응원글 전체보기 - 응원글 삭제기능 추가
This commit is contained in:
parent
948b1fd2b3
commit
1f992a11dc
|
@ -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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ struct UserProfileFanTalkCheersItemView: View {
|
|||
.cornerRadius(6.7)
|
||||
.onTapGesture {
|
||||
modifyCheer(cheersItem.cheersId, cheers)
|
||||
isModeModify = false
|
||||
}
|
||||
|
||||
Text("취소")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue