diff --git a/SodaLive/Sources/Content/ContentRepository.swift b/SodaLive/Sources/Content/ContentRepository.swift index 649d4b7..1000fb2 100644 --- a/SodaLive/Sources/Content/ContentRepository.swift +++ b/SodaLive/Sources/Content/ContentRepository.swift @@ -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 { - 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 { + return api.requestPublisher(.registerComment(request: RegisterAudioContentCommentRequest(comment: comment, contentId: audioContentId, parentId: parentId, isSecret: isSecret))) } func orderAudioContent(contentId: Int, orderType: OrderType) -> AnyPublisher { diff --git a/SodaLive/Sources/Content/Detail/Comment/ContentDetailCommentView.swift b/SodaLive/Sources/Content/Detail/Comment/ContentDetailCommentView.swift index 7108643..8a757ff 100644 --- a/SodaLive/Sources/Content/Detail/Comment/ContentDetailCommentView.swift +++ b/SodaLive/Sources/Content/Detail/Comment/ContentDetailCommentView.swift @@ -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) ) } diff --git a/SodaLive/Sources/Content/Detail/Comment/RegisterAudioContentCommentRequest.swift b/SodaLive/Sources/Content/Detail/Comment/RegisterAudioContentCommentRequest.swift index 4e72841..6b8e682 100644 --- a/SodaLive/Sources/Content/Detail/Comment/RegisterAudioContentCommentRequest.swift +++ b/SodaLive/Sources/Content/Detail/Comment/RegisterAudioContentCommentRequest.swift @@ -11,4 +11,5 @@ struct RegisterAudioContentCommentRequest: Encodable { let comment: String let contentId: Int let parentId: Int? + let isSecret: Bool } diff --git a/SodaLive/Sources/Content/Detail/ContentDetailView.swift b/SodaLive/Sources/Content/Detail/ContentDetailView.swift index 18e6e80..ef21a64 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailView.swift @@ -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) diff --git a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift index c00844f..5ef8374 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift @@ -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: