콘텐츠 댓글 - 수정/삭제 추가
This commit is contained in:
@@ -10,80 +10,162 @@ import Kingfisher
|
||||
|
||||
struct AudioContentCommentItemView: View {
|
||||
|
||||
let comment: GetAudioContentCommentListItem
|
||||
@Binding var isDisabledNavigationLink: Bool
|
||||
|
||||
let contentCreatorId: Int
|
||||
let commentItem: GetAudioContentCommentListItem
|
||||
let isReplyComment: Bool
|
||||
let isShowPopupMenuButton: Bool
|
||||
|
||||
let modifyComment: (Int, String) -> Void
|
||||
let onClickDelete: (Int) -> Void
|
||||
|
||||
@State var isShowPopupMenu: Bool = false
|
||||
@State var isModeModify: Bool = false
|
||||
@State var comment: String = ""
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(spacing: 6.7) {
|
||||
KFImage(URL(string: comment.profileUrl))
|
||||
.resizable()
|
||||
.frame(width: 40, height: 40)
|
||||
.clipShape(Circle())
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(comment.nickname)
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Text(comment.date)
|
||||
.font(.custom(Font.medium.rawValue, size: 10.3))
|
||||
.foregroundColor(Color(hex: "525252"))
|
||||
.padding(.top, 4)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if comment.donationCan > 0 {
|
||||
HStack(spacing: 3) {
|
||||
Image("ic_can")
|
||||
ZStack(alignment: .topTrailing) {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(spacing: 6.7) {
|
||||
KFImage(URL(string: commentItem.profileUrl))
|
||||
.resizable()
|
||||
.frame(width: 13.3, height: 13.3)
|
||||
.frame(width: 40, height: 40)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text("\(comment.donationCan)")
|
||||
.font(.custom(Font.bold.rawValue, size: 12))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.padding(.horizontal, 6.7)
|
||||
.padding(.vertical, 2.7)
|
||||
.background(
|
||||
comment.donationCan >= 100000 ? Color(hex: "973a3a") :
|
||||
comment.donationCan >= 50000 ? Color(hex: "d85e37") :
|
||||
comment.donationCan >= 10000 ? Color(hex: "d38c38") :
|
||||
comment.donationCan >= 5000 ? Color(hex: "59548f") :
|
||||
comment.donationCan >= 1000 ? Color(hex: "4d6aa4") :
|
||||
comment.donationCan >= 500 ? Color(hex: "2d7390") :
|
||||
Color(hex: "548f7d")
|
||||
)
|
||||
.cornerRadius(10.7)
|
||||
.padding(.leading, 46.7)
|
||||
.padding(.bottom, 5)
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
VStack(alignment: .leading, spacing: 13.3) {
|
||||
Text(comment.comment)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.padding(.top, comment.donationCan > 0 ? 0 : 13.3)
|
||||
|
||||
if !isReplyComment {
|
||||
Text(comment.replyCount > 0 ? "답글 \(comment.replyCount)개" : "답글 쓰기")
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(commentItem.nickname)
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Text(commentItem.date)
|
||||
.font(.custom(Font.medium.rawValue, size: 10.3))
|
||||
.foregroundColor(Color(hex: "525252"))
|
||||
.padding(.top, 4)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if isShowPopupMenuButton && (contentCreatorId == UserDefaults.int(forKey: .userId) || commentItem.writerId == UserDefaults.int(forKey: .userId)) {
|
||||
Image("ic_seemore_vertical")
|
||||
.onTapGesture { isShowPopupMenu.toggle() }
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
if commentItem.donationCan > 0 {
|
||||
HStack(spacing: 3) {
|
||||
Image("ic_can")
|
||||
.resizable()
|
||||
.frame(width: 13.3, height: 13.3)
|
||||
|
||||
Text("\(commentItem.donationCan)")
|
||||
.font(.custom(Font.bold.rawValue, size: 12))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.padding(.horizontal, 6.7)
|
||||
.padding(.vertical, 2.7)
|
||||
.background(
|
||||
commentItem.donationCan >= 100000 ? Color(hex: "973a3a") :
|
||||
commentItem.donationCan >= 50000 ? Color(hex: "d85e37") :
|
||||
commentItem.donationCan >= 10000 ? Color(hex: "d38c38") :
|
||||
commentItem.donationCan >= 5000 ? Color(hex: "59548f") :
|
||||
commentItem.donationCan >= 1000 ? Color(hex: "4d6aa4") :
|
||||
commentItem.donationCan >= 500 ? Color(hex: "2d7390") :
|
||||
Color(hex: "548f7d")
|
||||
)
|
||||
.cornerRadius(10.7)
|
||||
.padding(.leading, 46.7)
|
||||
.padding(.bottom, 5)
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
if isModeModify {
|
||||
HStack(spacing: 0) {
|
||||
TextField("댓글을 입력해 보세요.", text: $comment)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.accentColor(Color(hex: "9970ff"))
|
||||
.keyboardType(.default)
|
||||
.padding(.horizontal, 13.3)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image("btn_message_send")
|
||||
.resizable()
|
||||
.frame(width: 35, height: 35)
|
||||
.padding(6.7)
|
||||
.onTapGesture {
|
||||
hideKeyboard()
|
||||
if commentItem.comment != comment {
|
||||
modifyComment(commentItem.id, comment)
|
||||
}
|
||||
isModeModify = false
|
||||
}
|
||||
}
|
||||
.background(Color(hex: "232323"))
|
||||
.cornerRadius(10)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.strokeBorder(lineWidth: 1)
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
)
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 13.3) {
|
||||
Text(commentItem.comment)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.padding(.top, commentItem.donationCan > 0 ? 0 : 13.3)
|
||||
|
||||
if !isReplyComment {
|
||||
Text(commentItem.replyCount > 0 ? "답글 \(commentItem.replyCount)개" : "답글 쓰기")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.leading, 46.7)
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(Color(hex: "595959"))
|
||||
.frame(height: 0.5)
|
||||
.padding(.top, 16.7)
|
||||
}
|
||||
.padding(.leading, 46.7)
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(Color(hex: "595959"))
|
||||
.frame(height: 0.5)
|
||||
.padding(.top, 16.7)
|
||||
if isShowPopupMenu {
|
||||
VStack(spacing: 10) {
|
||||
if commentItem.writerId == UserDefaults.int(forKey: .userId) {
|
||||
Text("수정")
|
||||
.font(.custom(Font.medium.rawValue, size: 14))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.onTapGesture {
|
||||
isModeModify = true
|
||||
isDisabledNavigationLink = true
|
||||
isShowPopupMenu = false
|
||||
}
|
||||
}
|
||||
|
||||
if contentCreatorId == UserDefaults.int(forKey: .userId) ||
|
||||
commentItem.writerId == UserDefaults.int(forKey: .userId)
|
||||
{
|
||||
Text("삭제")
|
||||
.font(.custom(Font.medium.rawValue, size: 14))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.onTapGesture {
|
||||
onClickDelete(commentItem.id)
|
||||
isShowPopupMenu = false
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
.background(Color(hex: "222222"))
|
||||
}
|
||||
}
|
||||
.onAppear { comment = commentItem.comment }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user