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) { |
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
| // | |
| // 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
| 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
| //------------------------------------------------------------------------ | |
| // The SwiftUI Lab: Advanced SwiftUI Animations | |
| // https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths) | |
| // https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect) | |
| // https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier) | |
| //------------------------------------------------------------------------ | |
| import SwiftUI | |
| struct ContentView: View { | |
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 SwiftUI | |
| class MyModel: ObservableObject { | |
| @Published var attempted: Bool = false | |
| @Published var firstname: String = "" { | |
| didSet { updateDismissability() } | |
| } | |
| @Published var lastname: String = "" { |
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
| // | |
| // ContentView.swift | |
| // TryGeometryReader | |
| // | |
| // Created by satoutakeshi on 2019/12/07. | |
| // Copyright © 2019 satoutakeshi. Licensed under MIT. | |
| // | |
| 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
| import SwiftUI | |
| /// SwiftUI implementation of a responsive-feeling scrollview with tappable tiles. | |
| /// We use a custom UIScrollView via UIViewRepresentable and a UIView tap overlay to | |
| /// get around current SwiftUI issues with simultaneous gesture recognition and allow | |
| /// the tiles to respond instantly to presses while scrolling. | |
| struct ContentView: View { | |
| @State private var showSheet = false |
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
| // | |
| // TipsView.swift | |
| // Stonks | |
| // | |
| // Created by Paul Stamatiou on 7/3/20. | |
| // | |
| import SwiftUI | |
| import PlaygroundSupport |
OlderNewer