feat(follow): 팔로우 해제 확인 팝업을 추가한다

This commit is contained in:
Yu Sung
2026-08-18 11:40:35 +09:00
parent 702d82ebb1
commit 16b1eab206
6 changed files with 150 additions and 50 deletions

View File

@@ -13,6 +13,19 @@ struct FollowCreatorItemView: View {
let creator: GetCreatorFollowingAllListItem
let onClickFollow: (Int) -> Void
let showCreatorFollowNotifyDialog: (Int) -> Void
let onTapUnfollow: ((Int) -> Void)?
init(
creator: GetCreatorFollowingAllListItem,
onClickFollow: @escaping (Int) -> Void,
showCreatorFollowNotifyDialog: @escaping (Int) -> Void,
onTapUnfollow: ((Int) -> Void)? = nil
) {
self.creator = creator
self.onClickFollow = onClickFollow
self.showCreatorFollowNotifyDialog = showCreatorFollowNotifyDialog
self.onTapUnfollow = onTapUnfollow
}
var body: some View {
VStack(spacing: 13.3) {
@@ -36,19 +49,7 @@ struct FollowCreatorItemView: View {
Spacer()
let asset = FollowButtonImageAsset(
type: creator.isFollow
? (creator.isNotify ? .following : .followingNoAlarm)
: .follow
)
asset.imageView()
.onTapGesture {
if creator.isFollow {
showCreatorFollowNotifyDialog(creator.creatorId)
} else {
onClickFollow(creator.creatorId)
}
}
followButton
}
Rectangle()
@@ -56,4 +57,33 @@ struct FollowCreatorItemView: View {
.frame(height: 0.5)
}
}
@ViewBuilder
private var followButton: some View {
if creator.isFollow, let onTapUnfollow {
Button(action: { onTapUnfollow(creator.creatorId) }) {
Image("ic_new_following_white")
.resizable()
.frame(width: 20, height: 20)
.frame(width: 36, height: 36)
.background(Color.gray800)
.clipShape(Circle())
}
.buttonStyle(.plain)
} else {
let asset = FollowButtonImageAsset(
type: creator.isFollow
? (creator.isNotify ? .following : .followingNoAlarm)
: .follow
)
asset.imageView()
.onTapGesture {
if creator.isFollow {
showCreatorFollowNotifyDialog(creator.creatorId)
} else {
onClickFollow(creator.creatorId)
}
}
}
}
}

View File

@@ -11,9 +11,10 @@ struct FollowCreatorView: View {
@StateObject var viewModel = FollowCreatorViewModel()
@State private var isShowFollowNotifyDialog: Bool = false
@State private var isShowUnfollowConfirmDialog: Bool = false
@State private var creatorId: Int = 0
@State private var selectedItemIndex: Int = 0
@State private var creatorName: String = ""
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
@@ -48,7 +49,12 @@ struct FollowCreatorView: View {
showCreatorFollowNotifyDialog: {
creatorId = $0
selectedItemIndex = index
isShowFollowNotifyDialog = true
},
onTapUnfollow: {
creatorId = $0
creatorName = creator.nickname
selectedItemIndex = index
isShowUnfollowConfirmDialog = true
}
)
.padding(.horizontal, 20)
@@ -77,41 +83,44 @@ struct FollowCreatorView: View {
}
.sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2)
if isShowFollowNotifyDialog {
CreatorFollowNotifyDialog(
isShowing: $isShowFollowNotifyDialog,
onClickNotifyAll: {
viewModel.creatorFollow(
creatorId: creatorId,
index: selectedItemIndex,
follow: true,
notify: true
)
creatorId = 0
selectedItemIndex = -1
},
onClickNotifyNone: {
viewModel.creatorFollow(
creatorId: creatorId,
index: selectedItemIndex,
follow: true,
notify: false
)
creatorId = 0
selectedItemIndex = -1
},
onClickUnFollow: {
viewModel.creatorFollow(
creatorId: creatorId,
index: selectedItemIndex,
follow: false,
notify: false
)
creatorId = 0
selectedItemIndex = -1
}
)
if isShowUnfollowConfirmDialog {
unfollowConfirmDialog
}
}
}
private var unfollowConfirmDialog: some View {
SodaV2ActionModal(
title: I18n.MemberChannel.unfollowActionModalTitle,
message: I18n.MemberChannel.unfollowActionModalMessage(creatorName),
button1: SodaV2ActionModalButton(
label: I18n.MemberChannel.unfollowActionModalConfirm,
action: confirmUnfollow
),
button2: SodaV2ActionModalButton(
label: I18n.MemberChannel.unfollowActionModalCancel,
action: dismissUnfollowConfirmDialog
),
onDimmedTap: dismissUnfollowConfirmDialog
)
}
private func confirmUnfollow() {
let targetCreatorId = creatorId
let targetIndex = selectedItemIndex
dismissUnfollowConfirmDialog()
viewModel.creatorFollow(
creatorId: targetCreatorId,
index: targetIndex,
follow: false,
notify: false
)
}
private func dismissUnfollowConfirmDialog() {
isShowUnfollowConfirmDialog = false
creatorId = 0
selectedItemIndex = -1
creatorName = ""
}
}