Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto Dev
  • Loading branch information
Roy-wonji committed Nov 4, 2023
2 parents c18c329 + 91c9fc9 commit 3168c0e
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 91 deletions.
175 changes: 94 additions & 81 deletions PingPong/Projects/Feature/Archive/Sources/UI/View/ArchiveView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -133,16 +121,51 @@ 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) {
HomeBakingView(viewModel: viewModel, appState: appState, backAction: {
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{
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ 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

public var body: some View {
ZStack {
ScrollView(.vertical){
// let (group, situationInfo, flavorCountInfo, sourceCountInfo) = filterHomePostContents()

searchBar()
.padding(.top, 62)

Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 3168c0e

Please sign in to comment.