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 UIView { | |
| func show(animated: Bool) { | |
| self.isHidden = false | |
| if animated { | |
| UIView.animate( | |
| withDuration: animationDuration, | |
| animations: { | |
| self.alpha = 1 | |
| } |
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 UIScrollView { | |
| func scrollToLeft(for distance: CGFloat, withAnimationDuration animationDuration: TimeInterval = 0.3) { | |
| var newOffset = self.contentOffset.x - distance | |
| if newOffset < 0 { | |
| newOffset = 0 | |
| } | |
| UIView.animate(withDuration: animationDuration) { | |
| self.contentOffset.x = newOffset | |
| } |
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
| import UIKit | |
| extension UITableViewCell { | |
| class var reuseIdentifier: String { | |
| return "tableViewCell" | |
| } | |
| } | |
| extension Collection { | |
| /// Returns the element at the specified index if it is within bounds, otherwise nil. |
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
| import Foundation | |
| typealias VoidVoid = () -> () | |
| protocol Repeating { | |
| func startRepeating(withIntervalInSeconds: TimeInterval) | |
| func stopRepeating() |
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
| import Foundation | |
| protocol ModelStateDelegate: class { | |
| func onModelStateOutdated() | |
| } | |
| class ModelState { | |
| weak var delegate: ModelStateDelegate? | |
| init(updateNotification: Foundation.Notification.Name, itemId: String? = nil, outdated: Bool = true) { |
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 NakedTabBarContorller: UITabBarController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.tabBar.isHidden = true | |
| } | |
| } |
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
| import Foundation | |
| protocol Repeating { | |
| func startRepeating(withIntervalInSeconds: TimeInterval) | |
| func stopRepeating() | |
| } |
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
| import UIKit | |
| /// Extend `NibView` to create a reusable view in a XIB file. | |
| /// The contents of the view are designed in a XIB file. | |
| /// The `NibView` class is responsible for loading the | |
| /// contents of the XIB file and setting it as its subview. | |
| /// File's Owner in the XIB file needs to be set to the | |
| /// view class extending the `NibView`. Any outlets defined | |
| /// in that class need to be connected to the File's Owner. | |
| open class NibView: UIView { |
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 Optional where Wrapped == String { | |
| var orEmpty: String { | |
| switch self { | |
| case .some(let value): | |
| return value | |
| case .none: | |
| return "" | |
| } | |
| } | |
| } |
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 UIImage { | |
| func tinted(with color: UIColor) -> UIImage? { | |
| let maskImage = cgImage | |
| let bounds = CGRect(origin: .zero, size: size) | |
| let renderer = UIGraphicsImageRenderer(size: size) | |
| // QuartzCore origin .zero is bottom-left, while UIKit's is top-left. | |
| let tintedButFlippedImage = renderer.image { context in | |
| let cgContext = context.cgContext | |
| cgContext.clip(to: bounds, mask: maskImage!) |