- Add BookmarkState enum with unread, favorite, and archived states - Extend API layer with query parameter filtering for bookmark states - Update Bookmark domain model to match complete API response schema - Implement BookmarkListView with card-based UI and preview images - Add BookmarkListViewModel with state management and error handling - Enhance BookmarkDetailView with meta information and WebView rendering - Create comprehensive DTO mapping for all bookmark fields - Add TabView with state-based bookmark filtering - Implement date formatting utilities for ISO8601 timestamps - Add progress indicators and pull-to-refresh functionality
38 lines
842 B
Swift
38 lines
842 B
Swift
import Foundation
|
|
|
|
@Observable
|
|
class BookmarksViewModel {
|
|
private let getBooksmarksUseCase = DefaultUseCaseFactory.shared.makeGetBookmarksUseCase()
|
|
|
|
var bookmarks: [Bookmark] = []
|
|
var isLoading = false
|
|
var errorMessage: String?
|
|
var currentState: BookmarkState = .unread
|
|
|
|
|
|
init() {
|
|
|
|
}
|
|
|
|
@MainActor
|
|
func loadBookmarks(state: BookmarkState = .unread) async {
|
|
isLoading = true
|
|
errorMessage = nil
|
|
currentState = state
|
|
|
|
do {
|
|
bookmarks = try await getBooksmarksUseCase.execute(state: state)
|
|
} catch {
|
|
errorMessage = "Fehler beim Laden der Bookmarks"
|
|
bookmarks = []
|
|
}
|
|
|
|
isLoading = false
|
|
}
|
|
|
|
@MainActor
|
|
func refreshBookmarks() async {
|
|
await loadBookmarks(state: currentState)
|
|
}
|
|
}
|