Stabilize iOS/watchOS/tvOS apps and add cross-platform audit remediation
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import AVKit
|
||||
import SharedCore
|
||||
|
||||
|
||||
struct Constants {
|
||||
@@ -24,21 +25,24 @@ struct Werkout_iosApp: App {
|
||||
let persistenceController = PersistenceController.shared
|
||||
@State var additionalWindows: [UIWindow] = []
|
||||
@State private var tabSelection = 1
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
let pub = NotificationCenter.default.publisher(for: NSNotification.Name("CreatedNewWorkout"))
|
||||
let pub = NotificationCenter.default.publisher(for: AppNotifications.createdNewWorkout)
|
||||
|
||||
private var screenDidConnectPublisher: AnyPublisher<UIScreen, Never> {
|
||||
NotificationCenter.default
|
||||
.publisher(for: UIScreen.didConnectNotification)
|
||||
.compactMap { $0.object as? UIScreen }
|
||||
.publisher(for: UIScene.willConnectNotification)
|
||||
.compactMap { ($0.object as? UIWindowScene)?.screen }
|
||||
.filter { $0 != UIScreen.main }
|
||||
.receive(on: RunLoop.main)
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private var screenDidDisconnectPublisher: AnyPublisher<UIScreen, Never> {
|
||||
NotificationCenter.default
|
||||
.publisher(for: UIScreen.didDisconnectNotification)
|
||||
.compactMap { $0.object as? UIScreen }
|
||||
.publisher(for: UIScene.didDisconnectNotification)
|
||||
.compactMap { ($0.object as? UIWindowScene)?.screen }
|
||||
.filter { $0 != UIScreen.main }
|
||||
.receive(on: RunLoop.main)
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
@@ -74,10 +78,13 @@ struct Werkout_iosApp: App {
|
||||
}
|
||||
.accentColor(Color("appColor"))
|
||||
.onAppear{
|
||||
UIApplication.shared.isIdleTimerDisabled = true
|
||||
UIApplication.shared.isIdleTimerDisabled = scenePhase == .active
|
||||
_ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: .default, options: .mixWithOthers)
|
||||
// UserStore.shared.logout()
|
||||
}
|
||||
.onChange(of: scenePhase) { phase in
|
||||
UIApplication.shared.isIdleTimerDisabled = phase == .active
|
||||
}
|
||||
.onReceive(pub) { (output) in
|
||||
self.tabSelection = 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user