- Add ShareViewController with complete URL extraction logic - Support URL sharing from Safari, Chrome and other apps - Extract URLs from different content types (URL, plain text, property list) - Implement direct API call to create bookmarks from share extension - Add Core Data integration to fetch authentication token - Include proper error handling and user feedback with alerts - Support title extraction and user text input for bookmark creation Technical implementation: - Handle UTType.url, UTType.plainText, and UTType.propertyList - Async/await pattern for API requests - NSDataDetector for URL extraction from text - Property list parsing for Safari-style sharing - Loading and success/error alerts for better UX
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)
|
|
}
|
|
}
|