Blink/BlinkApp.swift
- 1.1 kB
- View raw
1//
2// BlinkApp.swift
3// BlinkApp
4//
5// Created by Alex Chan on 08/06/2023.
6//
8import SwiftUI
10@main
11struct BlinkApp: App {
12 @AppStorage("colorScheme") private var colorScheme: String = "dark"
14 let photosLibrary = PhotosLibrary()
16 var body: some Scene {
17 // Note: this uses `Window` instead of the `WindowGroup` from the
18 // standard SwiftUI template, so that SwiftUI knows this app only
19 // ever needs a single window, and it doesn't need to offer
20 // window/tab management.
21 //
22 // See https://www.optionalmap.com/posts/swiftui_single_window_app/
23 Window("Blink", id: "main") {
24 PhotoReviewer()
25 .environmentObject(photosLibrary)
26 .preferredColorScheme(preferredColorScheme())
27 }
29 Settings {
30 SettingsView()
31 }
32 }
34 private func preferredColorScheme() -> ColorScheme? {
35 switch(colorScheme) {
36 case "dark":
37 return .dark
38 case "light":
39 return .light
40 default:
41 return nil
42 }
43 }
45}