응원글 삭제 기능 추가
This commit is contained in:
@@ -15,5 +15,6 @@ struct PostWriteCheersRequest: Encodable {
|
||||
|
||||
struct PutModifyCheersRequest: Encodable {
|
||||
let cheersId: Int
|
||||
let content: String
|
||||
let content: String?
|
||||
let isActive: Bool?
|
||||
}
|
||||
|
@@ -81,17 +81,18 @@ struct UserProfileFanTalkAllView: View {
|
||||
let cheer = viewModel.cheersList[index]
|
||||
UserProfileFanTalkCheersItemView(
|
||||
userId: userId,
|
||||
cheer: cheer,
|
||||
cheersItem: cheer,
|
||||
writeCheerReply: { cheersReplyContent in
|
||||
viewModel.writeCheersReply(parentCheersId: cheer.cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent)
|
||||
},
|
||||
modifyCheer: { cheersId, cheersReplyContent in
|
||||
viewModel.modifyCheersReply(cheersId: cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent)
|
||||
viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent)
|
||||
},
|
||||
reportPopup: { cheersId in
|
||||
viewModel.reportCheersId = cheersId
|
||||
viewModel.isShowCheersReportMenu = true
|
||||
}
|
||||
},
|
||||
onClickDelete: { _ in }
|
||||
)
|
||||
.onAppear {
|
||||
if index == viewModel.cheersList.count - 1 {
|
||||
|
@@ -11,127 +11,176 @@ import Kingfisher
|
||||
struct UserProfileFanTalkCheersItemView: View {
|
||||
|
||||
let userId: Int
|
||||
let cheer: GetCheersResponseItem
|
||||
let cheersItem: GetCheersResponseItem
|
||||
let writeCheerReply: (String) -> Void
|
||||
let modifyCheer: (Int, String) -> Void
|
||||
let reportPopup: (Int) -> Void
|
||||
let onClickDelete: (Int) -> Void
|
||||
|
||||
@State var replyContent: String = ""
|
||||
@State var isShowInputReply = false
|
||||
|
||||
@State var isShowPopupMenu: Bool = false
|
||||
@State var isModeModify: Bool = false
|
||||
@State var cheers: String = ""
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(alignment: .top, spacing: 6.7) {
|
||||
KFImage(URL(string: cheer.profileUrl))
|
||||
.cancelOnDisappear(true)
|
||||
.downsampling(size: CGSize(width: 33.3, height: 33.3))
|
||||
.resizable()
|
||||
.frame(width: 33.3, height: 33.3)
|
||||
.clipShape(Circle())
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text("\(cheer.nickname)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
ZStack(alignment: .topTrailing) {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(alignment: .top, spacing: 6.7) {
|
||||
KFImage(URL(string: cheersItem.profileUrl))
|
||||
.cancelOnDisappear(true)
|
||||
.downsampling(size: CGSize(width: 33.3, height: 33.3))
|
||||
.resizable()
|
||||
.frame(width: 33.3, height: 33.3)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text("\(cheer.date)")
|
||||
.font(.custom(Font.medium.rawValue, size: 10.7))
|
||||
.foregroundColor(Color(hex: "525252"))
|
||||
.padding(.top, 8.3)
|
||||
|
||||
Text("\(cheer.content)")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.padding(.top, 13.3)
|
||||
|
||||
if isShowInputReply {
|
||||
HStack(spacing: 10) {
|
||||
TextField("응원댓글에 답글을 남겨보세요!", text: $replyContent)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.padding(13.3)
|
||||
.background(Color(hex: "232323"))
|
||||
.accentColor(Color(hex: "9970ff"))
|
||||
.keyboardType(.default)
|
||||
.cornerRadius(10)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.strokeBorder(lineWidth: 1)
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
)
|
||||
|
||||
Text("등록")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "ffffff"))
|
||||
.padding(13.3)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.cornerRadius(6.7)
|
||||
.onTapGesture {
|
||||
if cheer.replyList.count > 0 {
|
||||
modifyCheer(cheer.replyList[0].cheersId, replyContent)
|
||||
} else {
|
||||
writeCheerReply(replyContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 10)
|
||||
} else {
|
||||
if cheer.replyList.count <= 0 {
|
||||
if userId == UserDefaults.int(forKey: .userId) {
|
||||
Text("답글쓰기")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.padding(.top, 18.3)
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text("\(cheersItem.nickname)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Text("\(cheersItem.date)")
|
||||
.font(.custom(Font.medium.rawValue, size: 10.7))
|
||||
.foregroundColor(Color(hex: "525252"))
|
||||
.padding(.top, 8.3)
|
||||
|
||||
Text("\(cheersItem.content)")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.padding(.top, 13.3)
|
||||
|
||||
if isShowInputReply {
|
||||
HStack(spacing: 10) {
|
||||
TextField("응원댓글에 답글을 남겨보세요!", text: $replyContent)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.padding(13.3)
|
||||
.background(Color(hex: "232323"))
|
||||
.accentColor(Color(hex: "9970ff"))
|
||||
.keyboardType(.default)
|
||||
.cornerRadius(10)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.strokeBorder(lineWidth: 1)
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
)
|
||||
|
||||
Text("등록")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "ffffff"))
|
||||
.padding(13.3)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.cornerRadius(6.7)
|
||||
.onTapGesture {
|
||||
isShowInputReply = true
|
||||
if cheersItem.replyList.count > 0 {
|
||||
modifyCheer(cheersItem.replyList[0].cheersId, replyContent)
|
||||
} else {
|
||||
writeCheerReply(replyContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 10)
|
||||
} else {
|
||||
let reply = cheer.replyList[0]
|
||||
VStack(alignment: .leading, spacing: 8.3) {
|
||||
Text(reply.content)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "ffffff"))
|
||||
.frame(minWidth: 100)
|
||||
.padding(.horizontal, 6.7)
|
||||
.padding(.vertical, 6.7)
|
||||
.background(Color(hex: "9970ff").opacity(0.3))
|
||||
.cornerRadius(16.7)
|
||||
.padding(.top, 18.3)
|
||||
|
||||
HStack(spacing: 6.7) {
|
||||
Text(reply.date)
|
||||
.font(.custom(Font.medium.rawValue, size: 10.7))
|
||||
.foregroundColor(Color(hex: "525252"))
|
||||
if cheersItem.replyList.count <= 0 {
|
||||
if userId == UserDefaults.int(forKey: .userId) {
|
||||
Text("답글쓰기")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.padding(.top, 18.3)
|
||||
.onTapGesture {
|
||||
isShowInputReply = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let reply = cheersItem.replyList[0]
|
||||
VStack(alignment: .leading, spacing: 8.3) {
|
||||
Text(reply.content)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "ffffff"))
|
||||
.frame(minWidth: 100)
|
||||
.padding(.horizontal, 6.7)
|
||||
.padding(.vertical, 6.7)
|
||||
.background(Color(hex: "9970ff").opacity(0.3))
|
||||
.cornerRadius(16.7)
|
||||
.padding(.top, 18.3)
|
||||
|
||||
if userId == UserDefaults.int(forKey: .userId) {
|
||||
Text("답글 수정")
|
||||
HStack(spacing: 6.7) {
|
||||
Text(reply.date)
|
||||
.font(.custom(Font.medium.rawValue, size: 10.7))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.onTapGesture {
|
||||
self.replyContent = reply.content
|
||||
isShowInputReply = true
|
||||
}
|
||||
.foregroundColor(Color(hex: "525252"))
|
||||
|
||||
if userId == UserDefaults.int(forKey: .userId) {
|
||||
Text("답글 수정")
|
||||
.font(.custom(Font.medium.rawValue, size: 10.7))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.onTapGesture {
|
||||
self.replyContent = reply.content
|
||||
isShowInputReply = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Image("ic_seemore_vertical")
|
||||
.onTapGesture { isShowPopupMenu = true }
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Image("ic_seemore_vertical")
|
||||
.onTapGesture { reportPopup(cheer.cheersId) }
|
||||
Rectangle()
|
||||
.frame(height: 1)
|
||||
.foregroundColor(Color(hex: "909090").opacity(0.5))
|
||||
.padding(.top, 13.3)
|
||||
}
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
|
||||
Rectangle()
|
||||
.frame(height: 1)
|
||||
.foregroundColor(Color(hex: "909090").opacity(0.5))
|
||||
.padding(.top, 13.3)
|
||||
if isShowPopupMenu {
|
||||
VStack(spacing: 10) {
|
||||
if cheersItem.memberId != UserDefaults.int(forKey: .userId) {
|
||||
Text("신고하기")
|
||||
.font(.custom(Font.medium.rawValue, size: 14))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.onTapGesture {
|
||||
reportPopup(cheersItem.cheersId)
|
||||
isShowPopupMenu = false
|
||||
}
|
||||
}
|
||||
|
||||
if cheersItem.memberId == UserDefaults.int(forKey: .userId) {
|
||||
Text("수정")
|
||||
.font(.custom(Font.medium.rawValue, size: 14))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.onTapGesture {
|
||||
isModeModify = true
|
||||
isShowPopupMenu = false
|
||||
}
|
||||
}
|
||||
|
||||
if userId == UserDefaults.int(forKey: .userId) ||
|
||||
cheersItem.memberId == UserDefaults.int(forKey: .userId)
|
||||
{
|
||||
Text("삭제")
|
||||
.font(.custom(Font.medium.rawValue, size: 14))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.onTapGesture {
|
||||
onClickDelete(cheersItem.cheersId)
|
||||
isShowPopupMenu = false
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
.background(Color(hex: "222222"))
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
isShowPopupMenu = false
|
||||
}
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ struct UserProfileFanTalkView: View {
|
||||
let cheers: GetCheersResponse
|
||||
let errorPopup: (String) -> Void
|
||||
let reportPopup: (Int) -> Void
|
||||
let deletePopup: (Int) -> Void
|
||||
|
||||
@Binding var isLoading: Bool
|
||||
@State private var cheersContent: String = ""
|
||||
@@ -97,15 +98,18 @@ struct UserProfileFanTalkView: View {
|
||||
let cheer = viewModel.cheersList[$0]
|
||||
UserProfileFanTalkCheersItemView(
|
||||
userId: userId,
|
||||
cheer: cheer,
|
||||
cheersItem: cheer,
|
||||
writeCheerReply: { cheersReplyContent in
|
||||
viewModel.writeCheersReply(parentCheersId: cheer.cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent)
|
||||
},
|
||||
modifyCheer: { cheersId, cheersReplyContent in
|
||||
viewModel.modifyCheersReply(cheersId: cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent)
|
||||
viewModel.modifyCheers(cheersId: cheersId, creatorId: userId, cheersReplyContent: cheersReplyContent)
|
||||
},
|
||||
reportPopup: { cheersId in
|
||||
reportPopup(cheersId)
|
||||
},
|
||||
onClickDelete: { cheersId in
|
||||
deletePopup(cheersId)
|
||||
}
|
||||
)
|
||||
.onTapGesture {
|
||||
|
@@ -224,7 +224,7 @@ final class UserProfileFanTalkViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func modifyCheersReply(cheersId: Int, creatorId: Int, cheersReplyContent: String) {
|
||||
func modifyCheers(cheersId: Int, creatorId: Int, cheersReplyContent: String) {
|
||||
if cheersReplyContent.trimmingCharacters(in: .whitespaces).isEmpty {
|
||||
if let errorPopup = errorPopup {
|
||||
errorPopup("내용을 입력하세요")
|
||||
@@ -241,7 +241,7 @@ final class UserProfileFanTalkViewModel: ObservableObject {
|
||||
}
|
||||
isLoading = true
|
||||
|
||||
repository.modifyCheers(cheersId: cheersId, content: cheersReplyContent)
|
||||
repository.modifyCheers(cheersId: cheersId, content: cheersReplyContent, isActive: nil)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
|
Reference in New Issue
Block a user