콘텐츠 댓글 - 수정/삭제 추가
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user