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 UIKit | |
| class AnimatedTabBarController: UITabBarController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| delegate = self | |
| } | |
| } |
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
| // | |
| // ViewController.swift | |
| // ActivityViewController | |
| // | |
| // Created by Maksim Vialykh on 2019-02-21. | |
| // Copyright © 2019 Vialyx. All rights reserved. | |
| // | |
| import UIKit |
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 SafariServices | |
| import AuthenticationServices | |
| typealias AuthHandlerCompletion = (URL?, Error?) -> Void | |
| class AuthContextProvider: NSObject { | |
| private weak var anchor: ASPresentationAnchor! | |
| init(_ anchor: ASPresentationAnchor) { |
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
| struct Constants { | |
| static let authUrl = URL(string: "https://www.fitbit.com/oauth2/authorize") | |
| static let responseType = "code" | |
| static let clientId = "{YOUR_CLIENT_ID}" | |
| static let redirectScheme = "vialyx://" // YOU MUST DEFINE THAT SCHEME IN PROJECT SETTIGNS | |
| static let redirectUrl = "\(redirectScheme)fitbit/auth" | |
| static let scope = ["activity", "heartrate", "location", "nutrition", "profile", "settings", "sleep", "social", "weight"] | |
| static let expires = "604800" |
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
| class Model: AuthHandlerType { | |
| var session: NSObject? = nil | |
| var contextProvider: AuthContextProvider? | |
| func auth(_ completion: @escaping ((String?, Error?) -> Void)) { | |
| guard let authUrl = Constants.authUrl else { | |
| completion(nil, nil) | |
| return |
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
| class ViewController: UIViewController { | |
| var model: Model = Model() | |
| override func loadView() { | |
| super.loadView() | |
| let button = UIButton(frame: CGRect(x: 60, y: 100, width: 200, height: 100)) | |
| button.setTitle("Start Fitbit Auth", for: UIControl.State()) | |
| button.backgroundColor = .red |
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
| if segue.identifier == "signup", | |
| let vc = segue.destination as? OBSignupViewController { | |
| vc.email = emailTF.text | |
| } |
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
| struct Segue { | |
| var identifier: String | |
| } | |
| extension UIViewController { | |
| func perform(segue: Segue, sender: Any? = nil) { | |
| performSegue(withIdentifier: segue.identifier, sender: sender) | |
| } | |
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 UIKit | |
| extension Segue { | |
| static var signup: Segue = Segue(identifier: "signup") | |
| } | |
| class OBEmailViewController: UIViewController { | |
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
| class MaskedLabelView: UIView { | |
| weak var label: UILabel! | |
| var startColor: UIColor = .blue | |
| var endColor: UIColor = .black | |
| var duration: CFTimeInterval = 2.0 | |
| var repeatCount: Float = Float.infinity | |
| var completion: ((Bool) -> Void)? | |
| // CAGradientLayer provide api to work with gradient colors |