feat(follow): 팔로우 해제 확인 팝업을 추가한다
This commit is contained in:
@@ -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 = ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user