인기 크리에이터 팔로우 해제 시 확인 다이얼로그 추가

This commit is contained in:
Yu Sung
2026-01-22 19:04:48 +09:00
parent 75452f0ffd
commit 4b9cdeb824
3 changed files with 64 additions and 11 deletions

View File

@@ -22,6 +22,9 @@ struct HomeTabView: View {
@State private var isShowAuthConfirmView: Bool = false
@State private var pendingAction: (() -> Void)? = nil
@State private var payload = Payload()
@State private var isShowUnfollowConfirmDialog = false
@State private var pendingUnfollowCreatorId: Int? = nil
@State private var pendingUnfollowCreatorName = ""
var onTapPopularCharacterAllView: (() -> Void)? = nil
@@ -124,17 +127,19 @@ struct HomeTabView: View {
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 16) {
ForEach(0..<viewModel.creatorRanking.count, id: \.self) {
let item = viewModel.creatorRanking[$0]
ForEach(viewModel.creatorRanking.indices, id: \.self) { index in
let item = viewModel.creatorRanking[index]
HomeCreatorRankingItemView(
rank: $0 + 1,
item: item,
rank: index + 1,
item: $viewModel.creatorRanking[index],
onClickFollow: { creatorId, follow in
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
if follow {
viewModel.creatorFollow(creatorId: item.id, follow: true, notify: true)
} else {
viewModel.creatorFollow(creatorId: item.id, follow: false, notify: false)
pendingUnfollowCreatorId = creatorId
pendingUnfollowCreatorName = item.nickname
isShowUnfollowConfirmDialog = true
}
} else {
AppState.shared
@@ -430,6 +435,37 @@ struct HomeTabView: View {
)
}
if isShowUnfollowConfirmDialog {
SodaDialog(
title: I18n.MemberChannel.unfollowConfirmTitle,
desc: I18n.MemberChannel.unfollowConfirmDescription(pendingUnfollowCreatorName),
confirmButtonTitle: I18n.Common.confirm,
confirmButtonAction: {
isShowUnfollowConfirmDialog = false
guard let creatorId = pendingUnfollowCreatorId else {
pendingUnfollowCreatorId = nil
pendingUnfollowCreatorName = ""
return
}
if let index = viewModel.creatorRanking.firstIndex(
where: { $0.id == creatorId }
) {
viewModel.creatorRanking[index].follow = false
}
pendingUnfollowCreatorId = nil
pendingUnfollowCreatorName = ""
viewModel.creatorFollow(creatorId: creatorId, follow: false, notify: false)
},
cancelButtonTitle: I18n.Common.cancel,
cancelButtonAction: {
isShowUnfollowConfirmDialog = false
pendingUnfollowCreatorId = nil
pendingUnfollowCreatorName = ""
},
textAlignment: .center
)
}
if liveViewModel.isShowPasswordDialog {
LiveRoomPasswordDialog(
isShowing: $liveViewModel.isShowPasswordDialog,