라이브 입장 메시지 on/off 스위치 추가

- 라이브 정보 수정 가장 아래에 입장 메시지 on/off 스위치 추가
This commit is contained in:
Yu Sung 2025-04-15 13:34:27 +09:00
parent d09ffe1973
commit a7b3c9d5e7
3 changed files with 28 additions and 7 deletions

View File

@ -16,6 +16,7 @@ struct LiveRoomInfoEditDialog: View {
@State private var title = "" @State private var title = ""
@State private var notice = "" @State private var notice = ""
@State private var isAdult = false @State private var isAdult = false
@State private var isEntryMessageEnabled = true
let placeholder = "라이브 공지를 입력하세요" let placeholder = "라이브 공지를 입력하세요"
@ -24,19 +25,20 @@ struct LiveRoomInfoEditDialog: View {
let isLoading: Bool let isLoading: Bool
let coverImageUrl: String? let coverImageUrl: String?
let coverImage: UIImage? let coverImage: UIImage?
var confirmAction: (String, String, Bool) -> Void var confirmAction: (String, String, Bool, Bool) -> Void
init( init(
isShowing: Binding<Bool>, isShowing: Binding<Bool>,
isShowPhotoPicker: Binding<Bool>, isShowPhotoPicker: Binding<Bool>,
viewModel: LiveRoomViewModel, viewModel: LiveRoomViewModel,
isAdult: Bool, isAdult: Bool,
isEntryMessageEnabled: Bool,
isLoading: Bool, isLoading: Bool,
currentTitle: String, currentTitle: String,
currentNotice: String, currentNotice: String,
coverImageUrl: String, coverImageUrl: String,
coverImage: UIImage?, coverImage: UIImage?,
confirmAction: @escaping (String, String, Bool) -> Void confirmAction: @escaping (String, String, Bool, Bool) -> Void
) { ) {
self._isShowing = isShowing self._isShowing = isShowing
self._isShowPhotoPicker = isShowPhotoPicker self._isShowPhotoPicker = isShowPhotoPicker
@ -44,6 +46,7 @@ struct LiveRoomInfoEditDialog: View {
self._viewModel = StateObject(wrappedValue: viewModel) self._viewModel = StateObject(wrappedValue: viewModel)
self.isLoading = isLoading self.isLoading = isLoading
self.isAdult = isAdult self.isAdult = isAdult
self.isEntryMessageEnabled = isEntryMessageEnabled
self.title = currentTitle self.title = currentTitle
self.notice = currentNotice self.notice = currentNotice
@ -159,6 +162,22 @@ struct LiveRoomInfoEditDialog: View {
) )
.padding(.top, 33.3) .padding(.top, 33.3)
HStack(spacing: 0) {
Text("입장메시지")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color.grayee)
Spacer()
Image(isEntryMessageEnabled ? "btn_toggle_on_big" : "btn_toggle_off_big")
.resizable()
.frame(width: 33.3, height: 20)
.onTapGesture {
isEntryMessageEnabled.toggle()
}
}
.padding(.top, 33.3)
HStack(spacing: 13.3) { HStack(spacing: 13.3) {
Text("취소") Text("취소")
.font(.custom(Font.bold.rawValue, size: 18.3)) .font(.custom(Font.bold.rawValue, size: 18.3))
@ -187,7 +206,8 @@ struct LiveRoomInfoEditDialog: View {
confirmAction( confirmAction(
title, title,
notice.trimmingCharacters(in: .whitespacesAndNewlines) != placeholder ? notice : "", notice.trimmingCharacters(in: .whitespacesAndNewlines) != placeholder ? notice : "",
isAdult isAdult,
isEntryMessageEnabled
) )
isShowing = false isShowing = false
} }

View File

@ -129,6 +129,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
@Published var isBgOn = true @Published var isBgOn = true
@Published var isSignatureOn = true @Published var isSignatureOn = true
@Published var isEntryMessageEnabled = true
@Published var donationStatus: GetLiveRoomDonationStatusResponse? @Published var donationStatus: GetLiveRoomDonationStatusResponse?
@Published var heartStatus: GetLiveRoomHeartListResponse? @Published var heartStatus: GetLiveRoomHeartListResponse?
@ -762,8 +763,6 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
) )
if (request.title == nil && request.notice == nil && coverImage == nil && menu == liveRoomInfo?.menuPan && request.isAdult == nil) { if (request.title == nil && request.notice == nil && coverImage == nil && menu == liveRoomInfo?.menuPan && request.isAdult == nil) {
self.errorMessage = "변경사항이 없습니다."
self.isShowErrorPopup = true
return return
} }
@ -2273,7 +2272,7 @@ extension LiveRoomViewModel: AgoraRtmChannelDelegate {
func channel(_ channel: AgoraRtmChannel, memberJoined member: AgoraRtmMember) { func channel(_ channel: AgoraRtmChannel, memberJoined member: AgoraRtmMember) {
getRoomInfo(userId: Int(member.userId)!) { [unowned self] nickname in getRoomInfo(userId: Int(member.userId)!) { [unowned self] nickname in
if !nickname.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { if !nickname.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && isEntryMessageEnabled {
DispatchQueue.main.async { [unowned self] in DispatchQueue.main.async { [unowned self] in
self.messages.append(LiveRoomJoinChat(nickname: nickname)) self.messages.append(LiveRoomJoinChat(nickname: nickname))
self.messageChangeFlag.toggle() self.messageChangeFlag.toggle()

View File

@ -731,17 +731,19 @@ struct LiveRoomViewV2: View {
isShowPhotoPicker: $viewModel.isShowPhotoPicker, isShowPhotoPicker: $viewModel.isShowPhotoPicker,
viewModel: viewModel, viewModel: viewModel,
isAdult: liveRoomInfo.isAdult, isAdult: liveRoomInfo.isAdult,
isEntryMessageEnabled: viewModel.isEntryMessageEnabled,
isLoading: viewModel.isLoading, isLoading: viewModel.isLoading,
currentTitle: liveRoomInfo.title, currentTitle: liveRoomInfo.title,
currentNotice: liveRoomInfo.notice, currentNotice: liveRoomInfo.notice,
coverImageUrl: liveRoomInfo.coverImageUrl, coverImageUrl: liveRoomInfo.coverImageUrl,
coverImage: viewModel.coverImage coverImage: viewModel.coverImage
) { newTitle, newNotice, isAdult in ) { newTitle, newNotice, isAdult, isEntryMessageEnabled in
self.viewModel.editLiveRoomInfo( self.viewModel.editLiveRoomInfo(
title: newTitle, title: newTitle,
notice: newNotice, notice: newNotice,
isAdult: isAdult isAdult: isAdult
) )
self.viewModel.isEntryMessageEnabled = isEntryMessageEnabled
} }
} else { } else {
EmptyView() EmptyView()