This file contains hidden or 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 Updateable { | |
| func updated(block: (inout Self) -> ()) -> Self | |
| } | |
| extension Updateable { | |
| func updated(block: (inout Self) -> ()) -> Self { | |
| var item = self | |
| block(&item) | |
| return item | |
| } |
This file contains hidden or 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 Logger { | |
| static var defaultLogger = Logger() | |
| func log(_ message: String) { | |
| print(message) | |
| } | |
| } |
This file contains hidden or 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 CGSize { | |
| // get scale of image size with max dimention | |
| public func scale(max: CGFloat) -> CGFloat { | |
| if width > height{ | |
| if width > max { | |
| return max / width | |
| } | |
| } else { | |
| if height > max { | |
| return max / height |
This file contains hidden or 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 issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin | |
| // first header and last footer when bouncing. This layout subclass fixes that. | |
| class StickyLayout: UICollectionViewFlowLayout { | |
| override init() { | |
| super.init() | |
| self.sectionFootersPinToVisibleBounds = true | |
| self.sectionHeadersPinToVisibleBounds = true | |
| } |