This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ProfileViewController { | |
static func makeViewController(_ userService: UserService) -> ProfileViewController { | |
let viewController = ProfileViewController() | |
viewController.nameLabel.text = userService.user.name | |
viewController.imageView.imageUrl = userService.user.imageUrl // Assuming using an image caching libary | |
userService.friends.bind(to: viewController.friendsView) { cell, friend in | |
cell.nameLabel.text = friend.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ProfileViewController { | |
static func makeViewController() -> ProfileViewController { | |
let viewController = ProfileViewController() | |
// ...configure viewController... | |
return viewController | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ProfileViewController { | |
func makeLogoutButton() -> UIButton { | |
let button = UIButton(type: .system) | |
button.setTitle("Log out", for: .normal) | |
return button | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ProfileViewController { | |
static func makeViewController(_ userService: UserService) -> ProfileViewController { | |
let viewController = ProfileViewController() | |
... | |
viewController.friendsView.reactive.selectedItem | |
.with(latestFrom: userService.friends, combine: itemAtIndex) // Take element at selected index from friends array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ProfileViewController { | |
static func makeViewController(_ userService: UserService) -> ProfileViewController { | |
let viewController = ProfileViewController() | |
viewController.nameLabel.text = userService.user.name | |
viewController.imageView.imageUrl = userService.user.imageUrl // Assuming using an image caching libary | |
userService.friends.bind(to: viewController.friendsView) { cell, friend in | |
cell.nameLabel.text = friend.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ??? { | |
func makeViewController() -> ProfileViewController { | |
let viewController = ProfileViewController() | |
// ...configure viewController... | |
return viewController | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct User { | |
public let name: String | |
public let imageUrl: URL | |
} | |
public class UserService { | |
public let user: User | |
public let friends: SafeSignal<[User]> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProfileViewController: UIViewController { | |
public let nameLabel: UILabel | |
public let imageView: UIImageView | |
public let friendsView: UICollectionView | |
public let logoutButton: UIButton | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
public struct Style<View: UIView> { | |
public let style: (View) -> Void | |
public init(style: @escaping (View) -> Void) { | |
self.style = style | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProductView: UIView { | |
public let titleLabel = UILabel(style: Stylesheet.Product.title) | |
public let imageView = UIImageView(style: Stylesheet.Product.image) | |
} |
NewerOlder