Files
omnivore/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift
2023-12-07 17:15:53 +08:00

47 lines
1.2 KiB
Swift

#if os(iOS)
import Foundation
import Models
import Services
import SwiftUI
import Utils
import Views
public struct MiniPlayer: View {
@EnvironmentObject var audioController: AudioController
@Environment(\.colorScheme) private var colorScheme: ColorScheme
private let presentingView: AnyView
@AppStorage(UserDefaultKey.audioPlayerExpanded.rawValue) var expanded = true
init<PresentingView>(
presentingView: PresentingView
) where PresentingView: View {
self.presentingView = AnyView(presentingView)
}
public var body: some View {
ZStack(alignment: .center) {
presentingView
if let itemAudioProperties = self.audioController.itemAudioProperties {
ZStack(alignment: .bottom) {
Color.systemBackground.edgesIgnoringSafeArea(.bottom)
.frame(height: expanded ? 0 : 110, alignment: .bottom)
VStack {
Spacer(minLength: 0)
MiniPlayerViewer(itemAudioProperties: itemAudioProperties)
}
}
}
}
}
}
public extension View {
func miniPlayer() -> some View {
MiniPlayer(presentingView: self)
}
}
#endif