- API-Klasse mit allen CRUD-Operationen für Bookmarks - Login/Authentifizierung mit Bearer Token - Bookmarks abrufen (Liste und Details) - Artikel-Inhalt abrufen - DTO-Strukturen in separate Dateien aufgeteilt - UserDto für Authentifizierung - BookmarkDto für Bookmark-Listen - BookmarkDetailDto mit vollständigen Metadaten - MVVM-Architektur mit @Observable - SettingsViewModel für Anmeldung - BookmarksViewModel für Bookmark-Verwaltung - SwiftUI Views mit modernem Design - SettingsView mit Eingabefeldern und Validierung - BookmarksView mit Pull-to-Refresh und Leerzustand - MainTabView als Navigation - Use Case Pattern implementiert - LoginUseCase für Authentifizierung - GetBookmarksUseCase für Datenabfrage - DefaultUseCaseFactory für Dependency Injection - Fehlerbehandlung und Loading States - Protocol-basierte Architektur für bessere Testbarkeit
57 lines
1.7 KiB
Swift
57 lines
1.7 KiB
Swift
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@State private var viewModel = SettingsViewModel()
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
Form {
|
|
Section(header: Text("Anmeldedaten"), footer: SectionFooter()) {
|
|
TextField("Benutzername", text: $viewModel.username)
|
|
.autocorrectionDisabled()
|
|
.textInputAutocapitalization(.never)
|
|
|
|
SecureField("Passwort", text: $viewModel.password)
|
|
|
|
TextField("Endpoint", text: $viewModel.endpoint)
|
|
.keyboardType(.URL)
|
|
|
|
Button {
|
|
Task {
|
|
await viewModel.login()
|
|
}
|
|
} label: {
|
|
if viewModel.isLoading {
|
|
ProgressView()
|
|
} else {
|
|
Text("Speichern")
|
|
}
|
|
}
|
|
.disabled(viewModel.isLoginDisabled)
|
|
}
|
|
|
|
|
|
}
|
|
.navigationTitle("Einstellungen")
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func SectionFooter() -> some View {
|
|
switch viewModel.state {
|
|
case .error:
|
|
Text("Anmeldung fehlgeschlagen. Bitte überprüfen Sie Ihre Eingaben.")
|
|
.foregroundColor(.red)
|
|
case .success:
|
|
Text("Anmeldung erfolgreich!")
|
|
.foregroundColor(.green)
|
|
case .default:
|
|
Text("")
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
SettingsView()
|
|
}
|