From b7054320f19e3c21c27f47e0f70db01cb7fad828 Mon Sep 17 00:00:00 2001 From: Byeonjinha Date: Sun, 5 Nov 2023 00:32:58 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=AA=9B[chore]=20:=20=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EB=B6=84=EB=A6=AC=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Archive/Sources/UI/View/ArchiveView.swift | 149 ++++++++++-------- .../FamousSayingBakeCardView.swift | 8 +- 2 files changed, 83 insertions(+), 74 deletions(-) diff --git a/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift b/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift index 8994195e..00fea039 100644 --- a/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift +++ b/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift @@ -25,89 +25,79 @@ 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: posts.count) -// staticsView(count: homeViewViewModel.homeRandomQuoteModel?.data?.totalElements ?? .zero) - - if posts.count != 0 { + if !posts.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(posts) { 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 +123,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) { @@ -142,7 +132,26 @@ public struct ArchiveView: View { }) } } + @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{ diff --git a/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift b/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift index ab4ff3d9..e0e4ea66 100644 --- a/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift +++ b/PingPong/Projects/Feature/Bake/Sources/UI/HomeBakingView/FamousSayingBakeCardView.swift @@ -239,8 +239,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) @@ -252,8 +252,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) } From 91c9fc9d21ad2ff049b7ae23080e2e1762a3bbe9 Mon Sep 17 00:00:00 2001 From: Byeonjinha Date: Sun, 5 Nov 2023 01:14:18 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=AA=9B[chore]=20:=20=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EB=B6=84=EB=A6=AC=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Archive/Sources/UI/View/ArchiveView.swift | 34 +++++++++++-------- .../UI/ViewModel/ArchiveViewViewModel.swift | 11 ++++++ .../Search/Sources/UI/View/ExploreView.swift | 7 +--- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift b/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift index 00fea039..216b45d6 100644 --- a/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift +++ b/PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift @@ -34,14 +34,12 @@ public struct ArchiveView: View { VStack(){ archiveHeader() - - let posts = generateBookmarkPostContents() - staticsView(count: posts.count) + staticsView(count: archiveViewViewModel.bookmarkCards.count) - if !posts.isEmpty { + if !archiveViewViewModel.bookmarkCards.isEmpty { ScrollView(.vertical) { LazyVGrid(columns: columns) { - ForEach(posts) { card in + ForEach(archiveViewViewModel.bookmarkCards) { card in let colorSet = viewModel.createColorSet(flavor: card.hashtags.flavor) VStack { HStack { @@ -131,6 +129,22 @@ 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 { @@ -178,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/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: {