feat(creator-channel): 차단·신고 메뉴를 연결한다

This commit is contained in:
Yu Sung
2026-08-14 16:41:33 +09:00
parent 080f36e690
commit 4b209dcd72
4 changed files with 197 additions and 1 deletions

View File

@@ -19,6 +19,10 @@ struct CreatorChannelView: View {
@State private var isShowChannelDonationDialog = false
@State private var isShowAuthView = false
@State private var isShowAuthConfirmView = false
@State private var isShowReportMenu = false
@State private var isShowUserBlockConfirm = false
@State private var isShowUserReport = false
@State private var isShowProfileReport = false
@State private var isCreatorActionMenuPresented = false
@State private var pendingAction: (() -> Void)? = nil
@State private var payload = Payload()
@@ -183,6 +187,56 @@ struct CreatorChannelView: View {
)
}
if viewModel.response != nil && isShowReportMenu {
VStack(spacing: 0) {
ProfileReportMenuView(
isShowing: $isShowReportMenu,
isBlockedUser: false,
userBlockAction: { isShowUserBlockConfirm = true },
userUnBlockAction: {},
userReportAction: { isShowUserReport = true },
profileReportAction: { isShowProfileReport = true }
)
if proxy.safeAreaInsets.bottom > 0 {
Rectangle()
.foregroundColor(Color(hex: "222222"))
.frame(width: proxy.size.width, height: 15.3)
}
}
.ignoresSafeArea()
}
if let creator = viewModel.response?.creator, isShowUserBlockConfirm {
UserBlockConfirmDialogView(
isShowing: $isShowUserBlockConfirm,
nickname: creator.nickname,
confirmAction: {
viewModel.userBlock(userId: creator.creatorId) {
dismiss()
}
}
)
}
if isShowUserReport {
UserReportDialogView(
isShowing: $isShowUserReport,
confirmAction: { reason in
viewModel.report(type: .USER, userId: creatorId, reason: reason)
}
)
}
if isShowProfileReport {
ProfileReportDialogView(
isShowing: $isShowProfileReport,
confirmAction: {
viewModel.report(type: .PROFILE, userId: creatorId)
}
)
}
communityOverlay(proxy: proxy)
}
}
@@ -227,7 +281,9 @@ struct CreatorChannelView: View {
onTapUnnotify: {
viewModel.creatorFollow(follow: true, notify: false)
},
onTapMore: {}
onTapMore: {
isShowReportMenu = true
}
)
}

View File

@@ -4,6 +4,7 @@ import Combine
final class CreatorChannelViewModel: ObservableObject {
private let repository = CreatorChannelHomeRepository()
private let userRepository = UserRepository()
private let reportRepository = ReportRepository()
private let communityRepository = CreatorCommunityRepository()
private var subscription = Set<AnyCancellable>()
@@ -156,6 +157,75 @@ final class CreatorChannelViewModel: ObservableObject {
.store(in: &subscription)
}
func userBlock(userId: Int, onSuccess: @escaping () -> Void) {
isLoading = true
userRepository.memberBlock(userId: userId)
.sink { [weak self] result in
switch result {
case .finished:
DEBUG_LOG("finish")
case .failure(let error):
ERROR_LOG(error.localizedDescription)
self?.isLoading = false
}
} receiveValue: { [weak self] response in
guard let self else { return }
do {
let jsonDecoder = JSONDecoder()
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: response.data)
if decoded.success {
onSuccess()
} else {
self.errorMessage = decoded.message ?? I18n.Common.commonError
self.isShowPopup = true
}
} catch {
ERROR_LOG(error.localizedDescription)
self.errorMessage = I18n.Common.commonError
self.isShowPopup = true
}
self.isLoading = false
}
.store(in: &subscription)
}
func report(type: ReportType, userId: Int? = nil, reason: String = I18n.Dialog.MemberProfile.reportProfile) {
isLoading = true
let request = ReportRequest(type: type, reason: reason, reportedMemberId: userId)
reportRepository.report(request: request)
.sink { [weak self] result in
switch result {
case .finished:
DEBUG_LOG("finish")
case .failure(let error):
ERROR_LOG(error.localizedDescription)
self?.isLoading = false
}
} receiveValue: { [weak self] response in
guard let self else { return }
do {
let jsonDecoder = JSONDecoder()
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: response.data)
self.errorMessage = decoded.message ?? I18n.Common.commonError
self.isShowPopup = true
} catch {
ERROR_LOG(error.localizedDescription)
self.errorMessage = I18n.Common.commonError
self.isShowPopup = true
}
self.isLoading = false
}
.store(in: &subscription)
}
private func applyApiFailedPlaceholderState() {
response = nil
isApiFailedPlaceholderVisible = true