- 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.
60 lines
1.9 KiB
Swift
60 lines
1.9 KiB
Swift
import SwiftUI
|
|
|
|
struct LabelsView: View {
|
|
@State var viewModel = LabelsViewModel()
|
|
@Binding var selectedTag: BookmarkLabel?
|
|
|
|
init(viewModel: LabelsViewModel = LabelsViewModel(), selectedTag: Binding<BookmarkLabel?>) {
|
|
self.viewModel = viewModel
|
|
self._selectedTag = selectedTag
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
if viewModel.isLoading {
|
|
ProgressView()
|
|
} else if let errorMessage = viewModel.errorMessage {
|
|
Text("Error: \(errorMessage)")
|
|
.foregroundColor(.red)
|
|
} else {
|
|
List {
|
|
ForEach(viewModel.labels, id: \.href) { label in
|
|
if UIDevice.isPhone {
|
|
NavigationLink {
|
|
BookmarksView(state: .all, type: [], selectedBookmark: .constant(nil), tag: label.name)
|
|
.navigationTitle("\(label.name) (\(label.count))")
|
|
} label: {
|
|
ButtonLabel(label)
|
|
}
|
|
} else {
|
|
Button {
|
|
selectedTag = nil
|
|
DispatchQueue.main.async {
|
|
selectedTag = label
|
|
}
|
|
} label: {
|
|
ButtonLabel(label)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
Task {
|
|
await viewModel.loadLabels()
|
|
}
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func ButtonLabel(_ label: BookmarkLabel) -> some View {
|
|
HStack {
|
|
Text(label.name)
|
|
Spacer()
|
|
Text("\(label.count)")
|
|
.foregroundColor(.secondary)
|
|
}
|
|
}
|
|
}
|