콘텐츠 상세페이지 이동 방식 수정

- NavigationView 적용
- 뒤로가기 시 리스트를 다시 로딩하여 스크롤이 최상단으로 이동하지 않도록 수정
This commit is contained in:
Yu Sung 2023-11-22 23:07:10 +09:00
parent 823bd8e92d
commit ebfecb0ad4
7 changed files with 515 additions and 499 deletions

View File

@ -15,40 +15,43 @@ struct ContentNewAllItemView: View {
@State var width: CGFloat = 0 @State var width: CGFloat = 0
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 8) { NavigationLink {
KFImage(URL(string: item.coverImageUrl)) ContentDetailView(contentId: item.contentId)
.resizable() } label: {
.scaledToFill() VStack(alignment: .leading, spacing: 8) {
.frame(width: width, height: width, alignment: .top) KFImage(URL(string: item.coverImageUrl))
.cornerRadius(2.7)
Text(item.title)
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "d2d2d2"))
.frame(width: width, alignment: .leading)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.lineLimit(2)
HStack(spacing: 5.3) {
KFImage(URL(string: item.creatorProfileImageUrl))
.resizable() .resizable()
.scaledToFill() .scaledToFill()
.frame(width: 21.3, height: 21.3) .frame(width: width, height: width, alignment: .top)
.clipShape(Circle()) .cornerRadius(2.7)
.onTapGesture { AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId)) }
Text(item.creatorNickname) Text(item.title)
.font(.custom(Font.medium.rawValue, size: 12)) .font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777")) .foregroundColor(Color(hex: "d2d2d2"))
.lineLimit(1) .frame(width: width, alignment: .leading)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.lineLimit(2)
HStack(spacing: 5.3) {
KFImage(URL(string: item.creatorProfileImageUrl))
.resizable()
.scaledToFill()
.frame(width: 21.3, height: 21.3)
.clipShape(Circle())
.onTapGesture { AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId)) }
Text(item.creatorNickname)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "777777"))
.lineLimit(1)
}
.padding(.bottom, 10)
}
.frame(width: width)
.onAppear {
width = (screenSize().width - 40) / 2
} }
.padding(.bottom, 10)
}
.frame(width: width)
.onTapGesture { AppState.shared.setAppStep(step: .contentDetail(contentId: item.contentId)) }
.onAppear {
width = (screenSize().width - 40) / 2
} }
} }
} }

View File

@ -17,63 +17,65 @@ struct ContentNewAllView: View {
] ]
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { NavigationView {
VStack(spacing: 0) { BaseView(isLoading: $viewModel.isLoading) {
DetailNavigationBar(title: "새로운 콘텐츠") VStack(spacing: 0) {
DetailNavigationBar(title: "새로운 콘텐츠")
Text("※ 최근 2주간 등록된 새로운 콘텐츠 입니다.")
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "bbbbbb"))
.padding(.horizontal, 13.3)
.padding(.vertical, 8)
.frame(width: screenSize().width, alignment: .leading)
.background(Color(hex: "222222"))
.padding(.top, 13.3)
ContentMainNewContentThemeView(
themes: viewModel.themeList,
selectTheme: {
viewModel.selectedTheme = $0
},
selectedTheme: $viewModel.selectedTheme
).padding(.top, 13.3)
HStack(spacing: 0) {
Text("전체")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
Text("\(viewModel.totalCount)") Text("※ 최근 2주간 등록된 새로운 콘텐츠 입니다.")
.font(.custom(Font.medium.rawValue, size: 13.3)) .font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "ff5c49")) .foregroundColor(Color(hex: "bbbbbb"))
.padding(.leading, 8) .padding(.horizontal, 13.3)
.padding(.vertical, 8)
.frame(width: screenSize().width, alignment: .leading)
.background(Color(hex: "222222"))
.padding(.top, 13.3)
Text("") ContentMainNewContentThemeView(
.font(.custom(Font.medium.rawValue, size: 13.3)) themes: viewModel.themeList,
.foregroundColor(Color(hex: "e2e2e2")) selectTheme: {
.padding(.leading, 2) viewModel.selectedTheme = $0
},
selectedTheme: $viewModel.selectedTheme
).padding(.top, 13.3)
Spacer() HStack(spacing: 0) {
} Text("전체")
.padding(.vertical, 13.3) .font(.custom(Font.medium.rawValue, size: 13.3))
.padding(.horizontal, 20) .foregroundColor(Color(hex: "e2e2e2"))
ScrollView(.vertical, showsIndicators: false) { Text("\(viewModel.totalCount)")
LazyVGrid(columns: columns, spacing: 13.3) { .font(.custom(Font.medium.rawValue, size: 13.3))
ForEach(0..<viewModel.newContentList.count, id: \.self) { index in .foregroundColor(Color(hex: "ff5c49"))
ContentNewAllItemView(item: viewModel.newContentList[index]) .padding(.leading, 8)
.onAppear {
if index == viewModel.newContentList.count - 1 { Text("")
viewModel.getNewContentList() .font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.leading, 2)
Spacer()
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
ScrollView(.vertical, showsIndicators: false) {
LazyVGrid(columns: columns, spacing: 13.3) {
ForEach(0..<viewModel.newContentList.count, id: \.self) { index in
ContentNewAllItemView(item: viewModel.newContentList[index])
.onAppear {
if index == viewModel.newContentList.count - 1 {
viewModel.getNewContentList()
}
} }
} }
} }
} }
} }
} .onAppear {
.onAppear { viewModel.getThemeList()
viewModel.getThemeList() viewModel.getNewContentList()
viewModel.getNewContentList() }
} }
} }
} }

View File

@ -13,144 +13,145 @@ struct ContentRankingAllView: View {
@StateObject var viewModel = ContentRankingAllViewModel() @StateObject var viewModel = ContentRankingAllViewModel()
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { NavigationView {
VStack(spacing: 0) { BaseView(isLoading: $viewModel.isLoading) {
DetailNavigationBar(title: "인기 콘텐츠") VStack(spacing: 0) {
DetailNavigationBar(title: "인기 콘텐츠")
VStack(spacing: 8) {
Text("\(viewModel.dateString)")
.font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
Text("※ 인기 콘텐츠의 순위는 매주 업데이트됩니다.") VStack(spacing: 8) {
.font(.custom(Font.light.rawValue, size: 13.3)) Text("\(viewModel.dateString)")
.foregroundColor(Color(hex: "bbbbbb")) .font(.custom(Font.bold.rawValue, size: 14.7))
} .foregroundColor(Color(hex: "eeeeee"))
.padding(.vertical, 8)
.frame(width: screenSize().width - 26.7) Text("※ 인기 콘텐츠의 순위는 매주 업데이트됩니다.")
.background(Color(hex: "222222")) .font(.custom(Font.light.rawValue, size: 13.3))
.padding(.top, 13.3) .foregroundColor(Color(hex: "bbbbbb"))
}
ContentMainRankingSortView( .padding(.vertical, 8)
sorts: viewModel.contentRankingSortList, .frame(width: screenSize().width - 26.7)
selectSort: { viewModel.selectedContentRankingSort = $0 }, .background(Color(hex: "222222"))
selectedSort: $viewModel.selectedContentRankingSort .padding(.top, 13.3)
)
.frame(width: screenSize().width - 26.7) ContentMainRankingSortView(
.padding(.vertical, 16.7) sorts: viewModel.contentRankingSortList,
selectSort: { viewModel.selectedContentRankingSort = $0 },
ScrollView(.vertical, showsIndicators: false) { selectedSort: $viewModel.selectedContentRankingSort
LazyVStack(spacing: 20) { )
ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in .frame(width: screenSize().width - 26.7)
let item = viewModel.contentRankingItemList[index] .padding(.vertical, 16.7)
HStack(spacing: 0) {
KFImage(URL(string: item.coverImageUrl)) ScrollView(.vertical, showsIndicators: false) {
.resizable() LazyVStack(spacing: 20) {
.scaledToFill() ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in
.frame(width: 66.7, height: 66.7, alignment: .top) let item = viewModel.contentRankingItemList[index]
.clipped() NavigationLink {
.cornerRadius(5.3) ContentDetailView(contentId: item.contentId)
} label: {
Text("\(index + 1)") HStack(spacing: 0) {
.font(.custom(Font.bold.rawValue, size: 16.7)) KFImage(URL(string: item.coverImageUrl))
.foregroundColor(Color(hex: "3bb9f1"))
.padding(.horizontal, 12)
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 8) {
Text(item.themeStr)
.font(.custom(Font.medium.rawValue, size: 8))
.foregroundColor(Color(hex: "3bac6a"))
.padding(2.6)
.background(Color(hex: "28312b"))
.cornerRadius(2.6)
Text(item.duration)
.font(.custom(Font.medium.rawValue, size: 8))
.foregroundColor(Color(hex: "777777"))
.padding(2.6)
.background(Color(hex: "222222"))
.cornerRadius(2.6)
}
Text(item.creatorNickname)
.font(.custom(Font.medium.rawValue, size: 10.7))
.foregroundColor(Color(hex: "777777"))
.padding(.vertical, 8)
Text(item.title)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "d2d2d2"))
.lineLimit(2)
.padding(.top, 2.7)
}
Spacer()
if item.price > 0 {
HStack(spacing: 8) {
Image("ic_can")
.resizable() .resizable()
.frame(width: 17, height: 17) .scaledToFill()
.frame(width: 66.7, height: 66.7, alignment: .top)
.clipped()
.cornerRadius(5.3)
Text("\(item.price)") Text("\(index + 1)")
.font(.custom(Font.medium.rawValue, size: 12)) .font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "909090")) .foregroundColor(Color(hex: "3bb9f1"))
.padding(.horizontal, 12)
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 8) {
Text(item.themeStr)
.font(.custom(Font.medium.rawValue, size: 8))
.foregroundColor(Color(hex: "3bac6a"))
.padding(2.6)
.background(Color(hex: "28312b"))
.cornerRadius(2.6)
Text(item.duration)
.font(.custom(Font.medium.rawValue, size: 8))
.foregroundColor(Color(hex: "777777"))
.padding(2.6)
.background(Color(hex: "222222"))
.cornerRadius(2.6)
}
Text(item.creatorNickname)
.font(.custom(Font.medium.rawValue, size: 10.7))
.foregroundColor(Color(hex: "777777"))
.padding(.vertical, 8)
Text(item.title)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "d2d2d2"))
.lineLimit(2)
.padding(.top, 2.7)
}
Spacer()
if item.price > 0 {
HStack(spacing: 8) {
Image("ic_can")
.resizable()
.frame(width: 17, height: 17)
Text("\(item.price)")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "909090"))
}
} else {
Text("무료")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "ffffff"))
.padding(.horizontal, 5.3)
.padding(.vertical, 2.7)
.background(Color(hex: "cf5c37"))
.cornerRadius(2.6)
}
}
.frame(height: 66.7)
.contentShape(Rectangle())
.onAppear {
if index == viewModel.contentRankingItemList.count - 1 {
viewModel.getContentRanking()
}
} }
} else {
Text("무료")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "ffffff"))
.padding(.horizontal, 5.3)
.padding(.vertical, 2.7)
.background(Color(hex: "cf5c37"))
.cornerRadius(2.6)
}
}
.frame(height: 66.7)
.contentShape(Rectangle())
.onTapGesture {
AppState
.shared
.setAppStep(step: .contentDetail(contentId: item.contentId))
}
.onAppear {
if index == viewModel.contentRankingItemList.count - 1 {
viewModel.getContentRanking()
} }
} }
} }
} }
.padding(13.3)
} }
.padding(13.3)
} if viewModel.isLoading {
LoadingView()
if viewModel.isLoading {
LoadingView()
}
}
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
GeometryReader { geo in
HStack {
Spacer()
Text(viewModel.errorMessage)
.padding(.vertical, 13.3)
.padding(.horizontal, 6.7)
.frame(width: geo.size.width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color(hex: "9970ff"))
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(20)
.padding(.top, 66.7)
Spacer()
} }
} }
} .popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
.onAppear { GeometryReader { geo in
viewModel.getContentRankingSortType() HStack {
viewModel.getContentRanking() Spacer()
Text(viewModel.errorMessage)
.padding(.vertical, 13.3)
.padding(.horizontal, 6.7)
.frame(width: geo.size.width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color(hex: "9970ff"))
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(20)
.padding(.top, 66.7)
Spacer()
}
}
}
.onAppear {
viewModel.getContentRankingSortType()
viewModel.getContentRanking()
}
} }
} }
} }

