콘텐츠 상세페이지 이동 방식 수정
- NavigationView 적용 - 뒤로가기 시 리스트를 다시 로딩하여 스크롤이 최상단으로 이동하지 않도록 수정
This commit is contained in:
@@ -12,88 +12,89 @@ struct OrderListAllView: View {
|
||||
@StateObject var viewModel = OrderListAllViewModel()
|
||||
|
||||
var body: some View {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 0) {
|
||||
Button {
|
||||
AppState.shared.back()
|
||||
} label: {
|
||||
Image("ic_back")
|
||||
.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)
|
||||
NavigationView {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 0) {
|
||||
Button {
|
||||
AppState.shared.back()
|
||||
} label: {
|
||||
Image("ic_back")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
ForEach(0..<viewModel.orderList.count, id: \.self) { index in
|
||||
let item = viewModel.orderList[index]
|
||||
OrderListItemView(item: item)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
AppState
|
||||
.shared
|
||||
.setAppStep(step: .contentDetail(contentId: item.contentId))
|
||||
}
|
||||
.padding(.horizontal, 13.3)
|
||||
.padding(.top, 6.7)
|
||||
.onAppear {
|
||||
if index == viewModel.orderList.count - 1 {
|
||||
viewModel.getOrderList()
|
||||
}
|
||||
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
|
||||
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()
|
||||
}
|
||||
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
|
||||
HStack {
|
||||
Spacer()
|
||||
Text(viewModel.errorMessage)
|
||||
.padding(.vertical, 13.3)
|
||||
.frame(width: screenSize().width - 66.7, alignment: .center)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.background(Color(hex: "9970ff"))
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
.cornerRadius(20)
|
||||
.padding(.bottom, 66.7)
|
||||
Spacer()
|
||||
.onAppear {
|
||||
viewModel.getOrderList()
|
||||
}
|
||||
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
|
||||
HStack {
|
||||
Spacer()
|
||||
Text(viewModel.errorMessage)
|
||||
.padding(.vertical, 13.3)
|
||||
.frame(width: screenSize().width - 66.7, alignment: .center)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.background(Color(hex: "9970ff"))
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
.cornerRadius(20)
|
||||
.padding(.bottom, 66.7)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user