metatext/System/MetatextApp.swift

33 lines
938 B
Swift
Raw Normal View History

2020-07-19 02:12:32 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
2020-07-19 02:06:12 +00:00
2021-01-30 01:14:22 +00:00
import AVKit
import ServiceLayer
2020-07-19 02:06:12 +00:00
import SwiftUI
2020-09-01 07:33:49 +00:00
import ViewModels
2020-07-19 02:06:12 +00:00
@main
struct MetatextApp: App {
2020-08-12 07:24:39 +00:00
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
2021-02-04 08:30:37 +00:00
// swiftlint:disable:next force_try
private let viewModel = try! RootViewModel(environment: Self.environment)
2021-01-30 01:14:22 +00:00
init() {
try? AVAudioSession.sharedInstance().setCategory(.ambient, mode: .default)
2021-02-04 08:30:37 +00:00
try? ImageCacheConfiguration(environment: Self.environment).configure()
2021-01-30 01:14:22 +00:00
}
2020-08-12 07:24:39 +00:00
2020-07-19 02:06:12 +00:00
var body: some Scene {
2021-02-04 08:30:37 +00:00
viewModel.registerForRemoteNotifications = appDelegate.registerForRemoteNotifications
return WindowGroup {
RootView(viewModel: viewModel)
2020-07-19 02:06:12 +00:00
}
}
}
2021-01-30 01:14:22 +00:00
private extension MetatextApp {
2021-02-04 08:30:37 +00:00
static let environment = AppEnvironment.live(
userNotificationCenter: .current(),
reduceMotion: { UIAccessibility.isReduceMotionEnabled })
2021-01-30 01:14:22 +00:00
}