// // Swiftfin is subject to the terms of the Mozilla Public // License, v2.0. If a copy of the MPL was not distributed with this // file, you can obtain one at https://mozilla.org/MPL/2.0/. // // Copyright (c) 2024 Jellyfin & Jellyfin Contributors // import SwiftUI // TODO: Look at name spacing // TODO: Consistent naming: ...Key struct AudioOffset: EnvironmentKey { static let defaultValue: Binding = .constant(0) } struct AspectFilled: EnvironmentKey { static let defaultValue: Binding = .constant(false) } struct CurrentOverlayType: EnvironmentKey { static let defaultValue: Binding = .constant(.main) } struct IsScrubbing: EnvironmentKey { static let defaultValue: Binding = .constant(false) } struct PlaybackSpeedKey: EnvironmentKey { static let defaultValue: Binding = .constant(1) } struct SafeAreaInsetsKey: EnvironmentKey { static var defaultValue: EdgeInsets { UIApplication.shared.keyWindow?.safeAreaInsets.asEdgeInsets ?? .zero } } struct SubtitleOffset: EnvironmentKey { static let defaultValue: Binding = .constant(0) } struct IsPresentingOverlayKey: EnvironmentKey { static let defaultValue: Binding = .constant(false) } extension EnvironmentValues { var isPresentingOverlay: Binding { get { self[IsPresentingOverlayKey.self] } set { self[IsPresentingOverlayKey.self] = newValue } } var audioOffset: Binding { get { self[AudioOffset.self] } set { self[AudioOffset.self] = newValue } } var aspectFilled: Binding { get { self[AspectFilled.self] } set { self[AspectFilled.self] = newValue } } var currentOverlayType: Binding { get { self[CurrentOverlayType.self] } set { self[CurrentOverlayType.self] = newValue } } var isScrubbing: Binding { get { self[IsScrubbing.self] } set { self[IsScrubbing.self] = newValue } } var playbackSpeed: Binding { get { self[PlaybackSpeedKey.self] } set { self[PlaybackSpeedKey.self] = newValue } } var safeAreaInsets: EdgeInsets { self[SafeAreaInsetsKey.self] } var subtitleOffset: Binding { get { self[SubtitleOffset.self] } set { self[SubtitleOffset.self] = newValue } } }