콘텐츠 댓글 - 수정/삭제 추가

This commit is contained in:
Yu Sung
2023-09-08 19:33:09 +09:00
parent 707b6f804c
commit b31933715d
9 changed files with 420 additions and 72 deletions

View File

@@ -11,10 +11,17 @@ import Kingfisher
struct AudioContentCommentListView: View {
@Binding var isPresented: Bool
let creatorId: Int
let audioContentId: Int
@StateObject var viewModel = AudioContentCommentListViewModel()
@State private var commentId: Int = 0
@State private var isShowDeletePopup: Bool = false
@State private var isDisabledNavigationLink: Bool = false
@State private var isShowReplyView: Bool = false
var body: some View {
NavigationView {
ZStack {
@@ -97,25 +104,66 @@ struct AudioContentCommentListView: View {
LazyVStack(spacing: 13.3) {
ForEach(0..<viewModel.commentList.count, id: \.self) { index in
let comment = viewModel.commentList[index]
NavigationLink {
AudioContentListReplyView(
audioContentId: audioContentId,
parentComment: comment
VStack {
NavigationLink(
destination: AudioContentListReplyView(
creatorId: creatorId,
audioContentId: audioContentId,
parentComment: comment
),
isActive: $isShowReplyView
) { EmptyView() }
AudioContentCommentItemView(
isDisabledNavigationLink: $isDisabledNavigationLink,
contentCreatorId: creatorId,
commentItem: comment,
isReplyComment: false,
isShowPopupMenuButton: true,
modifyComment: { commentId, comment in
hideKeyboard()
viewModel.modifyComment(commentId: commentId, audioContentId: audioContentId, comment: comment)
},
onClickDelete: {
commentId = $0
isShowDeletePopup = true
}
)
} label: {
AudioContentCommentItemView(comment: comment, isReplyComment: false)
.padding(.horizontal, 26.7)
.onAppear {
if index == viewModel.commentList.count - 1 {
viewModel.getCommentList()
}
}
.onTapGesture {
if !isDisabledNavigationLink {
isShowReplyView = true
}
}
}
}
}
}
}
if isShowDeletePopup && commentId > 0 {
SodaDialog(
title: "댓글 삭제",
desc: "삭제하시겠습니까?",
confirmButtonTitle: "삭제",
confirmButtonAction: {
viewModel.modifyComment(commentId: commentId, audioContentId: audioContentId, isActive: false)
commentId = 0
isShowDeletePopup = false
},
cancelButtonTitle: "취소",
cancelButtonAction: {
commentId = 0
isShowDeletePopup = false
}
)
}
if viewModel.isLoading {
LoadingView()
}