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 RxSwift | |
| import RxCocoa | |
| func keyboardHeight() -> Observable<CGFloat> { | |
| return Observable | |
| .from([ | |
| NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow) | |
| .map { notification -> CGFloat in | |
| (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0 | |
| }, |
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 | |
| import UIKit | |
| struct BaseStyles { | |
| static func rounded<V: UIView>(cornerRadius r: CGFloat = 5.5) -> UIViewStyle<V> { | |
| return UIViewStyle<V>(styling: { (view: V) in | |
| view.layer.masksToBounds = true | |
| view.clipsToBounds = true | |
| view.layer.cornerRadius = r | |
| }) |
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 | |
| import UIKit | |
| // MARK: Protocol Definition | |
| /// Make your UIView subclasses conform to this protocol when: | |
| /// * they *are* NIB-based, and | |
| /// * this class is used as the XIB's root view | |
| /// | |
| /// to be able to instantiate them from the NIB in a type-safe manner | |
| public protocol NibLoadable: class { |
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 | |
| import UIKit | |
| class Notification { | |
| // Shows a Notification from a NotificationType | |
| public static func showNotification(type: NotificationType, completion: @escaping () -> () = {}) { | |
| let view = NotificationView() | |
| view.setBackgroundColor(color: type.backgroundColor) |
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 UIColor { | |
| convenience init(hexString: String, alpha: CGFloat = 1.0) { | |
| let hexString: String = hexString.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
| let scanner = Scanner(string: hexString) | |
| if (hexString.hasPrefix("#")) { | |
| scanner.scanLocation = 1 | |
| } | |
| var color: UInt32 = 0 | |
| scanner.scanHexInt32(&color) |
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 UIApplication { | |
| static var appVersion: String? { | |
| return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String | |
| } | |
| } |
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 UIApplication { | |
| class func topViewController(_ viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? { | |
| if let nav = viewController as? UINavigationController { | |
| return topViewController(nav.visibleViewController) | |
| } | |
| if let tab = viewController as? UITabBarController { | |
| if let selected = tab.selectedViewController { | |
| return topViewController(selected) | |
| } | |
| } |
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 CGFloat { | |
| static var random: CGFloat { | |
| return CGFloat(arc4random()) / CGFloat(UInt32.max) | |
| } | |
| } | |
| extension UIColor { | |
| static var random: UIColor { | |
| return UIColor(red: .random, green: .random, blue: .random, alpha: 1.0) | |
| } |
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 Int { | |
| func toString() -> String { | |
| return "\(self)" | |
| } | |
| func toObjCString() -> NSString { | |
| return NSString(format: "%d", self) | |
| } | |
| func toDouble() -> Double { |
NewerOlder