콘텐츠 상세
- 댓글이 없을 때 유료 콘텐츠를 구매한 사람이 비밀댓글을 등록할 수 있는 기능 추가
This commit is contained in:
		| @@ -26,8 +26,8 @@ final class ContentRepository { | |||||||
|         return api.requestPublisher(.likeContent(request: PutAudioContentLikeRequest(contentId: audioContentId))) |         return api.requestPublisher(.likeContent(request: PutAudioContentLikeRequest(contentId: audioContentId))) | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     func registerComment(audioContentId: Int, comment: String, parentId: Int? = nil) -> AnyPublisher<Response, MoyaError> { |     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))) |         return api.requestPublisher(.registerComment(request: RegisterAudioContentCommentRequest(comment: comment, contentId: audioContentId, parentId: parentId, isSecret: isSecret))) | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     func orderAudioContent(contentId: Int, orderType: OrderType) -> AnyPublisher<Response, MoyaError> { |     func orderAudioContent(contentId: Int, orderType: OrderType) -> AnyPublisher<Response, MoyaError> { | ||||||
|   | |||||||
| @@ -12,10 +12,12 @@ struct ContentDetailCommentView: View { | |||||||
|      |      | ||||||
|     let commentCount: Int |     let commentCount: Int | ||||||
|     let commentList: [GetAudioContentCommentListItem] |     let commentList: [GetAudioContentCommentListItem] | ||||||
|  |     let isShowSecret: Bool | ||||||
|      |      | ||||||
|     let registerComment: (String) -> Void |     let registerComment: (String, Bool) -> Void | ||||||
|      |      | ||||||
|     @State private var comment = "" |     @State private var comment = "" | ||||||
|  |     @State private var isSecret = false | ||||||
|      |      | ||||||
|     var body: some View { |     var body: some View { | ||||||
|         VStack(alignment: .leading, spacing: 10.3) { |         VStack(alignment: .leading, spacing: 10.3) { | ||||||
| @@ -26,9 +28,24 @@ struct ContentDetailCommentView: View { | |||||||
|                  |                  | ||||||
|                 Text("\(commentCount)") |                 Text("\(commentCount)") | ||||||
|                     .font(.custom(Font.medium.rawValue, size: 12)) |                     .font(.custom(Font.medium.rawValue, size: 12)) | ||||||
|                     .foregroundColor(Color(hex: "909090")) |                     .foregroundColor(Color.gray90) | ||||||
|                  |                  | ||||||
|                 Spacer() |                 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) { |             HStack(spacing: 8) { | ||||||
| @@ -48,7 +65,7 @@ struct ContentDetailCommentView: View { | |||||||
|                 if commentCount > 0 { |                 if commentCount > 0 { | ||||||
|                     Text(commentList[0].comment) |                     Text(commentList[0].comment) | ||||||
|                         .font(.custom(Font.medium.rawValue, size: 12)) |                         .font(.custom(Font.medium.rawValue, size: 12)) | ||||||
|                         .foregroundColor(Color(hex: "bbbbbb")) |                         .foregroundColor(Color.graybb) | ||||||
|                         .lineLimit(1) |                         .lineLimit(1) | ||||||
|                         .lineSpacing(8) |                         .lineSpacing(8) | ||||||
|                         .padding(.leading, 3) |                         .padding(.leading, 3) | ||||||
| @@ -58,8 +75,8 @@ struct ContentDetailCommentView: View { | |||||||
|                             .autocapitalization(.none) |                             .autocapitalization(.none) | ||||||
|                             .disableAutocorrection(true) |                             .disableAutocorrection(true) | ||||||
|                             .font(.custom(Font.medium.rawValue, size: 13.3)) |                             .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||||
|                             .foregroundColor(Color(hex: "eeeeee")) |                             .foregroundColor(Color.grayee) | ||||||
|                             .accentColor(Color(hex: "3bb9f1")) |                             .accentColor(Color.button) | ||||||
|                             .keyboardType(.default) |                             .keyboardType(.default) | ||||||
|                             .padding(.horizontal, 13.3) |                             .padding(.horizontal, 13.3) | ||||||
|                          |                          | ||||||
| @@ -71,15 +88,15 @@ struct ContentDetailCommentView: View { | |||||||
|                             .padding(6.7) |                             .padding(6.7) | ||||||
|                             .onTapGesture { |                             .onTapGesture { | ||||||
|                                 hideKeyboard() |                                 hideKeyboard() | ||||||
|                                 registerComment(comment) |                                 registerComment(comment, isSecret) | ||||||
|                             } |                             } | ||||||
|                     } |                     } | ||||||
|                     .background(Color(hex: "232323")) |                     .background(Color.gray23) | ||||||
|                     .cornerRadius(10) |                     .cornerRadius(10) | ||||||
|                     .overlay( |                     .overlay( | ||||||
|                         RoundedRectangle(cornerRadius: 10) |                         RoundedRectangle(cornerRadius: 10) | ||||||
|                             .strokeBorder(lineWidth: 1) |                             .strokeBorder(lineWidth: 1) | ||||||
|                             .foregroundColor(Color(hex: "3bb9f1")) |                             .foregroundColor(Color.button) | ||||||
|                     ) |                     ) | ||||||
|                 } |                 } | ||||||
|                  |                  | ||||||
|   | |||||||
| @@ -11,4 +11,5 @@ struct RegisterAudioContentCommentRequest: Encodable { | |||||||
|     let comment: String |     let comment: String | ||||||
|     let contentId: Int |     let contentId: Int | ||||||
|     let parentId: Int? |     let parentId: Int? | ||||||
|  |     let isSecret: Bool | ||||||
| } | } | ||||||
|   | |||||||
| @@ -136,8 +136,9 @@ struct ContentDetailView: View { | |||||||
|                                             ContentDetailCommentView( |                                             ContentDetailCommentView( | ||||||
|                                                 commentCount: audioContent.commentCount, |                                                 commentCount: audioContent.commentCount, | ||||||
|                                                 commentList: audioContent.commentList, |                                                 commentList: audioContent.commentList, | ||||||
|                                                 registerComment: { comment in |                                                 isShowSecret: audioContent.existOrdered, | ||||||
|                                                     self.viewModel.registerComment(comment: comment) |                                                 registerComment: { comment, isSecret in | ||||||
|  |                                                     self.viewModel.registerComment(comment: comment, isSecret: isSecret) | ||||||
|                                                 } |                                                 } | ||||||
|                                             ) |                                             ) | ||||||
|                                             .padding(10.3) |                                             .padding(10.3) | ||||||
|   | |||||||
| @@ -239,14 +239,14 @@ final class ContentDetailViewModel: ObservableObject { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     func registerComment(comment: String) { |     func registerComment(comment: String, isSecret: Bool) { | ||||||
|         if comment.trimmingCharacters(in: .whitespaces).isEmpty { |         if comment.trimmingCharacters(in: .whitespaces).isEmpty { | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         isLoading = true |         isLoading = true | ||||||
|          |          | ||||||
|         repository.registerComment(audioContentId: contentId, comment: comment) |         repository.registerComment(audioContentId: contentId, comment: comment, isSecret: isSecret) | ||||||
|             .sink { result in |             .sink { result in | ||||||
|                 switch result { |                 switch result { | ||||||
|                 case .finished: |                 case .finished: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung