ReadKeep/readeck/UI/SpeechPlayer/GlobalPlayerContainerView.swift
Ilyas Hallak 8d4b08da11 Add TTS feature toggle, refactor settings, and improve UI
- Implemented a toggle for the 'Read Aloud' (TTS) feature in the general settings.
- Refactored AppSettings and PlayerUIState to support TTS enable/disable.
- Updated BookmarkDetailView, PadSidebarView, PhoneTabView, and GlobalPlayerContainerView to respect the TTS setting.
- Added new RButton component for consistent button styling.
- Improved LabelsView to support tag selection on iPad and iPhone.
- Updated SettingsGeneralView and SettingsGeneralViewModel for new TTS logic and removed unused app info code.
- Added app info section to SettingsContainerView.
- Updated SettingsServerView to use English labels and messages.
- Refactored SpeechPlayerViewModel to only initialize TTS when enabled.
- Updated Core Data model to include enableTTS in SettingEntity.
- Removed obsolete files (PersistenceController.swift, old PlayerUIState).
- Various bugfixes, code cleanups, and UI improvements.
2025-07-21 23:37:37 +02:00

42 lines
1.3 KiB
Swift

import SwiftUI
struct GlobalPlayerContainerView<Content: View>: View {
let content: Content
@StateObject private var viewModel = SpeechPlayerViewModel()
@EnvironmentObject var playerUIState: PlayerUIState
@EnvironmentObject var appSettings: AppSettings
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
var body: some View {
ZStack(alignment: .bottom) {
content
.frame(maxWidth: .infinity, maxHeight: .infinity)
if appSettings.enableTTS && viewModel.hasItems && playerUIState.isPlayerVisible {
VStack(spacing: 0) {
SpeechPlayerView(onClose: { playerUIState.hidePlayer() })
.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))
}
.environmentObject(PlayerUIState())
}