diff --git a/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift b/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift index 8994195e..216b45d6 100644 --- a/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift +++ b/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift @@ -25,89 +25,77 @@ public struct ArchiveView: View { @EnvironmentObject var sheetManager: SheetManager let columns = [ - GridItem(.fixed(165)), GridItem(.fixed(165)) + GridItem(.fixed(175)), GridItem(.fixed(175)) ] let buttonHeight: CGFloat = 30 public var body: some View { VStack(){ - Image(assetName: "archiveViewBG") - .resizable() - .frame(width: UIScreen.main.bounds.width, height: UIScreen.screenHeight * 0.2) - .overlay( - VStack { - Spacer() - HStack { - Text("보관함") - .padding() - .pretendardFont(family: .SemiBold, size: 24) - .foregroundColor(.basicGray9) - Spacer() - } - } - ) + archiveHeader() - let posts = generateBookmarkPostContents() + staticsView(count: archiveViewViewModel.bookmarkCards.count) -// staticsView(count: homeViewViewModel.homeRandomQuoteModel?.data?.totalElements ?? .zero) - - if posts.count != 0 { + if !archiveViewViewModel.bookmarkCards.isEmpty { ScrollView(.vertical) { LazyVGrid(columns: columns) { - ForEach(posts) { post in - - let colorSet = viewModel.createColorSet(flavor: post.hashtags.flavor) - -// VStack { -// HStack { -// Circle() -// .foregroundColor(post.hashtags.flavor.type.backgroundImageName1) -// .frame(width: 20, height: 20) -// .overlay( -// Image(assetName: post.hashtags.flavor.type.smallIconImageName) -// .resizable() -// .frame(width: 14, height: 14) -// ) -// Circle() -// .foregroundColor(colorSet.iconBackground) -// .frame(width: 20, height: 20) -// .overlay( -// Image(assetName: post.hashtags.flavor.type.smallIconImageName) -// .resizable() -// .frame(width: 14, height: 14) -// ) -// Spacer() -// } -// .padding(EdgeInsets(top: 12, leading: 12, bottom: 0, trailing: 0)) -// Spacer() -// HStack { -// Text(post.title) -// .baeEun(size: 18) -// .foregroundColor(.cardTextMain) -// .padding() -// Spacer() -// } -// HStack { -// Text(post.author) -// .baeEun(size: 18) -// .foregroundColor(.cardTextMain) -// .padding() -// Spacer() -// } -// }.frame(width: 165, height: 240, alignment: .leading) -// .background(colorSet.background) -// .cornerRadius(10) -// .onTapGesture { -// withAnimation { -// let imageNameAndText = self.viewModel.generateImageNameAndText(hashtags: post.hashtags) -// viewModel.updateDetailViewInfo(colorSet: colorSet, cardInfomation: post, imageNameAndText: imageNameAndText) -// viewModel.isShowDetailView.toggle() -// } -// } + ForEach(archiveViewViewModel.bookmarkCards) { card in + let colorSet = viewModel.createColorSet(flavor: card.hashtags.flavor) + VStack { + HStack { + Circle() + .foregroundColor(colorSet.iconBackground) + .frame(width: 20, height: 20) + .overlay( + Image(assetName: card.hashtags.flavor.type.smallIconImageName) + .resizable() + .frame(width: 14, height: 14) + ) + Circle() + .foregroundColor(colorSet.iconBackground) + .frame(width: 20, height: 20) + .overlay( + Image(assetName: card.hashtags.source.type.smallIconImageName) + .resizable() + .frame(width: 14, height: 14) + ) + Spacer() + } + .padding(EdgeInsets(top: 12, leading: 12, bottom: 0, trailing: 0)) + + Spacer() + + HStack { + Text(card.title) + .baeEun(size: 18) + .foregroundColor(.cardTextMain) + .allowsTightening(true) + .padding() + Spacer() + } + + HStack { + Text(card.author) + .baeEun(size: 18) + .foregroundColor(.cardTextMain) + .padding() + Spacer() + } + } + .frame(width: 175, height: 240, alignment: .leading) + .background(colorSet.background) + .allowsTightening(true) + .cornerRadius(10) + .onTapGesture { + withAnimation { + viewModel.selectedCard = card + viewModel.isShowDetailView.toggle() + } + } } } } + .frame(height: UIScreen.main.bounds.height * 0.56) } else { VStack(alignment: .center){ Image(assetName: "archiveEmptyImage") @@ -133,7 +121,7 @@ public struct ArchiveView: View { } } .pretendardFont(family: .SemiBold, size: 18) - .frame(height: UIScreen.main.bounds.height * 0.6) + .frame(height: UIScreen.main.bounds.height * 0.56) } } .navigationDestination(isPresented: $appState.goToBackingView) { @@ -141,8 +129,43 @@ public struct ArchiveView: View { appState.goToBackingView = false }) } + .task { + await archiveViewViewModel.archiveRequest(userId: "423") { + archiveViewViewModel.bookmarkCards = [] + for quoteContent in archiveViewViewModel.archiveModel?.data ?? [] { + let hashTags = archiveViewViewModel.getHashtags(post: quoteContent) + //FIXME: archive api 수정 요청 +// self.viewModel.likeYn = quoteContent.likeYn ?? false + let card = CardInfomation(qouteId: quoteContent.quoteID ?? .zero, + hashtags: hashTags, image: "", + title: quoteContent.content ?? "", + sources: quoteContent.author ?? "", + isBookrmark: false) + archiveViewViewModel.bookmarkCards.append(card) + } + } + } + } + @ViewBuilder + private func archiveHeader() -> some View { + Image(assetName: "archiveViewBG") + .resizable() + .frame(width: UIScreen.main.bounds.width, height: UIScreen.screenHeight * 0.2) + .overlay( + VStack { + Spacer() + HStack { + Text("보관함") + .padding() + .pretendardFont(family: .SemiBold, size: 24) + .foregroundColor(.basicGray9) + Spacer() + } + } + ) } + @ViewBuilder private func staticsView(count: Int) -> some View { HStack{ HStack{ @@ -169,14 +192,4 @@ public struct ArchiveView: View { } .frame(width: UIScreen.screenWidth - 40, height: 38) } - - func generateBookmarkPostContents() -> [CardInfomation] { - var filterContent: [CardInfomation] = [] - for post in viewModel.cards { - if post.isBookrmark { - filterContent.append(post) - } - } - return filterContent - } } diff --git a/PingPong/Projects/Feature/Archive/Sources/UI/ViewModel/ArchiveViewViewModel.swift b/PingPong/Projects/Feature/Archive/Sources/UI/ViewModel/ArchiveViewViewModel.swift index 5cb69794..572f4aa2 100644 --- a/PingPong/Projects/Feature/Archive/Sources/UI/ViewModel/ArchiveViewViewModel.swift +++ b/PingPong/Projects/Feature/Archive/Sources/UI/ViewModel/ArchiveViewViewModel.swift @@ -21,11 +21,22 @@ public class ArchiveViewViewModel: ObservableObject { @Published public var isAscendingOrder = true @Published public var archiveModel: ArchiveModel? + + @Published public var bookmarkCards: [CardInfomation] = [] + var archiveCancellable: AnyCancellable? @Published public var deleteModel: DeleteModel? var deleteCancellable: AnyCancellable? + public func getHashtags(post: ArchiveResponseModel) -> Hashtags { + let flavor = Flavor(rawValue: post.flavor ?? "")! + let source = Source(rawValue: post.source ?? "")! + let mood = Mood(rawValue: post.mood ?? "")! + + return Hashtags(flavor: flavor, source: source, mood: mood) + } + public func archiveRequestToViewModel(_ list: ArchiveModel) { self.archiveModel = list } diff --git a/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift b/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift index 29dd82e5..651d6a89 100644 --- a/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift +++ b/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift @@ -241,8 +241,8 @@ struct FamousSayingBakeCardView: View { HStack{ HStack{ HStack { - Image(assetName: card.hashtags.source.type.korean) - Text("\(post.hashtags.flavor.rawValue)") + Image(assetName: post.hashtags.flavor.type.smallIconImageName) + Text("\(post.hashtags.flavor.type.korean)") .pretendardFont(family: .SemiBold, size: 12) } .foregroundColor(colorSet.icon) @@ -254,8 +254,8 @@ struct FamousSayingBakeCardView: View { ) HStack { - Image(assetName: card.hashtags.source.type.smallIconImageName) - Text("\(post.hashtags.source.rawValue)") + Image(assetName: post.hashtags.source.type.smallIconImageName) + Text("\(post.hashtags.source.type.korean)") .pretendardFont(family: .SemiBold, size: 12) .foregroundColor(colorSet.icon) } diff --git a/PingPong/Projects/Feature/Search/Sources/UI/View/ExploreView.swift b/PingPong/Projects/Feature/Search/Sources/UI/View/ExploreView.swift index 587e5d8d..e6888433 100644 --- a/PingPong/Projects/Feature/Search/Sources/UI/View/ExploreView.swift +++ b/PingPong/Projects/Feature/Search/Sources/UI/View/ExploreView.swift @@ -27,7 +27,7 @@ public struct ExploreView: View { @EnvironmentObject var sheetManager: SheetManager let columns = [ - GridItem(.fixed(175)), GridItem(.fixed(175)) + GridItem(.fixed(175)), GridItem(.fixed(175)) ] let buttonHeight: CGFloat = 30 @@ -35,8 +35,6 @@ public struct ExploreView: View { public var body: some View { ZStack { ScrollView(.vertical){ - // let (group, situationInfo, flavorCountInfo, sourceCountInfo) = filterHomePostContents() - searchBar() .padding(.top, 62) @@ -190,9 +188,6 @@ public struct ExploreView: View { HStack { ForEach(viewModel.searchViewButtonInfoArray.indices, id: \.self) { idx in - - // TODO: 버튼 정보 예: 맛 + 3 이런 식으로 처리하기 - // let info: OptionButtonInfo = exploreViewViewModel.optionButtonInfoArray[idx] let info = viewModel.searchViewButtonInfoArray[idx] Button(action: {