- 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.
31 lines
834 B
Swift
31 lines
834 B
Swift
import Foundation
|
|
import Observation
|
|
|
|
@Observable
|
|
class LabelsViewModel {
|
|
private let getLabelsUseCase: PGetLabelsUseCase
|
|
|
|
var labels: [BookmarkLabel] = []
|
|
var isLoading: Bool
|
|
var errorMessage: String?
|
|
|
|
init(factory: UseCaseFactory = DefaultUseCaseFactory.shared, labels: [BookmarkLabel] = [], isLoading: Bool = false, errorMessage: String? = nil) {
|
|
self.labels = labels
|
|
self.isLoading = isLoading
|
|
self.errorMessage = errorMessage
|
|
getLabelsUseCase = factory.makeGetLabelsUseCase()
|
|
}
|
|
|
|
@MainActor
|
|
func loadLabels() async {
|
|
isLoading = true
|
|
errorMessage = nil
|
|
do {
|
|
labels = try await getLabelsUseCase.execute()
|
|
} catch {
|
|
errorMessage = "Error loading labels"
|
|
}
|
|
isLoading = false
|
|
}
|
|
}
|