diff --git a/SodaLive/Sources/Live/Room/Dialog/LiveRoomInfoEditDialog.swift b/SodaLive/Sources/Live/Room/Dialog/LiveRoomInfoEditDialog.swift index 1039e9d..3e88f01 100644 --- a/SodaLive/Sources/Live/Room/Dialog/LiveRoomInfoEditDialog.swift +++ b/SodaLive/Sources/Live/Room/Dialog/LiveRoomInfoEditDialog.swift @@ -16,6 +16,7 @@ struct LiveRoomInfoEditDialog: View { @State private var title = "" @State private var notice = "" @State private var isAdult = false + @State private var isEntryMessageEnabled = true let placeholder = "라이브 공지를 입력하세요" @@ -24,19 +25,20 @@ struct LiveRoomInfoEditDialog: View { let isLoading: Bool let coverImageUrl: String? let coverImage: UIImage? - var confirmAction: (String, String, Bool) -> Void + var confirmAction: (String, String, Bool, Bool) -> Void init( isShowing: Binding, isShowPhotoPicker: Binding, viewModel: LiveRoomViewModel, isAdult: Bool, + isEntryMessageEnabled: Bool, isLoading: Bool, currentTitle: String, currentNotice: String, coverImageUrl: String, coverImage: UIImage?, - confirmAction: @escaping (String, String, Bool) -> Void + confirmAction: @escaping (String, String, Bool, Bool) -> Void ) { self._isShowing = isShowing self._isShowPhotoPicker = isShowPhotoPicker @@ -44,6 +46,7 @@ struct LiveRoomInfoEditDialog: View { self._viewModel = StateObject(wrappedValue: viewModel) self.isLoading = isLoading self.isAdult = isAdult + self.isEntryMessageEnabled = isEntryMessageEnabled self.title = currentTitle self.notice = currentNotice @@ -159,6 +162,22 @@ struct LiveRoomInfoEditDialog: View { ) .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) { Text("취소") .font(.custom(Font.bold.rawValue, size: 18.3)) @@ -187,7 +206,8 @@ struct LiveRoomInfoEditDialog: View { confirmAction( title, notice.trimmingCharacters(in: .whitespacesAndNewlines) != placeholder ? notice : "", - isAdult + isAdult, + isEntryMessageEnabled ) isShowing = false } diff --git a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift index 28ffe10..d000938 100644 --- a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift +++ b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift @@ -129,6 +129,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject { @Published var isBgOn = true @Published var isSignatureOn = true + @Published var isEntryMessageEnabled = true @Published var donationStatus: GetLiveRoomDonationStatusResponse? @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) { - self.errorMessage = "변경사항이 없습니다." - self.isShowErrorPopup = true return } @@ -2273,7 +2272,7 @@ extension LiveRoomViewModel: AgoraRtmChannelDelegate { func channel(_ channel: AgoraRtmChannel, memberJoined member: AgoraRtmMember) { 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 self.messages.append(LiveRoomJoinChat(nickname: nickname)) self.messageChangeFlag.toggle() diff --git a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift index fc0c1e8..7e6aeab 100644 --- a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift +++ b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift @@ -731,17 +731,19 @@ struct LiveRoomViewV2: View { isShowPhotoPicker: $viewModel.isShowPhotoPicker, viewModel: viewModel, isAdult: liveRoomInfo.isAdult, + isEntryMessageEnabled: viewModel.isEntryMessageEnabled, isLoading: viewModel.isLoading, currentTitle: liveRoomInfo.title, currentNotice: liveRoomInfo.notice, coverImageUrl: liveRoomInfo.coverImageUrl, coverImage: viewModel.coverImage - ) { newTitle, newNotice, isAdult in + ) { newTitle, newNotice, isAdult, isEntryMessageEnabled in self.viewModel.editLiveRoomInfo( title: newTitle, notice: newNotice, isAdult: isAdult ) + self.viewModel.isEntryMessageEnabled = isEntryMessageEnabled } } else { EmptyView()