metatext-app-ios-iphone-ipad/System/MetatextApp.swift

39 lines
1.2 KiB
Swift
Raw Normal View History

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