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 Endpoint { | |
var scheme: String { get } | |
var host: String { get } | |
var path: String { get } | |
var method: RequestMethod { get } | |
var header: [String: String]? { get } | |
var body: [String: String]? { get } | |
} | |
extension Endpoint { |
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
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
if let navController = window!.rootViewController as? UINavigationController { | |
navController.delegate = self | |
let appearance2 = UINavigationBarAppearance() | |
appearance2.backgroundColor = .systemBlue | |
appearance2.titleTextAttributes = [.foregroundColor: UIColor.white] | |
appearance2.largeTitleTextAttributes = [.foregroundColor: UIColor.white] | |
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 String { | |
var isValidEmail: Bool { | |
let emailFormat = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}" | |
let emailPredicate = NSPredicate(format: "SELF MATCHES %@", emailFormat) | |
return emailPredicate.evaluate(with: self) | |
} | |
var isValidPassword: Bool { | |
//Regex restricts to 8 character minimum, 1 capital letter, 1 lowercased letter, 1 number | |
let passwordFormat = "(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).{8,}" |
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
enum ScreenSize { | |
static let width = UIScreen.main.bounds.size.width | |
static let height = UIScreen.main.bounds.size.height | |
static let maxLength = max(ScreenSize.width, ScreenSize.height) | |
static let minLength = min(ScreenSize.width, ScreenSize.height) | |
} | |
enum DeviceTypes { | |
static let idiom = UIDevice.current.userInterfaceIdiom |
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
func syncOnMainThread<T>(execute block: () throws -> T) rethrows -> T { | |
if Thread.isMainThread { | |
return try block() | |
} | |
return DispatchQueue.main.sync(execute: block) | |
} |
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 ViewController { | |
private func setNotificationForKeyboardAppearance() { | |
NotificationCenter.default.addObserver( | |
self, | |
selector: #selector(self.keyboardWillShow), | |
name: UIResponder.keyboardWillShowNotification, | |
object: nil) | |
NotificationCenter.default.addObserver( |
OlderNewer