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 | |
| /// Static properties for all preview devices. | |
| /// | |
| /// Usage: | |
| /// | |
| /// ```swift | |
| /// struct TestView_Previews: PreviewProvider { | |
| /// static var previews: some View { | |
| /// Group { |
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 | |
| struct ContentView: View { | |
| @State var horizontal: Bool = true | |
| @Namespace var namespace | |
| var body: some View { | |
| VStack(spacing: 40) { | |
| if horizontal { | |
| HStack { items } |
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 Combine | |
| import SwiftUI | |
| import CoreData | |
| class CoreDataViewModel: NSObject, ObservableObject, NSFetchedResultsControllerDelegate { | |
| let container: NSPersistentContainer | |
| private var controllerUpdates = [NSObject: CurrentValueSubject<[NSFetchRequestResult], Never>]() | |
| init(container: NSPersistentContainer) { | |
| self.container = container |
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
| // | |
| // PomodoroPicker.swift | |
| // pomodoro | |
| // | |
| // Created by David Rozmajzl on 1/1/22. | |
| // | |
| import SwiftUI | |
| struct PomodoroPicker<Content, Item: Hashable>: View where Content: 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
| // | |
| // RemindersAppIcon.swift | |
| // RemindersAppIcon | |
| // | |
| // Created by David on 1/5/22. | |
| // | |
| import SwiftUI | |
| struct RemindersAppIcon: 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 | |
| @main | |
| struct testColorSchemeApp: App { | |
| @StateObject private var appearanceManager = AppearanceManager() | |
| var body: some Scene { | |
| WindowGroup { | |
| ContentView() | |
| .environmentObject(appearanceManager) |
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 Error { | |
| var code: Int { return (self as NSError).code } | |
| var domain: String { return (self as NSError).domain } | |
| var userInfo: [String:Any] { return (self as NSError).userInfo } | |
| func timeAfterWhichToRetry(retryCount: Int) -> TimeInterval? { | |
| // CloudKit suggests us retry too often, so slow us down as we retry a lot, up to 5 minutes | |
| if let suggestedTimeout = suggestedTimeAfterWhichToRetry { | |
| if suggestedTimeAfterWhichToRetry == 0 { | |
| return 0 |
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 | |
| struct IceCream { | |
| let title: String | |
| let icon: UIImage | |
| } | |
| struct AppSettings { | |
| static var fontSize = 17.0 | |
| } |
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 | |
| enum ColorAttribute: CodableAttributedStringKey, MarkdownDecodableAttributedStringKey { | |
| enum Value: String, Codable, Hashable { | |
| case red | |
| case orange | |
| case yellow | |
| case green | |
| case mint | |
| case teal |
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 { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| Task { | |
| // 1️⃣❓ UIViewController is in a MainActor context, so this Task | |
| // will inherit that, so the following pretend expensive call will | |
| // be on the main thread and likely block? | |
| ExpensiveOperationPerformer.doExpensiveLoopAndPrint() | |
| } |