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
@IBAction func didTapEmailButton(_ sender: Any) { | |
let authUI = FUIAuth.defaultAuthUI()! | |
authUI.delegate = self | |
let settings = ActionCodeSettings() | |
settings.url = Constants.URLs.login | |
settings.handleCodeInApp = true | |
settings.setIOSBundleID(Constants.AppInfo.bundleIdentifier) | |
authUI.providers = [ | |
FUIEmailAuth( | |
authAuthUI: authUI, |
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
public struct ISOString { | |
/// Parse ISO 6709 string. | |
/// e.g. "+34.0595-118.4460+091.541/" | |
/// SeeAlso: [ISO 6709](https://en.wikipedia.org/wiki/ISO_6709) | |
public static func parse(iso6709 text: String?) -> CLLocation? { | |
guard | |
let results = text?.capture(pattern: "([+-][0-9.]+)([+-][0-9.]+)"), | |
let latitude = results[safe: 1] as NSString?, | |
let longitude = results[safe: 2] as NSString? | |
else { return nil } |
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 UIKit | |
final class BackgroundTask { | |
private var taskID = UIBackgroundTaskIdentifier.invalid | |
func begin(withName taskName: String = #function) { | |
taskID = UIApplication.shared.beginBackgroundTask(withName: taskName) { | |
UIApplication.shared.endBackgroundTask(self.taskID) | |
self.taskID = UIBackgroundTaskIdentifier.invalid | |
} |
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
protocol DebuggableOptionSet: OptionSet, CustomDebugStringConvertible { | |
static var allOptions: [Self] { get } | |
static var allOptionNames: [String] { get } | |
} | |
extension DebuggableOptionSet where Self == Self.Element { | |
var debugDescription: String { | |
var result = "" | |
for (index, element) in Self.allOptions.enumerated() { | |
if contains(element) { |
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 FirebaseAuth | |
import FirebaseUI | |
import FirebaseFirestore | |
import FirebaseFunctions | |
import FirebaseStorage | |
struct FirebaseError: LocalizedError { | |
enum ErrorDomain { | |
case auth(code: AuthErrorCode, userInfo: [String: Any]) |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let items: [[Any]] = [ | |
["Foo", URL(string: "http://www.africau.edu/images/default/sample.pdf")!] | |
["Bar", URL(string: "http://www.africau.edu/images/default/sample.pdf")!] | |
] | |
presentActivityViewControllerRecursively(items: items) { (error, items) in | |
if let error = error, let items = items { | |
print("Failed to complete activity items: \(items)") | |
return |
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 FadeAnimator: NSObject, UIViewControllerAnimatedTransitioning { | |
private let presenting: Bool | |
init(presenting: Bool) { | |
self.presenting = presenting | |
} | |
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { | |
return 0.3 | |
} |
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 UIKit | |
final class JustTapGestureRecognizer: UITapGestureRecognizer { | |
private var timer: Timer? | |
private let cancellationTimeInterval = TimeInterval(0.1) | |
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) { | |
timer = Timer.scheduledTimer(withTimeInterval: cancellationTimeInterval, repeats: false) { [weak self] (_) in | |
self?.state = .cancelled | |
} |
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 SwiftUI | |
import FirebaseUI | |
struct SignInView: View { | |
@State private var user: FirebaseAuth.User? | |
var body: some View { | |
SignInViewController(user: $user) | |
} | |
} |
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
enum PanAxis { | |
case none | |
case horizontal | |
case vertical | |
} | |
/// Returns only translation in either horizontal or vertical direction determined at `UIGestureRecognizer.State.began`. | |
class DirectionalPanGestureRecognizer: UIPanGestureRecognizer { | |
var axis = PanAxis.none | |
var directionalTranslation: CGPoint { |