커뮤니티 게시물 신고 하기 추가
This commit is contained in:
parent
302f69b265
commit
9f360e9fcd
|
@ -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,62 +11,114 @@ 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 {
|
||||||
BaseView(isLoading: $viewModel.isLoading) {
|
GeometryReader { proxy in
|
||||||
VStack(spacing: 0) {
|
BaseView(isLoading: $viewModel.isLoading) {
|
||||||
DetailNavigationBar(title: "커뮤니티")
|
VStack(spacing: 0) {
|
||||||
|
DetailNavigationBar(title: "커뮤니티")
|
||||||
ScrollView(.vertical, showsIndicators: false) {
|
|
||||||
LazyVStack(spacing: 26.7) {
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
ForEach(0..<viewModel.communityPostList.count, id: \.self) { index in
|
LazyVStack(spacing: 26.7) {
|
||||||
let item = viewModel.communityPostList[index]
|
ForEach(0..<viewModel.communityPostList.count, id: \.self) { index in
|
||||||
CreatorCommunityAllItemView(
|
let item = viewModel.communityPostList[index]
|
||||||
item: item,
|
CreatorCommunityAllItemView(
|
||||||
onClickLike: {
|
item: item,
|
||||||
viewModel.communityPostLike(postId: item.postId)
|
onClickLike: {
|
||||||
},
|
viewModel.communityPostLike(postId: item.postId)
|
||||||
onClickComment: {
|
},
|
||||||
viewModel.postId = item.postId
|
onClickComment: {
|
||||||
},
|
viewModel.postId = item.postId
|
||||||
onClickWriteComment: { comment in
|
viewModel.isShowCommentListView = true
|
||||||
viewModel.createCommunityPostComment(
|
},
|
||||||
comment: comment,
|
onClickWriteComment: { comment in
|
||||||
postId: item.postId
|
viewModel.createCommunityPostComment(
|
||||||
)
|
comment: comment,
|
||||||
}
|
postId: item.postId
|
||||||
)
|
)
|
||||||
.onAppear {
|
},
|
||||||
if index == viewModel.communityPostList.count - 1 {
|
onClickShowReportMenu: {
|
||||||
viewModel.getCommunityPostList()
|
viewModel.postId = item.postId
|
||||||
|
viewModel.isShowReportMenu = true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.onAppear {
|
||||||
|
if index == viewModel.communityPostList.count - 1 {
|
||||||
|
viewModel.getCommunityPostList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.padding(5.3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.sheet(
|
||||||
|
isPresented: $viewModel.isShowCommentListView,
|
||||||
|
content: {
|
||||||
|
CreatorCommunityCommentListView(
|
||||||
|
isPresented: $viewModel.isShowCommentListView,
|
||||||
|
creatorId: creatorId,
|
||||||
|
postId: viewModel.postId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
ZStack {
|
||||||
|
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 {
|
||||||
}
|
}
|
||||||
.padding(5.3)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(
|
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
|
||||||
isPresented: $viewModel.isShowCommentListView,
|
GeometryReader { geo in
|
||||||
content: {
|
HStack {
|
||||||
CreatorCommunityCommentListView(
|
Spacer()
|
||||||
isPresented: $viewModel.isShowCommentListView,
|
Text(viewModel.errorMessage)
|
||||||
creatorId: creatorId,
|
.padding(.vertical, 13.3)
|
||||||
postId: viewModel.postId
|
.frame(width: screenSize().width - 66.7, alignment: .center)
|
||||||
)
|
.font(.custom(Font.medium.rawValue, size: 12))
|
||||||
}
|
.background(Color(hex: "9970ff"))
|
||||||
)
|
.foregroundColor(Color.white)
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
if isShowingReportView {
|
.cornerRadius(20)
|
||||||
CreatorCommunityReportView(isShowing: $isShowingReportView) { _ in
|
.padding(.top, 66.7)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
.onAppear {
|
||||||
.onAppear {
|
viewModel.creatorId = creatorId
|
||||||
viewModel.creatorId = creatorId
|
viewModel.getCommunityPostList()
|
||||||
viewModel.getCommunityPostList()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue