This file contains 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 | |
extension String { | |
mutating func isValidEmail() -> Bool { | |
guard !self.lowercased().hasPrefix("mailto:") else { return false } | |
guard let emailDetector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else { return false } | |
This file contains 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 tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool { | |
if let fromView = tabBarController.selectedViewController?.view, | |
let toView = viewController.view, fromView != toView, | |
let controllerIndex = self.viewControllers?.index(of: viewController) { | |
let viewSize = fromView.frame | |
let scrollRight = controllerIndex > tabBarController.selectedIndex | |
// Avoid UI issues when switching tabs fast |