feat(creator): 후원 탭을 연결한다
This commit is contained in:
@@ -7,6 +7,7 @@ struct CreatorChannelView: View {
|
||||
|
||||
@StateObject private var viewModel = CreatorChannelViewModel()
|
||||
@StateObject private var channelDonationViewModel = ChannelDonationViewModel()
|
||||
@StateObject private var donationViewModel = CreatorChannelDonationViewModel()
|
||||
@StateObject private var liveViewModel = LiveViewModel()
|
||||
@StateObject private var mypageViewModel = MyPageViewModel()
|
||||
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
|
||||
@@ -113,6 +114,13 @@ struct CreatorChannelView: View {
|
||||
.ignoresSafeArea(.container, edges: .bottom)
|
||||
}
|
||||
|
||||
if viewModel.selectedTab == .donation && shouldShowDonationFloatingButton && !viewModel.isLoading {
|
||||
CreatorChannelDonationFloatingButton(action: showDonationDialog)
|
||||
.ignoresSafeArea(.container, edges: .bottom)
|
||||
.padding(.bottom, SodaSpacing.s14)
|
||||
.padding(.trailing, SodaSpacing.s14)
|
||||
}
|
||||
|
||||
if isShowAuthConfirmView {
|
||||
authConfirmDialog
|
||||
}
|
||||
@@ -133,6 +141,7 @@ struct CreatorChannelView: View {
|
||||
reloadAfterSuccess: false,
|
||||
onSuccess: {
|
||||
viewModel.fetchHome(creatorId: creatorId)
|
||||
donationViewModel.fetchFirstPage(creatorId: creatorId)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -207,6 +216,10 @@ struct CreatorChannelView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var shouldShowDonationFloatingButton: Bool {
|
||||
isOwnCreatorChannel == false && (donationViewModel.donationCount != 0 || donationViewModel.rankings.isEmpty == false)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var selectedTabContent: some View {
|
||||
if viewModel.selectedTab == .live {
|
||||
@@ -228,6 +241,14 @@ struct CreatorChannelView: View {
|
||||
isOwnCreatorChannel: isOwnCreatorChannel,
|
||||
onTapSeries: showSeriesDetail
|
||||
)
|
||||
} else if viewModel.selectedTab == .donation {
|
||||
CreatorChannelDonationTabView(
|
||||
creatorId: creatorId,
|
||||
isOwnCreatorChannel: isOwnCreatorChannel,
|
||||
viewModel: donationViewModel,
|
||||
onTapViewAll: showDonationRankingAll,
|
||||
onTapDonate: showDonationDialog
|
||||
)
|
||||
} else if viewModel.selectedTab != .home {
|
||||
CreatorChannelPlaceholderTabView(title: viewModel.selectedTab.title)
|
||||
} else if let response = viewModel.response {
|
||||
@@ -337,6 +358,10 @@ struct CreatorChannelView: View {
|
||||
AppState.shared.setAppStep(step: .seriesDetail(seriesId: seriesId))
|
||||
}
|
||||
|
||||
private func showDonationRankingAll() {
|
||||
AppState.shared.setAppStep(step: .userProfileDonationAll(userId: creatorId))
|
||||
}
|
||||
|
||||
private func showCommunity(_ creatorId: Int) {
|
||||
guard creatorId > 0 else { return }
|
||||
AppState.shared.setAppStep(step: .creatorCommunityAll(creatorId: creatorId))
|
||||
|
||||
Reference in New Issue
Block a user