View File

@ -13,148 +13,147 @@ struct ContentListView: View {
@StateObject var viewModel = ContentListViewModel() @StateObject var viewModel = ContentListViewModel()
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { NavigationView {
VStack(spacing: 0) { BaseView(isLoading: $viewModel.isLoading) {
HStack(spacing: 0) { VStack(spacing: 0) {
Button { HStack(spacing: 0) {
AppState.shared.back() Button {
} label: { AppState.shared.back()
Image("ic_back") } label: {
.resizable() Image("ic_back")
.frame(width: 20, height: 20) .resizable()
.frame(width: 20, height: 20)
Text("콘텐츠 전체보기")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "eeeeee"))
}
Spacer()
}
.padding(.horizontal, 13.3)
.frame(height: 50)
.background(Color.black)
if userId == UserDefaults.int(forKey: .userId) {
Text("새로운 콘텐츠 등록하기")
.font(.custom(Font.bold.rawValue, size: 15))
.foregroundColor(Color(hex: "eeeeee"))
.padding(.vertical, 17)
.frame(maxWidth: .infinity)
.background(Color(hex: "9970ff"))
.cornerRadius(5.3)
.padding(.top, 13.3)
.padding(.horizontal, 13.3)
.onTapGesture { AppState.shared.setAppStep(step: .createContent) }
}
HStack(spacing: 13.3) {
Spacer()
Text("최신순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .NEWEST ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .NEWEST {
viewModel.sort = .NEWEST
}
}
Text("높은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_HIGH ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_HIGH {
viewModel.sort = .PRICE_HIGH
}
}
Text("낮은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_LOW ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_LOW {
viewModel.sort = .PRICE_LOW
}
}
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
.background(Color(hex: "161616"))
.padding(.top, 13.3)
HStack(spacing: 0) {
Text("전체")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ff5c49"))
.padding(.leading, 8)
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.leading, 2)
Spacer()
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
ScrollViewReader { reader in
ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 10.7) {
ScrollerToTop(reader: reader, scrollOnChange: $viewModel.scrollToTop)
ForEach(0..<viewModel.audioContentList.count, id: \.self) { index in Text("콘텐츠 전체보기")
let audioContent = viewModel.audioContentList[index] .font(.custom(Font.bold.rawValue, size: 18.3))
ContentListItemView(item: audioContent) .foregroundColor(Color(hex: "eeeeee"))
.contentShape(Rectangle()) }
.onTapGesture {
AppState Spacer()
.shared }
.setAppStep( .padding(.horizontal, 13.3)
step: .contentDetail(contentId: audioContent.contentId) .frame(height: 50)
) .background(Color.black)
}
.onAppear { if userId == UserDefaults.int(forKey: .userId) {
if index == viewModel.audioContentList.count - 1 { Text("새로운 콘텐츠 등록하기")
viewModel.getAudioContentList() .font(.custom(Font.bold.rawValue, size: 15))
} .foregroundColor(Color(hex: "eeeeee"))
.padding(.vertical, 17)
.frame(maxWidth: .infinity)
.background(Color(hex: "9970ff"))
.cornerRadius(5.3)
.padding(.top, 13.3)
.padding(.horizontal, 13.3)
.onTapGesture { AppState.shared.setAppStep(step: .createContent) }
}
HStack(spacing: 13.3) {
Spacer()
Text("최신순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .NEWEST ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .NEWEST {
viewModel.sort = .NEWEST
}
}
Text("높은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_HIGH ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_HIGH {
viewModel.sort = .PRICE_HIGH
}
}
Text("낮은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_LOW ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_LOW {
viewModel.sort = .PRICE_LOW
}
}
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
.background(Color(hex: "161616"))
.padding(.top, 13.3)
HStack(spacing: 0) {
Text("전체")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ff5c49"))
.padding(.leading, 8)
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.leading, 2)
Spacer()
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
ScrollViewReader { reader in
ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 10.7) {
ScrollerToTop(reader: reader, scrollOnChange: $viewModel.scrollToTop)
ForEach(0..<viewModel.audioContentList.count, id: \.self) { index in
let audioContent = viewModel.audioContentList[index]
NavigationLink {
ContentDetailView(contentId: audioContent.contentId)
} label: {
ContentListItemView(item: audioContent)
.contentShape(Rectangle())
.onAppear {
if index == viewModel.audioContentList.count - 1 {
viewModel.getAudioContentList()
}
}
} }
}
} }
} }
} }
.padding(.top, 13.3)
} }
.padding(.top, 13.3) .onAppear {
} viewModel.userId = userId
.onAppear { viewModel.getAudioContentList()
viewModel.userId = userId }
viewModel.getAudioContentList() .popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
} HStack {
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) { Spacer()
HStack { Text(viewModel.errorMessage)
Spacer() .padding(.vertical, 13.3)
Text(viewModel.errorMessage) .frame(width: screenSize().width - 66.7, alignment: .center)
.padding(.vertical, 13.3) .font(.custom(Font.medium.rawValue, size: 12))
.frame(width: screenSize().width - 66.7, alignment: .center) .background(Color(hex: "9970ff"))
.font(.custom(Font.medium.rawValue, size: 12)) .foregroundColor(Color.white)
.background(Color(hex: "9970ff")) .multilineTextAlignment(.leading)
.foregroundColor(Color.white) .cornerRadius(20)
.multilineTextAlignment(.leading) .padding(.bottom, 66.7)
.cornerRadius(20) Spacer()
.padding(.bottom, 66.7) }
Spacer()
} }
} }
} }

