diff --git a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkAllView.swift b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkAllView.swift index 1465b82..45668ae 100644 --- a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkAllView.swift +++ b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkAllView.swift @@ -14,6 +14,7 @@ struct UserProfileFanTalkAllView: View { @StateObject var viewModel = UserProfileFanTalkViewModel() @State private var cheersContent: String = "" + @State private var cheersId: Int = 0 var body: some View { GeometryReader { proxy in @@ -86,13 +87,16 @@ struct UserProfileFanTalkAllView: View { viewModel.writeCheersReply(parentCheersId: cheer.cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent) }, modifyCheer: { cheersId, cheersReplyContent in - viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent) + viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, cheersContent: cheersReplyContent) }, reportPopup: { cheersId in viewModel.reportCheersId = cheersId - viewModel.isShowCheersReportMenu = true + viewModel.isShowCheersReportView = true }, - onClickDelete: { _ in } + onClickDelete: { cheersId in + self.cheersId = cheersId + viewModel.isShowCheersDeleteView = true + } ) .onAppear { if index == viewModel.cheersList.count - 1 { @@ -142,22 +146,6 @@ struct UserProfileFanTalkAllView: View { } ZStack { - if viewModel.isShowCheersReportMenu { - VStack(spacing: 0) { - CheersReportMenuView( - isShowing: $viewModel.isShowCheersReportMenu, - onClickReport: { viewModel.isShowCheersReportView = true } - ) - - if proxy.safeAreaInsets.bottom > 0 { - Rectangle() - .foregroundColor(Color(hex: "222222")) - .frame(width: proxy.size.width, height: 15.3) - } - } - .ignoresSafeArea() - } - if viewModel.isShowCheersReportView { CheersReportDialogView( isShowing: $viewModel.isShowCheersReportView, @@ -166,6 +154,23 @@ struct UserProfileFanTalkAllView: View { } ) } + + if viewModel.isShowCheersDeleteView { + if viewModel.isShowCheersDeleteView { + SodaDialog( + title: "응원글 삭제", + desc: "삭제하시겠습니까?", + confirmButtonTitle: "삭제", + confirmButtonAction: { + viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, isActive: false) + viewModel.isShowCheersDeleteView = false + self.cheersId = 0 + }, + cancelButtonTitle: "취소", + cancelButtonAction: { viewModel.isShowCheersDeleteView = false } + ) + } + } } } } diff --git a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkCheersItemView.swift b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkCheersItemView.swift index 8c61f21..afc938f 100644 --- a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkCheersItemView.swift +++ b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkCheersItemView.swift @@ -71,6 +71,7 @@ struct UserProfileFanTalkCheersItemView: View { .cornerRadius(6.7) .onTapGesture { modifyCheer(cheersItem.cheersId, cheers) + isModeModify = false } Text("취소") diff --git a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkView.swift b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkView.swift index 48ccf64..86caaf7 100644 --- a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkView.swift +++ b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkView.swift @@ -103,7 +103,7 @@ struct UserProfileFanTalkView: View { viewModel.writeCheersReply(parentCheersId: cheer.cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent) }, modifyCheer: { cheersId, cheersReplyContent in - viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent) + viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, cheersContent: cheersReplyContent) }, reportPopup: { cheersId in reportPopup(cheersId) diff --git a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkViewModel.swift b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkViewModel.swift index 90bfc65..09effd3 100644 --- a/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkViewModel.swift +++ b/SodaLive/Sources/Explorer/Profile/FanTalk/UserProfileFanTalkViewModel.swift @@ -17,8 +17,8 @@ final class UserProfileFanTalkViewModel: ObservableObject { @Published var cheersList = [GetCheersResponseItem]() @Published var reportCheersId = 0 - @Published var isShowCheersReportMenu = false @Published var isShowCheersReportView = false + @Published var isShowCheersDeleteView = false var errorPopup: ((String) -> Void)? var setLoading: ((Bool) -> Void)? @@ -224,8 +224,17 @@ final class UserProfileFanTalkViewModel: ObservableObject { .store(in: &subscription) } - func modifyCheers(cheersId: Int, creatorId: Int, cheersReplyContent: String) { - if cheersReplyContent.trimmingCharacters(in: .whitespaces).isEmpty { + func modifyCheers(cheersId: Int, creatorId: Int, cheersContent: String? = nil, isActive: Bool? = nil) { + if cheersContent == nil && isActive == nil { + if let errorPopup = errorPopup { + errorPopup("변경사항이 없습니다.") + } else { + errorMessage = "변경사항이 없습니다." + isShowPopup = true + } + } + + if let cheersContent = cheersContent, cheersContent.trimmingCharacters(in: .whitespaces).isEmpty { if let errorPopup = errorPopup { errorPopup("내용을 입력하세요") } else { @@ -241,7 +250,7 @@ final class UserProfileFanTalkViewModel: ObservableObject { } isLoading = true - repository.modifyCheers(cheersId: cheersId, content: cheersReplyContent, isActive: nil) + repository.modifyCheers(cheersId: cheersId, content: cheersContent, isActive: isActive) .sink { result in switch result { case .finished: diff --git a/SodaLive/Sources/Report/CheersReportMenuView.swift b/SodaLive/Sources/Report/CheersReportMenuView.swift deleted file mode 100644 index c702fd2..0000000 --- a/SodaLive/Sources/Report/CheersReportMenuView.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// CheersReportMenuView.swift -// SodaLive -// -// Created by klaus on 2023/08/11. -// - -import SwiftUI - -struct CheersReportMenuView: View { - - @Binding var isShowing: Bool - let onClickReport: () -> Void - - var body: some View { - ZStack { - Color.black - .opacity(0.7) - .ignoresSafeArea() - .onTapGesture { isShowing = false } - - VStack(spacing: 0) { - Spacer() - - VStack(spacing: 13.3) { - HStack(spacing: 0) { - Text("신고하기") - .font(.custom(Font.medium.rawValue, size: 13.3)) - .foregroundColor(.white) - - Spacer() - } - .padding(.vertical, 8) - .padding(.horizontal, 26.7) - .contentShape(Rectangle()) - .onTapGesture { - isShowing = false - onClickReport() - } - } - .padding(24) - .background(Color(hex: "222222")) - .cornerRadius(13.3, corners: [.topLeft, .topRight]) - } - } - } -}