Created
November 26, 2018 12:26
-
-
Save Oni-zerone/2eaeaff654324b3327171fcd8911edf7 to your computer and use it in GitHub Desktop.
An example section ready to be used in PowerTools Framework
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 | |
self.items = items | |
self.footer = footer | |
} | |
mutating func append(_ item: ItemViewModel) { | |
self.items.append(item) | |
} | |
} | |
extension BaseSection: GridSection { | |
var lineItems: Int? { | |
return nil | |
} | |
var referenceItemWidth: CGFloat { | |
return 150 | |
} | |
var sectionHorizontalItemSpacing: CGFloat { | |
return 16.0 | |
} | |
var sectionVerticalItemSpacing: CGFloat { | |
return 20.0 | |
} | |
var sectionInsets: UIEdgeInsets { | |
return UIEdgeInsets(top: 20, left: 16, bottom: 20, right: 16) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment