parent
8aa69f02fc
commit
3db59e6236
|
@ -42,13 +42,13 @@ struct SodaDialog: View {
|
|||
VStack(spacing: 0) {
|
||||
Text(title)
|
||||
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
.foregroundColor(Color.graybb)
|
||||
.padding(.top, 40)
|
||||
|
||||
Text(desc)
|
||||
.font(.custom(Font.medium.rawValue, size: 15))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(Color.graybb)
|
||||
.multilineTextAlignment(.leading)
|
||||
.padding(.top, 12)
|
||||
.padding(.horizontal, 13.3)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
@ -57,14 +57,14 @@ struct SodaDialog: View {
|
|||
if cancelButtonTitle.count > 0 {
|
||||
Text(cancelButtonTitle)
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "3bb9f1"))
|
||||
.foregroundColor(Color.button)
|
||||
.padding(.vertical, 16)
|
||||
.frame(width: (geo.size.width - 66.7) / 3)
|
||||
.background(Color(hex: "13181b"))
|
||||
.background(Color.bg)
|
||||
.cornerRadius(8)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.stroke(Color(hex: "3bb9f1"), lineWidth: 1)
|
||||
.stroke(Color.button, lineWidth: 1)
|
||||
)
|
||||
.onTapGesture {
|
||||
cancelButtonAction()
|
||||
|
@ -73,10 +73,10 @@ struct SodaDialog: View {
|
|||
|
||||
Text(confirmButtonTitle)
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "ffffff"))
|
||||
.foregroundColor(Color.white)
|
||||
.padding(.vertical, 16)
|
||||
.frame(width: (geo.size.width - 66.7) * 2 / 3)
|
||||
.background(Color(hex: "3bb9f1"))
|
||||
.background(Color.button)
|
||||
.cornerRadius(8)
|
||||
.onTapGesture {
|
||||
confirmButtonAction()
|
||||
|
@ -86,7 +86,7 @@ struct SodaDialog: View {
|
|||
.padding(.bottom, 16.7)
|
||||
}
|
||||
.frame(width: geo.size.width - 26.7, alignment: .center)
|
||||
.background(Color(hex: "222222"))
|
||||
.background(Color.gray22)
|
||||
.cornerRadius(10)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ struct LiveRoomInfoEditDialog: View {
|
|||
|
||||
@State private var title = ""
|
||||
@State private var notice = ""
|
||||
@State private var isAdult = false
|
||||
|
||||
let placeholder = "라이브 공지를 입력하세요"
|
||||
|
||||
|
@ -23,24 +24,26 @@ struct LiveRoomInfoEditDialog: View {
|
|||
let isLoading: Bool
|
||||
let coverImageUrl: String?
|
||||
let coverImage: UIImage?
|
||||
var confirmAction: (String, String) -> Void
|
||||
var confirmAction: (String, String, Bool) -> Void
|
||||
|
||||
init(
|
||||
isShowing: Binding<Bool>,
|
||||
isShowPhotoPicker: Binding<Bool>,
|
||||
viewModel: LiveRoomViewModel,
|
||||
isAdult: Bool,
|
||||
isLoading: Bool,
|
||||
currentTitle: String,
|
||||
currentNotice: String,
|
||||
coverImageUrl: String,
|
||||
coverImage: UIImage?,
|
||||
confirmAction: @escaping (String, String) -> Void
|
||||
confirmAction: @escaping (String, String, Bool) -> Void
|
||||
) {
|
||||
self._isShowing = isShowing
|
||||
self._isShowPhotoPicker = isShowPhotoPicker
|
||||
|
||||
self._viewModel = StateObject(wrappedValue: viewModel)
|
||||
self.isLoading = isLoading
|
||||
self.isAdult = isAdult
|
||||
|
||||
self.title = currentTitle
|
||||
self.notice = currentNotice
|
||||
|
@ -116,6 +119,30 @@ struct LiveRoomInfoEditDialog: View {
|
|||
ContentInputView()
|
||||
.padding(.top, 33.3)
|
||||
|
||||
if UserDefaults.bool(forKey: .auth) {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("연령제한")
|
||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||
.foregroundColor(Color.grayee)
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text("19세 이상")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color.grayee)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(isAdult ? "btn_toggle_on_big" : "btn_toggle_off_big")
|
||||
.resizable()
|
||||
.frame(width: 33.3, height: 20)
|
||||
.onTapGesture {
|
||||
isAdult.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 33.3)
|
||||
}
|
||||
|
||||
LiveRoomMenuSelectView(
|
||||
menu: $viewModel.menu,
|
||||
isActivate: $viewModel.isActivateMenu,
|
||||
|
@ -152,7 +179,8 @@ struct LiveRoomInfoEditDialog: View {
|
|||
.onTapGesture {
|
||||
confirmAction(
|
||||
title,
|
||||
notice.trimmingCharacters(in: .whitespacesAndNewlines) != placeholder ? notice : ""
|
||||
notice.trimmingCharacters(in: .whitespacesAndNewlines) != placeholder ? notice : "",
|
||||
isAdult
|
||||
)
|
||||
isShowing = false
|
||||
}
|
||||
|
@ -169,7 +197,7 @@ struct LiveRoomInfoEditDialog: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.background(Color(hex: "222222").edgesIgnoringSafeArea(.all))
|
||||
.background(Color.gray22.edgesIgnoringSafeArea(.all))
|
||||
|
||||
if viewModel.isShowPopup {
|
||||
LiveRoomDialogView(
|
||||
|
@ -198,7 +226,7 @@ struct LiveRoomInfoEditDialog: View {
|
|||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text("제목")
|
||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.foregroundColor(Color.grayee)
|
||||
|
||||
TextField("라이브 제목을 입력하세요", text: $title)
|
||||
.autocapitalization(.none)
|
||||
|
|
|
@ -16,4 +16,5 @@ struct EditLiveRoomInfoRequest: Encodable {
|
|||
var menuPanId: Int = 0
|
||||
var menuPan: String = ""
|
||||
var isActiveMenuPan: Bool? = nil
|
||||
var isAdult: Bool? = nil
|
||||
}
|
||||
|
|
|
@ -43,6 +43,13 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
|||
@Published var isShowReportPopup = false
|
||||
@Published var isShowErrorPopup = false
|
||||
@Published var isShowUserProfilePopup = false
|
||||
@Published var changeIsAdult = false {
|
||||
didSet {
|
||||
if changeIsAdult && !UserDefaults.bool(forKey: .auth) {
|
||||
agora.speakerMute(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published var popupContent = ""
|
||||
@Published var popupCancelTitle: String? = nil
|
||||
|
@ -342,6 +349,10 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
|||
|
||||
getTotalDonationCan()
|
||||
|
||||
if data.isAdult && !UserDefaults.bool(forKey: .auth) {
|
||||
changeIsAdult = true
|
||||
}
|
||||
|
||||
if (userId > 0 && data.creatorId == UserDefaults.int(forKey: .userId)) {
|
||||
let nickname = getUserNicknameAndProfileUrl(accountId: userId).nickname
|
||||
onSuccess(nickname)
|
||||
|
@ -707,7 +718,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
|||
agora.sendMessageToPeer(peerId: peerId, rawMessage: LiveRoomRequestType.REQUEST_SPEAKER_ALLOW.rawValue.data(using: .utf8)!, completion: nil)
|
||||
}
|
||||
|
||||
func editLiveRoomInfo(title: String, notice: String) {
|
||||
func editLiveRoomInfo(title: String, notice: String, isAdult: Bool) {
|
||||
let request = EditLiveRoomInfoRequest(
|
||||
title: liveRoomInfo!.title != title ? title : nil,
|
||||
notice: liveRoomInfo!.notice != notice ? notice : nil,
|
||||
|
@ -716,10 +727,11 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
|||
timezone: nil,
|
||||
menuPanId: isActivateMenu ? menuId : 0,
|
||||
menuPan: isActivateMenu ? menu : "",
|
||||
isActiveMenuPan: isActivateMenu
|
||||
isActiveMenuPan: isActivateMenu,
|
||||
isAdult: liveRoomInfo!.isAdult != isAdult ? isAdult : nil
|
||||
)
|
||||
|
||||
if (request.title == nil && request.notice == nil && coverImage == nil && menu == liveRoomInfo?.menuPan) {
|
||||
if (request.title == nil && request.notice == nil && coverImage == nil && menu == liveRoomInfo?.menuPan && request.isAdult == nil) {
|
||||
self.errorMessage = "변경사항이 없습니다."
|
||||
self.isShowErrorPopup = true
|
||||
return
|
||||
|
@ -730,7 +742,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
|||
let encoder = JSONEncoder()
|
||||
encoder.outputFormatting = .withoutEscapingSlashes
|
||||
|
||||
if (request.title != nil || request.notice != nil || menu != liveRoomInfo?.menuPan) {
|
||||
if (request.title != nil || request.notice != nil || request.isAdult != nil || menu != liveRoomInfo?.menuPan) {
|
||||
let jsonData = try? encoder.encode(request)
|
||||
if let jsonData = jsonData {
|
||||
multipartData.append(MultipartFormData(provider: .data(jsonData), name: "request"))
|
||||
|
|
|
@ -151,16 +151,18 @@ struct LiveRoomViewV2: View {
|
|||
ScrollView(.vertical, showsIndicators: false) {
|
||||
scrollObservableView
|
||||
|
||||
LiveRoomChatView(messages: viewModel.messages) {
|
||||
if $0 != UserDefaults.int(forKey: .userId) {
|
||||
viewModel.getUserProfile(userId: $0)
|
||||
if !viewModel.changeIsAdult || UserDefaults.bool(forKey: .auth) {
|
||||
LiveRoomChatView(messages: viewModel.messages) {
|
||||
if $0 != UserDefaults.int(forKey: .userId) {
|
||||
viewModel.getUserProfile(userId: $0)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: screenSize().width)
|
||||
.rotationEffect(Angle(degrees: 180))
|
||||
.valueChanged(value: viewModel.messageChangeFlag) { _ in
|
||||
if viewModel.offset - viewModel.originOffset > (56.7 * 2) {
|
||||
viewModel.isShowingNewChat = true
|
||||
.frame(width: screenSize().width)
|
||||
.rotationEffect(Angle(degrees: 180))
|
||||
.valueChanged(value: viewModel.messageChangeFlag) { _ in
|
||||
if viewModel.offset - viewModel.originOffset > (56.7 * 2) {
|
||||
viewModel.isShowingNewChat = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,6 +400,17 @@ struct LiveRoomViewV2: View {
|
|||
}
|
||||
}
|
||||
|
||||
if viewModel.changeIsAdult && !UserDefaults.bool(forKey: .auth) {
|
||||
SodaDialog(
|
||||
title: "알림",
|
||||
desc: "지금 참여하던 라이브는 '19세 이상' 연령제한이 설정되어 정보통신망 이용촉진 및 정보 보호 등에 관한 법률 및 청소년 보호법의 규정에 의해 만 19세 미만의 청소년은 이용할 수 없습니다.\n마이페이지에서 본인인증 후 다시 이용하시기 바랍니다.",
|
||||
confirmButtonTitle: "확인",
|
||||
confirmButtonAction: {
|
||||
viewModel.quitRoom()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if viewModel.isShowQuitPopup {
|
||||
SodaDialog(
|
||||
title: "라이브 나가기",
|
||||
|
@ -646,15 +659,17 @@ struct LiveRoomViewV2: View {
|
|||
isShowing: $viewModel.isShowEditRoomInfoDialog,
|
||||
isShowPhotoPicker: $viewModel.isShowPhotoPicker,
|
||||
viewModel: viewModel,
|
||||
isAdult: liveRoomInfo.isAdult,
|
||||
isLoading: viewModel.isLoading,
|
||||
currentTitle: liveRoomInfo.title,
|
||||
currentNotice: liveRoomInfo.notice,
|
||||
coverImageUrl: liveRoomInfo.coverImageUrl,
|
||||
coverImage: viewModel.coverImage
|
||||
) { newTitle, newNotice in
|
||||
) { newTitle, newNotice, isAdult in
|
||||
self.viewModel.editLiveRoomInfo(
|
||||
title: newTitle,
|
||||
notice: newNotice
|
||||
notice: newNotice,
|
||||
isAdult: isAdult
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue