- Add BookmarkLabel model and DTO - Create LabelsRepository and PLabelsRepository protocol - Add GetLabelsUseCase for fetching labels - Update BookmarkMapper to handle labels - Add LabelsView and LabelsViewModel for UI - Update BookmarksView and BookmarkLabelsView to display labels - Add green2 color asset for labels - Update API and repository layers to support labels
80 lines
2.0 KiB
Swift
80 lines
2.0 KiB
Swift
import Foundation
|
|
|
|
extension BookmarksPageDto {
|
|
func toDomain() -> BookmarksPage {
|
|
return BookmarksPage(
|
|
bookmarks: bookmarks.map { $0.toDomain() },
|
|
currentPage: currentPage,
|
|
totalCount: totalCount,
|
|
totalPages: totalPages,
|
|
links: links
|
|
)
|
|
}
|
|
}
|
|
|
|
// MARK: - BookmarkDto to Domain Mapping
|
|
extension BookmarkDto {
|
|
func toDomain() -> Bookmark {
|
|
return Bookmark(
|
|
id: id,
|
|
title: title,
|
|
url: url,
|
|
href: href,
|
|
description: description,
|
|
authors: authors,
|
|
created: created,
|
|
published: published,
|
|
updated: updated,
|
|
siteName: siteName,
|
|
site: site,
|
|
readingTime: readingTime,
|
|
wordCount: wordCount,
|
|
hasArticle: hasArticle,
|
|
isArchived: isArchived,
|
|
isDeleted: isDeleted,
|
|
isMarked: isMarked,
|
|
labels: labels,
|
|
lang: lang,
|
|
loaded: loaded,
|
|
readProgress: readProgress,
|
|
documentType: documentType,
|
|
state: state,
|
|
textDirection: textDirection,
|
|
type: type,
|
|
resources: resources.toDomain()
|
|
)
|
|
}
|
|
}
|
|
|
|
// MARK: - Resources Mapping
|
|
extension BookmarkResourcesDto {
|
|
func toDomain() -> BookmarkResources {
|
|
return BookmarkResources(
|
|
article: article?.toDomain(),
|
|
icon: icon?.toDomain(),
|
|
image: image?.toDomain(),
|
|
log: log?.toDomain(),
|
|
props: props?.toDomain(),
|
|
thumbnail: thumbnail?.toDomain()
|
|
)
|
|
}
|
|
}
|
|
|
|
extension ResourceDto {
|
|
func toDomain() -> Resource {
|
|
return Resource(src: src)
|
|
}
|
|
}
|
|
|
|
extension ImageResourceDto {
|
|
func toDomain() -> ImageResource {
|
|
return ImageResource(src: src, height: height, width: width)
|
|
}
|
|
}
|
|
|
|
extension BookmarkLabelDto {
|
|
func toDomain() -> BookmarkLabel {
|
|
return BookmarkLabel(name: self.name, count: self.count, href: self.href)
|
|
}
|
|
}
|