Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions FLINT/Data/Sources/DTO/Collection/ToggleBookmarkResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// ToggleBookmarkResponseDTO.swift
// Data
//
// Created by 소은 on 4/22/26.
//


import Foundation

import Entity

public struct ToggleBookmarkResponseDTO: Codable {
public let data: Bool?
}

extension ToggleBookmarkResponseDTO {
public var entity: Bool {
return data ?? false
}
}
5 changes: 3 additions & 2 deletions FLINT/FLINT/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window = UIWindow(windowScene: windowScene)

// let viewController = diContainer.makeSplashViewController()
let viewController = diContainer.makeNicknameViewController()
// let viewController = diContainer.makeTabBarViewController()
// let viewController = diContainer.makeNicknameViewController()
let viewController = diContainer.makeTabBarViewController()

let navigationController = UINavigationController(rootViewController: viewController).configured({
$0.navigationBar.isHidden = true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import Foundation

import Presentation

protocol CollectionFolderListViewModelFactory: FetchRecentViewedCollectionsUseCaseFactory {
protocol CollectionFolderListViewModelFactory:
FetchRecentViewedCollectionsUseCaseFactory &
ToggleCollectionBookmarkUseCaseFactory {
func makeCollectionFolderListViewModel() -> CollectionFolderListViewModel
}

extension CollectionFolderListViewModelFactory {
func makeCollectionFolderListViewModel() -> CollectionFolderListViewModel {
return CollectionFolderListViewModel(fetchRecentViewedCollectionsUseCase: makeFetchRecentViewedCollectionsUseCase())
return CollectionFolderListViewModel(
fetchRecentViewedCollectionsUseCase: makeFetchRecentViewedCollectionsUseCase(),
toggleCollectionBookmarkUseCase: makeToggleCollectionBookmarkUseCase()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ extension CollectionFolderListViewController: UICollectionViewDataSource {
let entity = viewModel.items[indexPath.item]

let firstURL = entity.imageList.first ?? entity.thumbnailUrl
let secondString = entity.imageList.count > 1 ? entity.imageList[1] : nil
let secondURL = entity.imageList[safe: 1]
let profileURL = entity.user.profileImageUrl

Expand Down Expand Up @@ -220,98 +219,3 @@ extension CollectionFolderListViewController: UICollectionViewDelegateFlowLayout
) -> CGFloat { 24 }
}

// MARK: - FolderItem (화면 전용 더미 모델)

private extension CollectionFolderListViewController {

struct FolderItem {
let firstPosterImage: UIImage?
let secondPosterImage: UIImage?

let profileImage: UIImage?
let name: String

let title: String
let description: String

var isBookmarked: Bool
let bookmarkedCountText: String?

static func mock() -> [FolderItem] {
return [
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: DesignSystem.Image.Common.profileBlue,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: true,
bookmarkedCountText: "123"
),
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: DesignSystem.Image.Common.profileBlue,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: true,
bookmarkedCountText: "123"
),
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: DesignSystem.Image.Common.profileBlue,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: false,
bookmarkedCountText: "123"
),
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: nil,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: true,
bookmarkedCountText: "123"
),
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: nil,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: false,
bookmarkedCountText: "123"
),
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: nil,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: true,
bookmarkedCountText: "123"
),
.init(
firstPosterImage: nil,
secondPosterImage: nil,
profileImage: nil,
name: "닉네임",
title: "한번 보면 못 빠져나오는 사랑이야기",
description: "이 컬렉션은 세계최고 너무나도 멋진 컬렉션입니다",
isBookmarked: true,
bookmarkedCountText: "123"
)

]
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ public final class CollectionFolderListViewModel {

// MARK: - Dependency
private let fetchRecentViewedCollectionsUseCase: FetchRecentViewedCollectionsUseCase
private let toggleCollectionBookmarkUseCase: ToggleCollectionBookmarkUseCase
private var cancellables = Set<AnyCancellable>()

public init(fetchRecentViewedCollectionsUseCase: FetchRecentViewedCollectionsUseCase) {
public init(
fetchRecentViewedCollectionsUseCase: FetchRecentViewedCollectionsUseCase,
toggleCollectionBookmarkUseCase: ToggleCollectionBookmarkUseCase
) {
self.fetchRecentViewedCollectionsUseCase = fetchRecentViewedCollectionsUseCase
self.toggleCollectionBookmarkUseCase = toggleCollectionBookmarkUseCase
}

public func load() {
Expand All @@ -39,20 +44,35 @@ public final class CollectionFolderListViewModel {
}

public func updateBookmark(at index: Int, isBookmarked: Bool) {

guard items.indices.contains(index) else { return }

let old = items[index]

let collectionId = old.id
guard let collectionIdInt = Int64(collectionId) else { return }

items[index] = CollectionEntity(
id: old.id,
thumbnailUrl: old.thumbnailUrl,
title: old.title,
description: old.description,
imageList: old.imageList,
bookmarkCount: old.bookmarkCount,
bookmarkCount: isBookmarked ? old.bookmarkCount + 1 : max(old.bookmarkCount - 1, 0),
isBookmarked: isBookmarked,
user: old.user
)

toggleCollectionBookmarkUseCase(collectionId: collectionIdInt)
.receive(on: DispatchQueue.main)
.sink { completion in
if case let .failure(error) = completion {
print("❌ toggleBookmark failed:", error)
}
} receiveValue: { isBookmarked in
print("✅ toggleBookmark success:", isBookmarked)
}
.store(in: &cancellables)
}

}
Expand Down