Skip to content

Instantly share code, notes, and snippets.

View vialyx's full-sized avatar
🎯
Focusing

Maxim Vialyx vialyx

🎯
Focusing
View GitHub Profile
import UIKit
class AnimatedTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
}
//
// ViewController.swift
// ActivityViewController
//
// Created by Maksim Vialykh on 2019-02-21.
// Copyright © 2019 Vialyx. All rights reserved.
//
import UIKit
import SafariServices
import AuthenticationServices
typealias AuthHandlerCompletion = (URL?, Error?) -> Void
class AuthContextProvider: NSObject {
private weak var anchor: ASPresentationAnchor!
init(_ anchor: ASPresentationAnchor) {
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"
@vialyx
vialyx / Model.swift
Last active September 9, 2020 20:04
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
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
if segue.identifier == "signup",
let vc = segue.destination as? OBSignupViewController {
vc.email = emailTF.text
}
struct Segue {
var identifier: String
}
extension UIViewController {
func perform(segue: Segue, sender: Any? = nil) {
performSegue(withIdentifier: segue.identifier, sender: sender)
}
import UIKit
extension Segue {
static var signup: Segue = Segue(identifier: "signup")
}
class OBEmailViewController: UIViewController {
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