feat(creator): 채널 후원 섹션을 연결한다
This commit is contained in:
@@ -4,8 +4,10 @@ struct CreatorChannelView: View {
|
||||
let creatorId: Int
|
||||
|
||||
@StateObject private var viewModel = CreatorChannelViewModel()
|
||||
@StateObject private var channelDonationViewModel = ChannelDonationViewModel()
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var tabBarMinY: CGFloat = .greatestFiniteMagnitude
|
||||
@State private var isShowChannelDonationDialog = false
|
||||
|
||||
private let titleBarHeight: CGFloat = 56
|
||||
private let tabBarHeight: CGFloat = 52
|
||||
@@ -65,6 +67,28 @@ struct CreatorChannelView: View {
|
||||
if viewModel.isLoading {
|
||||
LoadingView()
|
||||
}
|
||||
|
||||
if isShowChannelDonationDialog {
|
||||
LiveRoomDonationDialogView(
|
||||
isShowing: $isShowChannelDonationDialog,
|
||||
isAudioContentDonation: false,
|
||||
messageLimit: 100,
|
||||
secretLabel: I18n.MemberChannel.secretDonationLabel,
|
||||
secretMinimumCanMessage: I18n.MemberChannel.secretDonationMinimumCanMessage,
|
||||
shouldPrefixSecretInMessagePlaceholder: false,
|
||||
onClickDonation: { can, message, isSecret in
|
||||
channelDonationViewModel.postChannelDonation(
|
||||
can: can,
|
||||
message: message,
|
||||
isSecret: isSecret,
|
||||
reloadAfterSuccess: false,
|
||||
onSuccess: {
|
||||
viewModel.fetchHome(creatorId: creatorId)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarBackButtonHidden(true)
|
||||
@@ -74,6 +98,7 @@ struct CreatorChannelView: View {
|
||||
}
|
||||
}
|
||||
.sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 1)
|
||||
.sodaToast(isPresented: $channelDonationViewModel.isShowPopup, message: channelDonationViewModel.errorMessage, autohideIn: 2)
|
||||
}
|
||||
|
||||
private func titleBar(backgroundProgress: CGFloat) -> some View {
|
||||
@@ -131,7 +156,8 @@ struct CreatorChannelView: View {
|
||||
CreatorChannelHomeView(
|
||||
response: response,
|
||||
onSelectTab: selectTab,
|
||||
onTapContent: showContentDetail
|
||||
onTapContent: showContentDetail,
|
||||
onTapDonate: showDonationDialog
|
||||
)
|
||||
} else {
|
||||
CreatorChannelPlaceholderTabView(title: viewModel.selectedTab.title)
|
||||
@@ -158,6 +184,12 @@ struct CreatorChannelView: View {
|
||||
private func showContentDetail(_ contentId: Int) {
|
||||
AppState.shared.setAppStep(step: .contentDetail(contentId: contentId))
|
||||
}
|
||||
|
||||
private func showDonationDialog() {
|
||||
guard let creatorId = viewModel.response?.creator.creatorId else { return }
|
||||
channelDonationViewModel.setCreatorId(creatorId, shouldFetch: false)
|
||||
isShowChannelDonationDialog = true
|
||||
}
|
||||
}
|
||||
|
||||
struct CreatorChannelView_Previews: PreviewProvider {
|
||||
@@ -194,7 +226,36 @@ struct CreatorChannelView_Previews: PreviewProvider {
|
||||
isOwned: false,
|
||||
isRented: false
|
||||
),
|
||||
channelDonations: [],
|
||||
channelDonations: [
|
||||
CreatorChannelDonationResponse(
|
||||
nickname: "팬 이름 50",
|
||||
profileImageUrl: "https://picsum.photos/120/120?1",
|
||||
can: 50,
|
||||
message: "크리에이터가 커뮤니티에 올린 글이 보이는 부분 크리에이터가 커뮤니티에 올린 글이 보이는 부분",
|
||||
createdAtUtc: "2026-07-03T03:44:00Z"
|
||||
),
|
||||
CreatorChannelDonationResponse(
|
||||
nickname: "팬 이름 100",
|
||||
profileImageUrl: "https://picsum.photos/120/120?2",
|
||||
can: 100,
|
||||
message: "51~100캔 후원 컬러를 확인하는 Preview 샘플입니다.",
|
||||
createdAtUtc: "2026-07-03T03:43:00Z"
|
||||
),
|
||||
CreatorChannelDonationResponse(
|
||||
nickname: "팬 이름 500",
|
||||
profileImageUrl: "https://picsum.photos/120/120?3",
|
||||
can: 500,
|
||||
message: "101~500캔 후원 컬러를 확인하는 Preview 샘플입니다.",
|
||||
createdAtUtc: "2026-07-03T03:42:00Z"
|
||||
),
|
||||
CreatorChannelDonationResponse(
|
||||
nickname: "팬 이름 501",
|
||||
profileImageUrl: "https://picsum.photos/120/120?4",
|
||||
can: 501,
|
||||
message: "501캔 이상 후원 컬러를 확인하는 Preview 샘플입니다.",
|
||||
createdAtUtc: "2026-07-03T03:41:00Z"
|
||||
)
|
||||
],
|
||||
notices: [],
|
||||
schedules: [],
|
||||
audioContents: [],
|
||||
|
||||
Reference in New Issue
Block a user