View File

@ -20,90 +20,92 @@ struct ContentCurationView: View {
] ]
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { NavigationView {
VStack(spacing: 0) { BaseView(isLoading: $viewModel.isLoading) {
DetailNavigationBar(title: title) VStack(spacing: 0) {
DetailNavigationBar(title: title)
HStack(spacing: 13.3) {
Spacer()
Text("최신순") HStack(spacing: 13.3) {
.font(.custom(Font.medium.rawValue, size: 13.3)) Spacer()
.foregroundColor(
Color(hex: "e2e2e2") Text("최신순")
.opacity(viewModel.sort == .NEWEST ? 1 : 0.5) .font(.custom(Font.medium.rawValue, size: 13.3))
) .foregroundColor(
.onTapGesture { Color(hex: "e2e2e2")
if viewModel.sort != .NEWEST { .opacity(viewModel.sort == .NEWEST ? 1 : 0.5)
viewModel.sort = .NEWEST )
} .onTapGesture {
} if viewModel.sort != .NEWEST {
viewModel.sort = .NEWEST
Text("높은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_HIGH ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_HIGH {
viewModel.sort = .PRICE_HIGH
}
}
Text("낮은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_LOW ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_LOW {
viewModel.sort = .PRICE_LOW
}
}
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
.background(Color(hex: "161616"))
.padding(.top, 13.3)
HStack(spacing: 0) {
Text("전체")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ff5c49"))
.padding(.leading, 8)
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.leading, 2)
Spacer()
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
ScrollView(.vertical, showsIndicators: false) {
LazyVGrid(columns: columns, spacing: 13.3) {
ForEach(0..<viewModel.contentList.count, id: \.self) { index in
ContentNewAllItemView(item: viewModel.contentList[index])
.onAppear {
if index == viewModel.contentList.count - 1 {
viewModel.getContentList()
}
} }
}
Text("높은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_HIGH ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_HIGH {
viewModel.sort = .PRICE_HIGH
}
}
Text("낮은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_LOW ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_LOW {
viewModel.sort = .PRICE_LOW
}
}
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
.background(Color(hex: "161616"))
.padding(.top, 13.3)
HStack(spacing: 0) {
Text("전체")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ff5c49"))
.padding(.leading, 8)
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.leading, 2)
Spacer()
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
ScrollView(.vertical, showsIndicators: false) {
LazyVGrid(columns: columns, spacing: 13.3) {
ForEach(0..<viewModel.contentList.count, id: \.self) { index in
ContentNewAllItemView(item: viewModel.contentList[index])
.onAppear {
if index == viewModel.contentList.count - 1 {
viewModel.getContentList()
}
}
}
} }
} }
} }
} .onAppear {
.onAppear { viewModel.curationId = curationId
viewModel.curationId = curationId viewModel.getContentList()
viewModel.getContentList() }
} }
} }
} }

View File

@ -12,6 +12,8 @@ import RefreshableScrollView
struct ContentDetailView: View { struct ContentDetailView: View {
let contentId: Int let contentId: Int
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
@StateObject private var viewModel = ContentDetailViewModel() @StateObject private var viewModel = ContentDetailViewModel()
@State private var isShowOrderView = false @State private var isShowOrderView = false
@ -24,7 +26,11 @@ struct ContentDetailView: View {
VStack(spacing: 0) { VStack(spacing: 0) {
HStack(spacing: 0) { HStack(spacing: 0) {
Button { Button {
AppState.shared.back() if presentationMode.wrappedValue.isPresented {
presentationMode.wrappedValue.dismiss()
} else {
AppState.shared.back()
}
} label: { } label: {
Image("ic_back") Image("ic_back")
.resizable() .resizable()
@ -151,6 +157,8 @@ struct ContentDetailView: View {
Spacer() Spacer()
} }
.navigationTitle("")
.navigationBarBackButtonHidden()
.onAppear { .onAppear {
viewModel.contentId = contentId viewModel.contentId = contentId
AppState.shared.pushAudioContentId = 0 AppState.shared.pushAudioContentId = 0

View File

@ -12,88 +12,89 @@ struct OrderListAllView: View {
@StateObject var viewModel = OrderListAllViewModel() @StateObject var viewModel = OrderListAllViewModel()
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { NavigationView {
VStack(spacing: 0) { BaseView(isLoading: $viewModel.isLoading) {
HStack(spacing: 0) { VStack(spacing: 0) {
Button { HStack(spacing: 0) {
AppState.shared.back() Button {
} label: { AppState.shared.back()
Image("ic_back") } label: {
.resizable() Image("ic_back")
.frame(width: 20, height: 20) .resizable()
.frame(width: 20, height: 20)
Text("구매목록")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "eeeeee"))
}
Spacer()
}
.padding(.horizontal, 13.3)
.frame(height: 50)
.background(Color.black)
HStack(spacing: 0) {
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "dd4500"))
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
Spacer()
}
.padding(.horizontal, 13.3)
.padding(.top, 13.3)
ScrollViewReader { reader in
ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 10.7) {
ScrollerToTop(reader: reader, scrollOnChange: $viewModel.scrollToTop)
ForEach(0..<viewModel.orderList.count, id: \.self) { index in Text("구매목록")
let item = viewModel.orderList[index] .font(.custom(Font.bold.rawValue, size: 18.3))
OrderListItemView(item: item) .foregroundColor(Color(hex: "eeeeee"))
.contentShape(Rectangle()) }
.onTapGesture {
AppState Spacer()
.shared }
.setAppStep(step: .contentDetail(contentId: item.contentId)) .padding(.horizontal, 13.3)
} .frame(height: 50)
.padding(.horizontal, 13.3) .background(Color.black)
.padding(.top, 6.7)
.onAppear { HStack(spacing: 0) {
if index == viewModel.orderList.count - 1 { Text("")
viewModel.getOrderList() .font(.custom(Font.medium.rawValue, size: 13.3))
} .foregroundColor(Color(hex: "eeeeee"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "dd4500"))
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
Spacer()
}
.padding(.horizontal, 13.3)
.padding(.top, 13.3)
ScrollViewReader { reader in
ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 10.7) {
ScrollerToTop(reader: reader, scrollOnChange: $viewModel.scrollToTop)
ForEach(0..<viewModel.orderList.count, id: \.self) { index in
let item = viewModel.orderList[index]
NavigationLink {
ContentDetailView(contentId: item.contentId)
} label: {
OrderListItemView(item: item)
.contentShape(Rectangle())
.padding(.horizontal, 13.3)
.padding(.top, 6.7)
.onAppear {
if index == viewModel.orderList.count - 1 {
viewModel.getOrderList()
}
}
} }
}
} }
} }
} }
.padding(.top, 13.3)
} }
.padding(.top, 13.3) .onAppear {
} viewModel.getOrderList()
.onAppear { }
viewModel.getOrderList() .popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
} HStack {
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) { Spacer()
HStack { Text(viewModel.errorMessage)
Spacer() .padding(.vertical, 13.3)
Text(viewModel.errorMessage) .frame(width: screenSize().width - 66.7, alignment: .center)
.padding(.vertical, 13.3) .font(.custom(Font.medium.rawValue, size: 12))
.frame(width: screenSize().width - 66.7, alignment: .center) .background(Color(hex: "9970ff"))
.font(.custom(Font.medium.rawValue, size: 12)) .foregroundColor(Color.white)
.background(Color(hex: "9970ff")) .multilineTextAlignment(.leading)
.foregroundColor(Color.white) .cornerRadius(20)
.multilineTextAlignment(.leading) .padding(.bottom, 66.7)
.cornerRadius(20) Spacer()
.padding(.bottom, 66.7) }
Spacer()
} }
} }
} }