커뮤니티 게시물 신고 하기 추가
This commit is contained in:
		| @@ -14,6 +14,7 @@ struct CreatorCommunityAllItemView: View { | |||||||
|     let onClickLike: () -> Void |     let onClickLike: () -> Void | ||||||
|     let onClickComment: () -> Void |     let onClickComment: () -> Void | ||||||
|     let onClickWriteComment: (String) -> Void |     let onClickWriteComment: (String) -> Void | ||||||
|  |     let onClickShowReportMenu: () -> Void | ||||||
|      |      | ||||||
|     @State var isExpandContent = false |     @State var isExpandContent = false | ||||||
|     @State var isLike = false |     @State var isLike = false | ||||||
| @@ -23,12 +24,14 @@ struct CreatorCommunityAllItemView: View { | |||||||
|         item: GetCommunityPostListResponse, |         item: GetCommunityPostListResponse, | ||||||
|         onClickLike: @escaping () -> Void, |         onClickLike: @escaping () -> Void, | ||||||
|         onClickComment: @escaping () -> Void, |         onClickComment: @escaping () -> Void, | ||||||
|         onClickWriteComment: @escaping (String) -> Void |         onClickWriteComment: @escaping (String) -> Void, | ||||||
|  |         onClickShowReportMenu: @escaping () -> Void | ||||||
|     ) { |     ) { | ||||||
|         self.item = item |         self.item = item | ||||||
|         self.onClickLike = onClickLike |         self.onClickLike = onClickLike | ||||||
|         self.onClickComment = onClickComment |         self.onClickComment = onClickComment | ||||||
|         self.onClickWriteComment = onClickWriteComment |         self.onClickWriteComment = onClickWriteComment | ||||||
|  |         self.onClickShowReportMenu = onClickShowReportMenu | ||||||
|          |          | ||||||
|         self._isLike = State(initialValue: item.isLike) |         self._isLike = State(initialValue: item.isLike) | ||||||
|         self._likeCount = State(initialValue: item.likeCount) |         self._likeCount = State(initialValue: item.likeCount) | ||||||
| @@ -57,7 +60,7 @@ struct CreatorCommunityAllItemView: View { | |||||||
|                  |                  | ||||||
|                 Image("ic_seemore_vertical") |                 Image("ic_seemore_vertical") | ||||||
|                     .padding(.trailing, 8.3) |                     .padding(.trailing, 8.3) | ||||||
|                     .onTapGesture {} |                     .onTapGesture { onClickShowReportMenu() } | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             Text(item.content) |             Text(item.content) | ||||||
| @@ -129,7 +132,8 @@ struct CreatorCommunityAllItemView_Previews: PreviewProvider { | |||||||
|             ), |             ), | ||||||
|             onClickLike: {}, |             onClickLike: {}, | ||||||
|             onClickComment: {}, |             onClickComment: {}, | ||||||
|             onClickWriteComment: { _ in } |             onClickWriteComment: { _ in }, | ||||||
|  |             onClickShowReportMenu: {} | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -11,10 +11,10 @@ struct CreatorCommunityAllView: View { | |||||||
|      |      | ||||||
|     let creatorId: Int |     let creatorId: Int | ||||||
|      |      | ||||||
|     @State private var isShowingReportView = false |  | ||||||
|     @StateObject var viewModel = CreatorCommunityAllViewModel() |     @StateObject var viewModel = CreatorCommunityAllViewModel() | ||||||
|      |      | ||||||
|     var body: some View { |     var body: some View { | ||||||
|  |         GeometryReader { proxy in | ||||||
|             BaseView(isLoading: $viewModel.isLoading) { |             BaseView(isLoading: $viewModel.isLoading) { | ||||||
|                 VStack(spacing: 0) { |                 VStack(spacing: 0) { | ||||||
|                     DetailNavigationBar(title: "커뮤니티") |                     DetailNavigationBar(title: "커뮤니티") | ||||||
| @@ -30,12 +30,17 @@ struct CreatorCommunityAllView: View { | |||||||
|                                     }, |                                     }, | ||||||
|                                     onClickComment: { |                                     onClickComment: { | ||||||
|                                         viewModel.postId = item.postId |                                         viewModel.postId = item.postId | ||||||
|  |                                         viewModel.isShowCommentListView = true | ||||||
|                                     }, |                                     }, | ||||||
|                                     onClickWriteComment: { comment in |                                     onClickWriteComment: { comment in | ||||||
|                                         viewModel.createCommunityPostComment( |                                         viewModel.createCommunityPostComment( | ||||||
|                                             comment: comment, |                                             comment: comment, | ||||||
|                                             postId: item.postId |                                             postId: item.postId | ||||||
|                                         ) |                                         ) | ||||||
|  |                                     }, | ||||||
|  |                                     onClickShowReportMenu: { | ||||||
|  |                                         viewModel.postId = item.postId | ||||||
|  |                                         viewModel.isShowReportMenu = true | ||||||
|                                     } |                                     } | ||||||
|                                 ) |                                 ) | ||||||
|                                 .onAppear { |                                 .onAppear { | ||||||
| @@ -59,8 +64,54 @@ struct CreatorCommunityAllView: View { | |||||||
|                     } |                     } | ||||||
|                 ) |                 ) | ||||||
|                  |                  | ||||||
|             if isShowingReportView { |                 ZStack { | ||||||
|                 CreatorCommunityReportView(isShowing: $isShowingReportView) { _ in |                     if viewModel.isShowReportMenu { | ||||||
|  |                         VStack(spacing: 0) { | ||||||
|  |                             ContentDetailMenuView( | ||||||
|  |                                 isShowing: $viewModel.isShowReportMenu, | ||||||
|  |                                 isShowCreatorMenu: creatorId == UserDefaults.int(forKey: .userId), | ||||||
|  |                                 modifyAction: { | ||||||
|  |                                 }, | ||||||
|  |                                 deleteAction: { | ||||||
|  |                                 }, | ||||||
|  |                                 reportAction: { | ||||||
|  |                                     viewModel.isShowReportView = true | ||||||
|  |                                 } | ||||||
|  |                             ) | ||||||
|  |                              | ||||||
|  |                             if proxy.safeAreaInsets.bottom > 0 { | ||||||
|  |                                 Rectangle() | ||||||
|  |                                     .foregroundColor(Color(hex: "222222")) | ||||||
|  |                                     .frame(width: proxy.size.width, height: 15.3) | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                         .ignoresSafeArea() | ||||||
|  |                     } | ||||||
|  |                      | ||||||
|  |                     if viewModel.isShowReportView { | ||||||
|  |                         CreatorCommunityReportView(isShowing: $viewModel.isShowReportView) { reason in | ||||||
|  |                             viewModel.report(reason: reason) | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                      | ||||||
|  |                     if viewModel.isShowDeleteConfirm { | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             .popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) { | ||||||
|  |                 GeometryReader { geo in | ||||||
|  |                     HStack { | ||||||
|  |                         Spacer() | ||||||
|  |                         Text(viewModel.errorMessage) | ||||||
|  |                             .padding(.vertical, 13.3) | ||||||
|  |                             .frame(width: screenSize().width - 66.7, alignment: .center) | ||||||
|  |                             .font(.custom(Font.medium.rawValue, size: 12)) | ||||||
|  |                             .background(Color(hex: "9970ff")) | ||||||
|  |                             .foregroundColor(Color.white) | ||||||
|  |                             .multilineTextAlignment(.center) | ||||||
|  |                             .cornerRadius(20) | ||||||
|  |                             .padding(.top, 66.7) | ||||||
|  |                         Spacer() | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -69,6 +120,7 @@ struct CreatorCommunityAllView: View { | |||||||
|                 viewModel.getCommunityPostList() |                 viewModel.getCommunityPostList() | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| struct CreatorCommunityAllView_Previews: PreviewProvider { | struct CreatorCommunityAllView_Previews: PreviewProvider { | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ import Combine | |||||||
|  |  | ||||||
| class CreatorCommunityAllViewModel: ObservableObject { | class CreatorCommunityAllViewModel: ObservableObject { | ||||||
|     private let repository = CreatorCommunityRepository() |     private let repository = CreatorCommunityRepository() | ||||||
|  |     private let reportRepository = ReportRepository() | ||||||
|     private var subscription = Set<AnyCancellable>() |     private var subscription = Set<AnyCancellable>() | ||||||
|      |      | ||||||
|     @Published var isLoading = false |     @Published var isLoading = false | ||||||
| @@ -19,13 +20,7 @@ class CreatorCommunityAllViewModel: ObservableObject { | |||||||
|     @Published var isShowPopup = false |     @Published var isShowPopup = false | ||||||
|     @Published private(set) var communityPostList = [GetCommunityPostListResponse]() |     @Published private(set) var communityPostList = [GetCommunityPostListResponse]() | ||||||
|      |      | ||||||
|     @Published var postId = 0 { |     @Published var postId = 0 | ||||||
|         didSet { |  | ||||||
|             if postId > 0 { |  | ||||||
|                 isShowCommentListView = true |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|      |      | ||||||
|     @Published var isShowCommentListView = false { |     @Published var isShowCommentListView = false { | ||||||
|         didSet { |         didSet { | ||||||
| @@ -35,6 +30,22 @@ class CreatorCommunityAllViewModel: ObservableObject { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     @Published var isShowReportMenu = false | ||||||
|  |     @Published var isShowReportView = false { | ||||||
|  |         didSet { | ||||||
|  |             if !isShowReportView { | ||||||
|  |                 postId = 0 | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     @Published var isShowDeleteConfirm = false { | ||||||
|  |         didSet { | ||||||
|  |             if !isShowDeleteConfirm { | ||||||
|  |                 postId = 0 | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|     var creatorId = 0 |     var creatorId = 0 | ||||||
|      |      | ||||||
|     var page = 1 |     var page = 1 | ||||||
| @@ -152,4 +163,39 @@ class CreatorCommunityAllViewModel: ObservableObject { | |||||||
|                 .store(in: &subscription) |                 .store(in: &subscription) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     func report(reason: String) { | ||||||
|  |         isLoading = true | ||||||
|  |          | ||||||
|  |         let request = ReportRequest(type: .COMMUNITY_POST, reason: reason, communityPostId: postId) | ||||||
|  |         reportRepository.report(request: request) | ||||||
|  |             .sink { result in | ||||||
|  |                 switch result { | ||||||
|  |                 case .finished: | ||||||
|  |                     DEBUG_LOG("finish") | ||||||
|  |                 case .failure(let error): | ||||||
|  |                     ERROR_LOG(error.localizedDescription) | ||||||
|  |                 } | ||||||
|  |             } receiveValue: { [unowned self] response in | ||||||
|  |                 self.isLoading = false | ||||||
|  |                 let responseData = response.data | ||||||
|  |                  | ||||||
|  |                 do { | ||||||
|  |                     let jsonDecoder = JSONDecoder() | ||||||
|  |                     let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) | ||||||
|  |                      | ||||||
|  |                     if let message = decoded.message { | ||||||
|  |                         self.errorMessage = message | ||||||
|  |                     } else { | ||||||
|  |                         self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." | ||||||
|  |                     } | ||||||
|  |                      | ||||||
|  |                     self.isShowPopup = true | ||||||
|  |                 } catch { | ||||||
|  |                     self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." | ||||||
|  |                     self.isShowPopup = true | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             .store(in: &subscription) | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -71,8 +71,8 @@ struct CreatorCommunityReportView: View { | |||||||
|                         .foregroundColor(Color(hex: "9970ff")) |                         .foregroundColor(Color(hex: "9970ff")) | ||||||
|                         .onTapGesture { |                         .onTapGesture { | ||||||
|                             if let selectedIndex = selectedIndex { |                             if let selectedIndex = selectedIndex { | ||||||
|                                 isShowing = false |  | ||||||
|                                 confirmAction(reasons[selectedIndex]) |                                 confirmAction(reasons[selectedIndex]) | ||||||
|  |                                 isShowing = false | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -10,12 +10,13 @@ import Foundation | |||||||
| struct ReportRequest: Encodable { | struct ReportRequest: Encodable { | ||||||
|     let type: ReportType |     let type: ReportType | ||||||
|     let reason: String |     let reason: String | ||||||
|     let reportedMemberId: Int? |     var reportedMemberId: Int? = nil | ||||||
|     let cheersId: Int? |     var cheersId: Int? = nil | ||||||
|     let audioContentId: Int? |     var audioContentId: Int? = nil | ||||||
|  |     var communityPostId: Int? = nil | ||||||
| } | } | ||||||
|  |  | ||||||
| enum ReportType: String, Codable { | enum ReportType: String, Codable { | ||||||
|     case PROFILE, USER, CHEERS, AUDIO_CONTENT |     case PROFILE, USER, CHEERS, AUDIO_CONTENT, COMMUNITY_POST | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung