feat: 커뮤니티 댓글

- 유료 커뮤니티 구매시 비밀 댓글 쓰기 기능 추가
This commit is contained in:
Yu Sung
2025-06-13 19:18:37 +09:00
parent 522a177063
commit 24c97dbe51
13 changed files with 90 additions and 23 deletions

View File

@@ -9,4 +9,5 @@ struct CreateCommunityPostCommentRequest: Encodable {
let comment: String
let postId: Int
let parentId: Int?
let isSecret: Bool
}

View File

@@ -44,10 +44,22 @@ struct CreatorCommunityCommentItemView: View {
}
}
VStack(alignment: .leading, spacing: 0) {
Text(commentItem.nickname)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.gray90)
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 6.7) {
Text(commentItem.nickname)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.gray90)
if commentItem.isSecret {
Text("비밀댓글")
.font(.custom(Font.medium.rawValue, size: 11))
.foregroundColor(Color.grayee)
.padding(.horizontal, 4)
.padding(.vertical, 2)
.background(Color.button.opacity(0.2))
.cornerRadius(3.3)
}
}
Text(commentItem.date)
.font(.custom(Font.medium.rawValue, size: 10.3))

View File

@@ -14,6 +14,7 @@ struct CreatorCommunityCommentListView: View {
let creatorId: Int
let postId: Int
let isShowSecret: Bool
@State private var commentId: Int = 0
@State private var isShowDeletePopup: Bool = false
@@ -53,6 +54,28 @@ struct CreatorCommunityCommentListView: View {
.padding(.bottom, 13.3)
.padding(.horizontal, 13.3)
if isShowSecret {
HStack(spacing: 8) {
Spacer()
Image(viewModel.isSecret ? "btn_square_select_checked" : "btn_square_select_normal")
.resizable()
.frame(width: 20, height: 20)
.onTapGesture {
viewModel.isSecret.toggle()
}
Text("비밀댓글")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(viewModel.isSecret ? Color.button : Color.grayee)
.onTapGesture {
viewModel.isSecret.toggle()
}
}
.padding(.bottom, 13.3)
.padding(.horizontal, 13.3)
}
HStack(spacing: 8) {
KFImage(URL(string: UserDefaults.string(forKey: .profileImage)))
.cancelOnDisappear(true)
@@ -193,7 +216,8 @@ struct CreatorCommunityCommentListView_Previews: PreviewProvider {
CreatorCommunityCommentListView(
isPresented: .constant(true),
creatorId: 0,
postId: 0
postId: 0,
isShowSecret: true
)
}
}

View File

@@ -17,6 +17,7 @@ final class CreatorCommunityCommentListViewModel: ObservableObject {
@Published var isShowPopup = false
@Published var comment = ""
@Published var isSecret = false
@Published var totalCommentCount = 0
@Published var commentList = [GetCommunityPostCommentListItem]()
@@ -79,7 +80,7 @@ final class CreatorCommunityCommentListViewModel: ObservableObject {
if !isLoading {
isLoading = true
repository.createCommunityPostComment(comment: comment, postId: postId, parentId: parentId)
repository.createCommunityPostComment(comment: comment, postId: postId, parentId: parentId, isSecret: isSecret)
.sink { result in
switch result {
case .finished:
@@ -100,6 +101,7 @@ final class CreatorCommunityCommentListViewModel: ObservableObject {
self.comment = ""
self.page = 1
self.isLast = false
self.isSecret = false
self.getCommentList()
}
} else {

View File

@@ -192,6 +192,7 @@ struct CreatorCommunityCommentReplyView_Previews: PreviewProvider {
nickname: "댓글",
profileUrl: "",
comment: "부모 댓글입니다.",
isSecret: false,
date: "1시간전",
replyCount: 1
)

View File

@@ -81,7 +81,7 @@ final class CreatorCommunityCommentReplyViewModel: ObservableObject {
if !isLoading {
isLoading = true
repository.createCommunityPostComment(comment: comment, postId: postId, parentId: parentId)
repository.createCommunityPostComment(comment: comment, postId: postId, parentId: parentId, isSecret: false)
.sink { result in
switch result {
case .finished:

View File

@@ -11,10 +11,12 @@ import Kingfisher
struct CreatorCommunityCommentView: View {
let commentCount: Int
let commentItem: GetCommunityPostCommentListItem?
let isShowSecret: Bool
let onClickWriteComment: (String) -> Void
let onClickWriteComment: (String, Bool) -> Void
@State private var comment = ""
@State private var isSecret = false
var body: some View {
VStack(alignment: .leading, spacing: 11) {
@@ -28,6 +30,22 @@ struct CreatorCommunityCommentView: View {
.foregroundColor(Color(hex: "909090"))
Spacer()
if isShowSecret && commentItem == nil {
Image(isSecret ? "btn_square_select_checked" : "btn_square_select_normal")
.resizable()
.frame(width: 20, height: 20)
.onTapGesture {
isSecret.toggle()
}
Text("비밀댓글")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(isSecret ? Color.button : Color.grayee)
.onTapGesture {
isSecret.toggle()
}
}
}
HStack(spacing: 8) {
@@ -80,7 +98,7 @@ struct CreatorCommunityCommentView: View {
.padding(6.7)
.onTapGesture {
hideKeyboard()
onClickWriteComment(comment)
onClickWriteComment(comment, isSecret)
comment = ""
}
}
@@ -110,10 +128,12 @@ struct CreatorCommunityCommentView_Previews: PreviewProvider {
nickname: "닉네임",
profileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
comment: "댓글 테스트",
isSecret: false,
date: "1시간전",
replyCount: 0
),
onClickWriteComment: { _ in }
isShowSecret: true,
onClickWriteComment: { _, _ in }
)
}
}

View File

@@ -16,6 +16,7 @@ struct GetCommunityPostCommentListItem: Decodable {
let nickname: String
let profileUrl: String
let comment: String
let isSecret: Bool
let date: String
let replyCount: Int
}