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 | |
protocol IImageProvider: AnyObject { | |
func retrieve(_ completion: @escaping (UIImage?) -> Void) | |
func preload() | |
} | |
protocol IImageProviderConsumer { | |
var currentProvider: IImageProvider? { get set } |
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 | |
class AutoscaleImageView: UIImageView { | |
var aspectRatioConstraint: NSLayoutConstraint? | |
override init(image: UIImage?) { | |
super.init(image: image) | |
recalculateAspectRatioConstraint() | |
} |
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
struct ApartmentPlacement: Equatable { | |
let entrance: Int | |
let floor: Int | |
let location: Int | |
} | |
func calculateApartmentPlacement(for apartmentNumber: Int, totalEntrances: Int, totalFloors: Int) -> ApartmentPlacement? { | |
let apartmentIndex = apartmentNumber - 1 | |
guard totalEntrances > 0, totalFloors > 0 else { | |
return nil |
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
class TransactionCellView: UIView { | |
// ... other members omitted ... | |
let acceptButton = TransactionCellAcceptButton() | |
var iconToBottomConstraint: NSLayoutConstraint! | |
var acceptButtonToBottomConstraint: NSLayoutConstraint! | |
init(viewModel: TransactionCellViewModel) { | |
// ... omitted configuration of the view style ... | |
// ... omitted AutoLayout code ... |
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
protocol TransactionCellViewModel { | |
var icon: String { get } | |
var name: String { get } | |
var amount: NSDecimalNumber { get } | |
// Added in the following updates | |
var shouldShowAcceptButton: Bool { get } | |
} |
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
class TransactionCellView: UIView { | |
let iconImageView = UIImageView() | |
let nameLabel = UILabel() | |
let amountLabel = UILabel() | |
init(viewModel: TransactionCellViewModel) { | |
// ... omitted configuration of the view style ... | |
// ... omitted AutoLayout code ... | |
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
class TransactionTable: CustomTableView { | |
override init(viewModel: TransactionTableViewModel) { | |
super.init() | |
viewModel.transactionViewModels.forEach { transactionViewModel in | |
switch transactionViewModel { | |
case .info(let viewModel): | |
let cell = TransactionInfoCell(viewModel: viewModel) | |
self.addCell(cell) |
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
class TransactionTableViewModel { | |
// ... omitted ... | |
init(di: DI) { | |
self.transactionViewModels = di.transactionListService.getTransactionModels() | |
.map { transactionModel -> TransactionCellViewModel in | |
if transactionModel.isPendingAccept { | |
let viewModel = TransactionInfoWAcceptViewModel(model: transactionModel) | |
viewModel.acceptButtonTap | |
.map { _ in |
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
enum TransactionCellViewModel { | |
case info(TransactionInfoCellViewModel) | |
case infoPendingAccept(TransactionInfoWAcceptViewModel) | |
} |
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
class TransactionTableViewModel { | |
typealias DI = HasTransactionListService | |
let transactionViewModels: [TransactionCellViewModel] | |
class NavigationEvents { | |
let showTransactionAcceptScreen = PublishRelay<String>() | |
} | |
let navigation = NavigationEvents() | |
NewerOlder