From 174416952e21afc0291d73cdeef06b73aea43e1f Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Sat, 22 Feb 2025 10:23:00 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=AC=B4=EB=A3=8C=20=ED=83=AD=20-=20=ED=81=AC?= =?UTF-8?q?=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0=20=EC=86=8C=EA=B0=9C=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=EB=B3=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppStep.swift | 2 + .../ContentMainIntroduceCreatorAllView.swift | 67 +++++++++++++++++ ...tentMainIntroduceCreatorAllViewModel.swift | 74 +++++++++++++++++++ .../Main/V2/Free/ContentMainTabFreeView.swift | 5 +- SodaLive/Sources/ContentView.swift | 3 + 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 SodaLive/Sources/Content/Main/V2/Free/All/ContentMainIntroduceCreatorAllView.swift create mode 100644 SodaLive/Sources/Content/Main/V2/Free/All/ContentMainIntroduceCreatorAllViewModel.swift diff --git a/SodaLive/Sources/App/AppStep.swift b/SodaLive/Sources/App/AppStep.swift index c355d28..2e01e29 100644 --- a/SodaLive/Sources/App/AppStep.swift +++ b/SodaLive/Sources/App/AppStep.swift @@ -151,4 +151,6 @@ enum AppStep { case newAsmrContentAll case newReplayContentAll + + case introduceCreatorAll } diff --git a/SodaLive/Sources/Content/Main/V2/Free/All/ContentMainIntroduceCreatorAllView.swift b/SodaLive/Sources/Content/Main/V2/Free/All/ContentMainIntroduceCreatorAllView.swift new file mode 100644 index 0000000..56b895f --- /dev/null +++ b/SodaLive/Sources/Content/Main/V2/Free/All/ContentMainIntroduceCreatorAllView.swift @@ -0,0 +1,67 @@ +// +// ContentMainIntroduceCreatorAllView.swift +// SodaLive +// +// Created by klaus on 2/22/25. +// + +import SwiftUI + +struct ContentMainIntroduceCreatorAllView: View { + + @StateObject var viewModel = ContentMainIntroduceCreatorAllViewModel() + + let columns = [ + GridItem(.flexible()), + GridItem(.flexible()), + GridItem(.flexible()) + ] + + var body: some View { + NavigationView { + BaseView(isLoading: $viewModel.isLoading) { + VStack(spacing: 13.3) { + DetailNavigationBar(title: "크리에이터 소개") + + ScrollView(.vertical, showsIndicators: false) { + LazyVGrid(columns: columns, spacing: 13.3) { + ForEach(0..() + + @Published var errorMessage = "" + @Published var isShowPopup = false + @Published var isLoading = false + + @Published var introduceCreatorList: [GetAudioContentMainItem] = [] + + var page = 1 + var isLast = false + private let size = 20 + + func getIntroduceCreatorList() { + if (!isLast && !isLoading) { + isLoading = true + repository.getIntroduceCreatorList(page: page, size: size) + .sink { result in + switch result { + case .finished: + DEBUG_LOG("finish") + case .failure(let error): + ERROR_LOG(error.localizedDescription) + } + } receiveValue: { [unowned self] response in + self.isLoading = false + let responseData = response.data + + do { + let jsonDecoder = JSONDecoder() + let decoded = try jsonDecoder.decode(ApiResponse<[GetAudioContentMainItem]>.self, from: responseData) + self.isLoading = false + + if let data = decoded.data, decoded.success { + if page == 1 { + introduceCreatorList.removeAll() + } + + if !data.isEmpty { + page += 1 + self.introduceCreatorList.append(contentsOf: data) + } else { + isLast = true + } + } else { + if let message = decoded.message { + self.errorMessage = message + } else { + self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + } + + self.isShowPopup = true + } + } catch { + self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + self.isShowPopup = true + self.isLoading = false + } + } + .store(in: &subscription) + } + } +} diff --git a/SodaLive/Sources/Content/Main/V2/Free/ContentMainTabFreeView.swift b/SodaLive/Sources/Content/Main/V2/Free/ContentMainTabFreeView.swift index 249a63c..9c6634f 100644 --- a/SodaLive/Sources/Content/Main/V2/Free/ContentMainTabFreeView.swift +++ b/SodaLive/Sources/Content/Main/V2/Free/ContentMainTabFreeView.swift @@ -23,7 +23,10 @@ struct ContentMainTabFreeView: View { if let introduceCreator = viewModel.introduceCreator { ContentMainNewContentViewV2( title: introduceCreator.title, - onClickMore: {}, + onClickMore: { + AppState.shared + .setAppStep(step: .introduceCreatorAll) + }, themeList: [], contentList: introduceCreator.items ) { _ in } diff --git a/SodaLive/Sources/ContentView.swift b/SodaLive/Sources/ContentView.swift index 2eee431..a7d8fc1 100644 --- a/SodaLive/Sources/ContentView.swift +++ b/SodaLive/Sources/ContentView.swift @@ -230,6 +230,9 @@ struct ContentView: View { case .newReplayContentAll: ContentMainReplayAllView() + case .introduceCreatorAll: + ContentMainIntroduceCreatorAllView() + default: EmptyView() .frame(width: 0, height: 0, alignment: .topLeading)