콘텐츠 상세

- 댓글이 없을 때 유료 콘텐츠를 구매한 사람이 비밀댓글을 등록할 수 있는 기능 추가
This commit is contained in:
Yu Sung 2024-08-30 17:15:13 +09:00
parent ca9dee5574
commit fa849dd5b6
5 changed files with 33 additions and 14 deletions

View File

@ -26,8 +26,8 @@ final class ContentRepository {
return api.requestPublisher(.likeContent(request: PutAudioContentLikeRequest(contentId: audioContentId)))
}
func registerComment(audioContentId: Int, comment: String, parentId: Int? = nil) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.registerComment(request: RegisterAudioContentCommentRequest(comment: comment, contentId: audioContentId, parentId: parentId)))
func registerComment(audioContentId: Int, comment: String, parentId: Int? = nil, isSecret: Bool = false) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.registerComment(request: RegisterAudioContentCommentRequest(comment: comment, contentId: audioContentId, parentId: parentId, isSecret: isSecret)))
}
func orderAudioContent(contentId: Int, orderType: OrderType) -> AnyPublisher<Response, MoyaError> {

View File

@ -12,10 +12,12 @@ struct ContentDetailCommentView: View {
let commentCount: Int
let commentList: [GetAudioContentCommentListItem]
let isShowSecret: Bool
let registerComment: (String) -> Void
let registerComment: (String, Bool) -> Void
@State private var comment = ""
@State private var isSecret = false
var body: some View {
VStack(alignment: .leading, spacing: 10.3) {
@ -26,9 +28,24 @@ struct ContentDetailCommentView: View {
Text("\(commentCount)")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "909090"))
.foregroundColor(Color.gray90)
Spacer()
if isShowSecret && commentCount <= 0 {
HStack(spacing: 8) {
Image(isSecret ? "btn_select_checked" : "btn_select_normal")
.resizable()
.frame(width: 20, height: 20)
Text("비밀댓글")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.grayee)
}
.onTapGesture {
isSecret.toggle()
}
}
}
HStack(spacing: 8) {
@ -48,7 +65,7 @@ struct ContentDetailCommentView: View {
if commentCount > 0 {
Text(commentList[0].comment)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "bbbbbb"))
.foregroundColor(Color.graybb)
.lineLimit(1)
.lineSpacing(8)
.padding(.leading, 3)
@ -58,8 +75,8 @@ struct ContentDetailCommentView: View {
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
.accentColor(Color(hex: "3bb9f1"))
.foregroundColor(Color.grayee)
.accentColor(Color.button)
.keyboardType(.default)
.padding(.horizontal, 13.3)
@ -71,15 +88,15 @@ struct ContentDetailCommentView: View {
.padding(6.7)
.onTapGesture {
hideKeyboard()
registerComment(comment)
registerComment(comment, isSecret)
}
}
.background(Color(hex: "232323"))
.background(Color.gray23)
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.strokeBorder(lineWidth: 1)
.foregroundColor(Color(hex: "3bb9f1"))
.foregroundColor(Color.button)
)
}

View File

@ -11,4 +11,5 @@ struct RegisterAudioContentCommentRequest: Encodable {
let comment: String
let contentId: Int
let parentId: Int?
let isSecret: Bool
}

View File

@ -136,8 +136,9 @@ struct ContentDetailView: View {
ContentDetailCommentView(
commentCount: audioContent.commentCount,
commentList: audioContent.commentList,
registerComment: { comment in
self.viewModel.registerComment(comment: comment)
isShowSecret: audioContent.existOrdered,
registerComment: { comment, isSecret in
self.viewModel.registerComment(comment: comment, isSecret: isSecret)
}
)
.padding(10.3)

View File

@ -239,14 +239,14 @@ final class ContentDetailViewModel: ObservableObject {
}
}
func registerComment(comment: String) {
func registerComment(comment: String, isSecret: Bool) {
if comment.trimmingCharacters(in: .whitespaces).isEmpty {
return
}
isLoading = true
repository.registerComment(audioContentId: contentId, comment: comment)
repository.registerComment(audioContentId: contentId, comment: comment, isSecret: isSecret)
.sink { result in
switch result {
case .finished: