콘텐츠 상세페이지 이동 방식 수정
- NavigationView 적용 - 뒤로가기 시 리스트를 다시 로딩하여 스크롤이 최상단으로 이동하지 않도록 수정
This commit is contained in:
		| @@ -15,6 +15,9 @@ struct ContentNewAllItemView: View { | ||||
|     @State var width: CGFloat = 0 | ||||
|      | ||||
|     var body: some View { | ||||
|         NavigationLink { | ||||
|             ContentDetailView(contentId: item.contentId) | ||||
|         } label: { | ||||
|             VStack(alignment: .leading, spacing: 8) { | ||||
|                 KFImage(URL(string: item.coverImageUrl)) | ||||
|                     .resizable() | ||||
| @@ -46,9 +49,9 @@ struct ContentNewAllItemView: View { | ||||
|                 .padding(.bottom, 10) | ||||
|             } | ||||
|             .frame(width: width) | ||||
|         .onTapGesture { AppState.shared.setAppStep(step: .contentDetail(contentId: item.contentId)) } | ||||
|             .onAppear { | ||||
|                 width = (screenSize().width - 40) / 2 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -17,6 +17,7 @@ struct ContentNewAllView: View { | ||||
|     ] | ||||
|      | ||||
|     var body: some View { | ||||
|         NavigationView { | ||||
|             BaseView(isLoading: $viewModel.isLoading) { | ||||
|                 VStack(spacing: 0) { | ||||
|                     DetailNavigationBar(title: "새로운 콘텐츠") | ||||
| @@ -78,6 +79,7 @@ struct ContentNewAllView: View { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| struct ContentNewAllView_Previews: PreviewProvider { | ||||
|     static var previews: some View { | ||||
|   | ||||
| @@ -13,6 +13,7 @@ struct ContentRankingAllView: View { | ||||
|     @StateObject var viewModel = ContentRankingAllViewModel() | ||||
|      | ||||
|     var body: some View { | ||||
|         NavigationView { | ||||
|             BaseView(isLoading: $viewModel.isLoading) { | ||||
|                 VStack(spacing: 0) { | ||||
|                     DetailNavigationBar(title: "인기 콘텐츠") | ||||
| @@ -43,6 +44,9 @@ struct ContentRankingAllView: View { | ||||
|                         LazyVStack(spacing: 20) { | ||||
|                             ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in | ||||
|                                 let item = viewModel.contentRankingItemList[index] | ||||
|                                 NavigationLink { | ||||
|                                     ContentDetailView(contentId: item.contentId) | ||||
|                                 } label: { | ||||
|                                     HStack(spacing: 0) { | ||||
|                                         KFImage(URL(string: item.coverImageUrl)) | ||||
|                                             .resizable() | ||||
| @@ -109,11 +113,6 @@ struct ContentRankingAllView: View { | ||||
|                                     } | ||||
|                                     .frame(height: 66.7) | ||||
|                                     .contentShape(Rectangle()) | ||||
|                             .onTapGesture { | ||||
|                                 AppState | ||||
|                                     .shared | ||||
|                                     .setAppStep(step: .contentDetail(contentId: item.contentId)) | ||||
|                             } | ||||
|                                     .onAppear { | ||||
|                                         if index == viewModel.contentRankingItemList.count - 1 { | ||||
|                                             viewModel.getContentRanking() | ||||
| @@ -122,6 +121,7 @@ struct ContentRankingAllView: View { | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     .padding(13.3) | ||||
|                 } | ||||
|                  | ||||
| @@ -154,6 +154,7 @@ struct ContentRankingAllView: View { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| struct ContentRankingAllView_Previews: PreviewProvider { | ||||
|     static var previews: some View { | ||||
|   | ||||
| @@ -13,6 +13,7 @@ struct ContentListView: View { | ||||
|     @StateObject var viewModel = ContentListViewModel() | ||||
|      | ||||
|     var body: some View { | ||||
|         NavigationView { | ||||
|             BaseView(isLoading: $viewModel.isLoading) { | ||||
|                 VStack(spacing: 0) { | ||||
|                     HStack(spacing: 0) { | ||||
| @@ -118,15 +119,11 @@ struct ContentListView: View { | ||||
|                                  | ||||
|                                 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()) | ||||
|                                     .onTapGesture { | ||||
|                                         AppState | ||||
|                                             .shared | ||||
|                                             .setAppStep( | ||||
|                                                 step: .contentDetail(contentId: audioContent.contentId) | ||||
|                                             ) | ||||
|                                     } | ||||
|                                             .onAppear { | ||||
|                                                 if index == viewModel.audioContentList.count - 1 { | ||||
|                                                     viewModel.getAudioContentList() | ||||
| @@ -136,6 +133,7 @@ struct ContentListView: View { | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     .padding(.top, 13.3) | ||||
|                 } | ||||
|                 .onAppear { | ||||
| @@ -160,6 +158,7 @@ struct ContentListView: View { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| struct ScrollerToTop: View { | ||||
|     let reader: ScrollViewProxy | ||||
|   | ||||
| @@ -20,6 +20,7 @@ struct ContentCurationView: View { | ||||
|     ] | ||||
|      | ||||
|     var body: some View { | ||||
|         NavigationView { | ||||
|             BaseView(isLoading: $viewModel.isLoading) { | ||||
|                 VStack(spacing: 0) { | ||||
|                     DetailNavigationBar(title: title) | ||||
| @@ -108,3 +109,4 @@ struct ContentCurationView: View { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,8 @@ import RefreshableScrollView | ||||
| struct ContentDetailView: View { | ||||
|      | ||||
|     let contentId: Int | ||||
|      | ||||
|     @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode> | ||||
|     @StateObject private var viewModel = ContentDetailViewModel() | ||||
|      | ||||
|     @State private var isShowOrderView = false | ||||
| @@ -24,7 +26,11 @@ struct ContentDetailView: View { | ||||
|                 VStack(spacing: 0) { | ||||
|                     HStack(spacing: 0) { | ||||
|                         Button { | ||||
|                             if presentationMode.wrappedValue.isPresented { | ||||
|                                 presentationMode.wrappedValue.dismiss() | ||||
|                             } else { | ||||
|                                 AppState.shared.back() | ||||
|                             } | ||||
|                         } label: { | ||||
|                             Image("ic_back") | ||||
|                                 .resizable() | ||||
| @@ -151,6 +157,8 @@ struct ContentDetailView: View { | ||||
|                      | ||||
|                     Spacer() | ||||
|                 } | ||||
|                 .navigationTitle("") | ||||
|                 .navigationBarBackButtonHidden() | ||||
|                 .onAppear { | ||||
|                     viewModel.contentId = contentId | ||||
|                     AppState.shared.pushAudioContentId = 0 | ||||
|   | ||||
| @@ -12,6 +12,7 @@ struct OrderListAllView: View { | ||||
|     @StateObject var viewModel = OrderListAllViewModel() | ||||
|      | ||||
|     var body: some View { | ||||
|         NavigationView { | ||||
|             BaseView(isLoading: $viewModel.isLoading) { | ||||
|                 VStack(spacing: 0) { | ||||
|                     HStack(spacing: 0) { | ||||
| @@ -58,13 +59,11 @@ struct OrderListAllView: View { | ||||
|                                  | ||||
|                                 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()) | ||||
|                                     .onTapGesture { | ||||
|                                         AppState | ||||
|                                             .shared | ||||
|                                             .setAppStep(step: .contentDetail(contentId: item.contentId)) | ||||
|                                     } | ||||
|                                             .padding(.horizontal, 13.3) | ||||
|                                             .padding(.top, 6.7) | ||||
|                                             .onAppear { | ||||
| @@ -76,6 +75,7 @@ struct OrderListAllView: View { | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     .padding(.top, 13.3) | ||||
|                 } | ||||
|                 .onAppear { | ||||
| @@ -99,3 +99,4 @@ struct OrderListAllView: View { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung