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
@propertyWrapper | |
struct EmailValidated { | |
private(set) var defaultValue: String = "" | |
var wrappedValue: String { | |
get { defaultValue } | |
set { defaultValue = maxLength(newValue) && isValid(newValue) | |
? | |
newValue | |
: |
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 | |
struct Email { | |
private var string: String | |
init(_ string: String) throws { | |
try Validations.email(string) | |
self.string = string | |
} |
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 application(_ application: UIApplication, | |
continue userActivity: NSUserActivity, | |
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { | |
return handle(userAcitivity: userActivity) | |
} | |
// MARK: - Private | |
private func handle(userAcitivity activity: NSUserActivity) -> Bool { | |
switch activity.activityType { | |
case "com.mobiquity.TakeUrPill.history": |
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
final class HistoryViewController: BaseViewController { | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
if let information = presenter?.information { | |
activitySetup(information) | |
} | |
} | |
} |
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 | |
import Intents | |
struct SiriService { | |
struct ActivityInformation { | |
let activityType: String | |
let activityTitle: String | |
let activitySuggestedInvocation: String | |
} |
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
excluded: # paths to ignore during linting. Takes precedence over `included`. | |
- Tests | |
- Pods | |
- Carthage | |
- R.generated.swift | |
- MyPlayground.playground | |
disabled_rules: | |
- trailing_whitespace | |
- multiple_closures_trailing_closure |
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 | |
import UIKit // Only to use CGFloat 😬 | |
import WatchKit | |
enum WatchModelType { | |
case large | |
case small | |
} | |
struct WatchModel { |
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
// Ispired by http://rasic.info/bindings-generics-swift-and-mvvm/ | |
class Dynamic<T> { | |
typealias Listener = (T) -> Void | |
var listener: Listener? | |
func bind(listener: Listener?) { | |
self.listener = listener | |
} | |
func bindAndFire(listener: Listener?) { |
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
class foo { | |
let className = "foo" | |
} | |
let a = foo() | |
func isFoo(_ instance: Any) -> Bool { | |
return instance is foo | |
} |
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
/// Validate email string | |
/// | |
/// - parameter email: A String that rappresent an email address | |
/// | |
/// - returns: A Boolean value indicating whether an email is valid. | |
func isValid(_ email: String) -> Bool { | |
let emailRegEx = "(?:[a-zA-Z0-9!#$%\\&‘*+/=?\\^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%\\&'*+/=?\\^_`{|}” + | |
“~-]+)*|\“(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\” + | |
“x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\“)@(?:(?:[a-z0-9](?:[a-” + | |
“z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5" + |
NewerOlder