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 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
| 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 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
| 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
| 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
| import UIKit | |
| class KeyboardAvoider { | |
| init(for scrollView: UIScrollView) { | |
| self.scrollView = scrollView | |
| let notificationCenter = NotificationCenter.default | |
| notificationCenter.addObserver( | |
| self, |
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
| var gifs = { | |
| 'imageElementId': 'http://example.com/myimage.gif' | |
| } | |
| function getUpdateImageSrcFunc(imageId) { | |
| return function() { | |
| document.getElementById(imageId).src = this.src; | |
| } | |
| } | |
| for (var imageId in gifs) { | |
| var gifSrc = gifs[imageId] |