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 ResourceCell { | |
func setupResource(title: String) | |
func setupResource(description: String) | |
func setupResource(imageURL URL: URL) | |
} | |
struct ResourceItemViewModel: ItemViewModel { |
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 ResourceCell { | |
func setupResource(title: String) | |
func setupResource(description: String) | |
func setupResource(imageURL URL: URL) | |
} |
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 ResourceCollectionViewCell: UICollectionViewCell { | |
@IBOutlet weak var titleLabel: UILabel! | |
@IBOutlet weak var descriptionLabel: UILabel! | |
@IBOutlet weak var imageView: UIImageView! | |
} | |
extension ResourceCollectionViewCell: ResourceCell { |
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
//The standard Interface to make requests and get AsyncContent | |
protocol RequestManager { | |
func getContent(_ resourceId: Int, completion: @escaping (Resource.AsyncContent?, Error?) -> ()) | |
} | |
//The concrete Implementation of the interface, this object is responsible to do the real Network request and parse the result. | |
struct APIRequestManager: RequestManager { | |
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 protocol GridSection: SectionViewModel { | |
var lineItems: Int? { get } | |
var referenceItemWidth: CGFloat { get } | |
var sectionInsets: UIEdgeInsets { get } | |
var sectionHorizontalItemSpacing: CGFloat { 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
public protocol ItemViewDescriptor { | |
var reuseIdentifier: String { get } | |
} | |
public protocol ItemViewModel { | |
var descriptor: ItemViewDescriptor { get set } | |
var reuseIdentifier: String { 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
public struct ViewRatio: Equatable { | |
public var multiplier: CGFloat | |
public var constant: CGFloat | |
} | |
public protocol GridDescriptor: GridItem { | |
var ratio: ViewRatio { 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 ColorCollectionViewCell: UICollectionViewCell { | |
struct Descriptor: ItemViewDescriptor, GridDescriptor { | |
let reuseIdentifier: String = String(describing: ColorCollectionViewCell.self) | |
let ratio: ViewRatio = ViewRatio(multiplier: 1.6, constant: 0.0) | |
} | |
} |
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 BaseSection: SectionViewModel { | |
var header: ItemViewModel? | |
var items: [ItemViewModel] | |
var footer: ItemViewModel? | |
init(header: ItemViewModel? = nil, items: [ItemViewModel] = [], footer: ItemViewModel? = nil) { | |
self.header = header |
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
open class Builder<Context> { | |
public init() { } | |
open func build(_ context: Context) -> UIViewController? { | |
return nil | |
} | |
} |