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
| extension UIScrollView { | |
| var isBouncing: Bool { | |
| return isBouncingTop || isBouncingBottom | |
| } | |
| var isBouncingTop: Bool { | |
| return contentOffset.y < topInsetForBouncing - contentInset.top | |
| } | |
| var isBouncingBottom: Bool { |
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
| // | |
| // UIScrollViewWrapper.swift | |
| // lingq-5 | |
| // | |
| // Created by Timothy Costa on 2019/07/05. | |
| // Copyright © 2019 timothycosta.com. All rights reserved. | |
| // | |
| import SwiftUI |
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 ViewControllerHolder { | |
| weak var value: UIViewController? | |
| init(_ value: UIViewController?) { | |
| self.value = value | |
| } | |
| } | |
| struct ViewControllerKey: EnvironmentKey { | |
| static var defaultValue: ViewControllerHolder { return ViewControllerHolder(UIApplication.shared.windows.first?.rootViewController ) } |
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 Foundation | |
| /// Registers how many times an app has been launched, using UserDefaults as storage. | |
| class LaunchCounter { | |
| private var defaults: UserDefaults | |
| private var defaultsKey = "launchCount" | |
| /// Initialise, optionally with a custom UserDefaults instance | |
| init(defaults: UserDefaults = .standard) { |
NewerOlder