Skip to content

Commit

Permalink
Merge pull request #290 from DeveloperAcademy-POSTECH/exploreCuration…
Browse files Browse the repository at this point in the history
…View/newUI

[Feat] ExploreCurationView 바뀐 UI 적용
  • Loading branch information
otoolz authored Nov 23, 2022
2 parents 2075a27 + 8ff7a38 commit 68dbd38
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ShortcutsZipViewModel: ObservableObject {

@Published var curationsMadeByUser: [Curation] = [] // 유저가 만든 큐레이션배열
@Published var userCurations: [Curation] = []
@Published var personalCurations: [Curation] = [] // "땡땡님을 위한 모음집" 큐레이션배열
@Published var adminCurations: [Curation] = []

@Published var allComments: [Comments] = []
Expand Down
18 changes: 14 additions & 4 deletions HappyAnding/HappyAnding/Views/Components/CurationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

struct CurationListView: View {

@EnvironmentObject var shortcutsZipViewModel: ShortcutsZipViewModel
@State var data: NavigationListCurationType
@Binding var userCurations: [Curation]

Expand Down Expand Up @@ -41,17 +42,26 @@ struct CurationListView: View {
}

struct CurationListHeader: View {

@EnvironmentObject var shortcutsZipViewModel: ShortcutsZipViewModel
@Binding var userCurations: [Curation]

@State var data: NavigationListCurationType
let navigationParentView: NavigationParentView

var body: some View {
HStack(alignment: .bottom) {
Text(data.title ?? "")
.Title2()
.foregroundColor(.Gray5)
.onTapGesture { }
if data.type == .personalCuration {
Text("\(shortcutsZipViewModel.userInfo?.nickname ?? "")\(data.type.rawValue)")
.Title2()
.foregroundColor(.Gray5)
.onTapGesture { }
} else {
Text(data.title ?? "")
.Title2()
.foregroundColor(.Gray5)
.onTapGesture { }
}
Spacer()

NavigationLink(value: data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ struct ExploreCurationView: View {
.padding(.top, 20)
.padding(.bottom, 32)

//나의 큐레이션
UserCurationListView(data: NavigationListCurationType(type: .myCuration,
title: "내가 작성한 큐레이션",
isAllUser: false,
navigationParentView: .curations),
userCurations: $shortcutsZipViewModel.curationsMadeByUser)
.padding(.bottom, 20)
//땡땡니을 위한 모음집
CurationListView(data: NavigationListCurationType(type: .personalCuration,
title: "",
isAllUser: false,
navigationParentView: .curations),
userCurations: $shortcutsZipViewModel.personalCurations)
.onAppear {
shortcutsZipViewModel.personalCurations.removeAll()
let personalCurationIDs = Set(shortcutsZipViewModel.shortcutsUserDownloaded.flatMap({ $0.curationIDs }))
for curationID in personalCurationIDs {
if let curation = shortcutsZipViewModel.userCurations.first(where: { $0.id == curationID }) {
shortcutsZipViewModel.personalCurations.append(curation)
}
}
}
.padding(.bottom, 32)

//추천 유저 큐레이션
CurationListView(data: NavigationListCurationType(type: .userCuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI
enum CurationType: String {
case myCuration = "내가 작성한 큐레이션"
case userCuration = "큐레이션 모아보기"
case personalCuration = "님을 위한 모음집"
}

/**
Expand Down Expand Up @@ -72,6 +73,15 @@ struct ListCurationView: View {
.navigationBarTitleDisplayMode(.inline)

}
.scrollIndicators(.hidden)
.navigationDestination(for: NavigationReadUserCurationType.self) { data in
ReadUserCurationView(data: data)
}
.listStyle(.plain)
.background(Color.Background.ignoresSafeArea(.all, edges: .all))
.scrollContentBackground(.hidden)
.navigationBarTitle("\(shortcutsZipViewModel.userInfo?.nickname ?? "")\(self.data.type.rawValue)")
.navigationBarTitleDisplayMode(.inline)
}
}

Expand Down

0 comments on commit 68dbd38

Please sign in to comment.