- Add CREATE API endpoint for new bookmarks with POST request - Implement CreateBookmarkRequestDto and CreateBookmarkResponseDto - Create AddBookmarkView with form validation and clipboard integration - Add AddBookmarkViewModel with URL validation and label parsing - Implement CreateBookmarkUseCase with convenience methods - Extend BookmarksRepository with createBookmark method returning server message - Add comprehensive error handling for bookmark creation scenarios - Integrate WebView dark mode support with CSS variables and system color scheme - Add dynamic theme switching based on iOS appearance settings - Enhance WebView styling with iOS-native colors and typography - Fix BookmarksView refresh after bookmark creation - Add floating action button and sheet presentation for adding bookmarks - Implement form validation with real-time feedback - Add clipboard URL detection and paste functionality
66 lines
2.3 KiB
Swift
66 lines
2.3 KiB
Swift
import Foundation
|
|
|
|
protocol UseCaseFactory {
|
|
func makeLoginUseCase() -> LoginUseCase
|
|
func makeGetBookmarksUseCase() -> GetBookmarksUseCase
|
|
func makeGetBookmarkUseCase() -> GetBookmarkUseCase
|
|
func makeGetBookmarkArticleUseCase() -> GetBookmarkArticleUseCase
|
|
func makeSaveSettingsUseCase() -> SaveSettingsUseCase
|
|
func makeLoadSettingsUseCase() -> LoadSettingsUseCase
|
|
func makeUpdateBookmarkUseCase() -> UpdateBookmarkUseCase
|
|
func makeDeleteBookmarkUseCase() -> DeleteBookmarkUseCase
|
|
func makeCreateBookmarkUseCase() -> CreateBookmarkUseCase
|
|
}
|
|
|
|
class DefaultUseCaseFactory: UseCaseFactory {
|
|
private let tokenProvider = CoreDataTokenProvider()
|
|
private lazy var api: PAPI = API(tokenProvider: tokenProvider)
|
|
private lazy var authRepository: PAuthRepository = AuthRepository(api: api, settingsRepository: SettingsRepository())
|
|
private lazy var bookmarksRepository: PBookmarksRepository = BookmarksRepository(api: api)
|
|
|
|
static let shared = DefaultUseCaseFactory()
|
|
|
|
private init() {}
|
|
|
|
func makeLoginUseCase() -> LoginUseCase {
|
|
LoginUseCase(repository: authRepository)
|
|
}
|
|
|
|
func makeGetBookmarksUseCase() -> GetBookmarksUseCase {
|
|
GetBookmarksUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeGetBookmarkUseCase() -> GetBookmarkUseCase {
|
|
GetBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeGetBookmarkArticleUseCase() -> GetBookmarkArticleUseCase {
|
|
GetBookmarkArticleUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeSaveSettingsUseCase() -> SaveSettingsUseCase {
|
|
SaveSettingsUseCase(authRepository: authRepository)
|
|
}
|
|
|
|
func makeLoadSettingsUseCase() -> LoadSettingsUseCase {
|
|
LoadSettingsUseCase(authRepository: authRepository)
|
|
}
|
|
|
|
func makeUpdateBookmarkUseCase() -> UpdateBookmarkUseCase {
|
|
return UpdateBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
// Nicht mehr nötig - Token wird automatisch geladen
|
|
func refreshConfiguration() async {
|
|
// Optional: Cache löschen falls nötig
|
|
}
|
|
|
|
func makeDeleteBookmarkUseCase() -> DeleteBookmarkUseCase {
|
|
return DeleteBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeCreateBookmarkUseCase() -> CreateBookmarkUseCase {
|
|
return CreateBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
}
|