ReadKeep/readeck/UI/SpeechPlayer/GlobalPlayerContainerView.swift
Ilyas Hallak 9b89e58115 Refactor TTS system with Combine and VoiceManager
- Replace @MainActor with Combine framework for TTS functionality
- Create VoiceManager class for voice selection and caching
- Add UserDefaults persistence for selected voice
- Optimize performance with voice caching and immediate UI updates
- Remove @MainActor from TTS-related Use Cases
- Add proper pause/resume delegate methods
- Improve reactive UI updates with @StateObject
- Clean up code and remove unnecessary comments
2025-07-09 23:15:23 +02:00

40 lines
1.1 KiB
Swift

import SwiftUI
struct GlobalPlayerContainerView<Content: View>: View {
let content: Content
@StateObject private var viewModel = SpeechPlayerViewModel()
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
var body: some View {
ZStack(alignment: .bottom) {
content
.frame(maxWidth: .infinity, maxHeight: .infinity)
if viewModel.hasItems {
VStack(spacing: 0) {
SpeechPlayerView()
.padding(.horizontal, 16)
.padding(.vertical, 8)
.transition(.move(edge: .bottom).combined(with: .opacity))
Rectangle()
.fill(.clear)
.frame(height: 49)
}
}
}
.animation(.spring(), value: viewModel.hasItems)
}
}
#Preview {
GlobalPlayerContainerView {
Text("Main Content")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(.systemBackground))
}
}