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

86 lines
2.2 KiB
Swift

//
// RButton.swift
// readeck
//
// Created by Ilyas Hallak on 21.07.25.
//
// SPDX-License-Identifier: MIT
//
// This file is part of the readeck project and is licensed under the MIT License.
//
import SwiftUI
struct RButton<Label: View>: View {
let action: () -> Void
let isLoading: Bool
let isDisabled: Bool
let icon: String?
let label: () -> Label
init(isLoading: Bool = false, isDisabled: Bool = false, icon: String? = nil, action: @escaping () -> Void, @ViewBuilder label: @escaping () -> Label) {
self.action = action
self.isLoading = isLoading
self.isDisabled = isDisabled
self.icon = icon
self.label = label
}
var body: some View {
Button(action: {
if !isLoading && !isDisabled {
action()
}
}) {
HStack {
if isLoading {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
}
if let icon = icon {
Image(systemName: icon)
}
label()
}
.font(.title3.bold())
.frame(maxHeight: 60)
.padding(10)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color(.secondarySystemBackground))
)
}
.buttonStyle(.bordered)
.disabled(isLoading || isDisabled)
}
}
#Preview {
Group {
RButton(isLoading: false, isDisabled: false, icon: "star.fill", action: {}) {
Text("Favorite")
.foregroundColor(.yellow)
}
.padding()
.preferredColorScheme(.light)
RButton(isLoading: true, isDisabled: false, action: {}) {
Text("Loading...")
}
.padding()
.preferredColorScheme(.dark)
RButton(isLoading: false, isDisabled: true, icon: nil, action: {}) {
Text("Disabled")
}
.padding()
.preferredColorScheme(.dark)
RButton(isLoading: false, isDisabled: false, icon: nil, action: {}) {
Text("No Icon")
}
.padding()
.preferredColorScheme(.light)
}
}