From fa849dd5b6ac19fb0febfbb138f1736569a297c3 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Fri, 30 Aug 2024 17:15:13 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20-=20=EB=8C=93=EA=B8=80=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EC=9D=84=20=EB=95=8C=20=EC=9C=A0=EB=A3=8C=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0=EB=A5=BC=20=EA=B5=AC=EB=A7=A4=ED=95=9C=20=EC=82=AC?= =?UTF-8?q?=EB=9E=8C=EC=9D=B4=20=EB=B9=84=EB=B0=80=EB=8C=93=EA=B8=80?= =?UTF-8?q?=EC=9D=84=20=EB=93=B1=EB=A1=9D=ED=95=A0=20=EC=88=98=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Content/ContentRepository.swift | 4 +-- .../Comment/ContentDetailCommentView.swift | 33 ++++++++++++++----- .../RegisterAudioContentCommentRequest.swift | 1 + .../Content/Detail/ContentDetailView.swift | 5 +-- .../Detail/ContentDetailViewModel.swift | 4 +-- 5 files changed, 33 insertions(+), 14 deletions(-) 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: