parent
b6411c3ccb
commit
70460f5c8a
|
@ -352,7 +352,7 @@ struct LiveRoomCreateView: View {
|
||||||
text: $viewModel.content,
|
text: $viewModel.content,
|
||||||
placeholder: viewModel.placeholder,
|
placeholder: viewModel.placeholder,
|
||||||
textColorHex: "eeeeee",
|
textColorHex: "eeeeee",
|
||||||
backgroundColorHex: "222222"
|
backgroundColorHex: "303030"
|
||||||
)
|
)
|
||||||
.frame(width: screenSize().width - 26.7, height: 200)
|
.frame(width: screenSize().width - 26.7, height: 200)
|
||||||
.cornerRadius(6.7)
|
.cornerRadius(6.7)
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
|
|
||||||
let placeholder = "라이브 공지를 입력하세요"
|
let placeholder = "라이브 공지를 입력하세요"
|
||||||
|
|
||||||
let viewModel: LiveRoomViewModel
|
@StateObject var viewModel: LiveRoomViewModel
|
||||||
|
|
||||||
let isLoading: Bool
|
let isLoading: Bool
|
||||||
let coverImageUrl: String?
|
let coverImageUrl: String?
|
||||||
|
@ -39,7 +39,7 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
self._isShowing = isShowing
|
self._isShowing = isShowing
|
||||||
self._isShowPhotoPicker = isShowPhotoPicker
|
self._isShowPhotoPicker = isShowPhotoPicker
|
||||||
|
|
||||||
self.viewModel = viewModel
|
self._viewModel = StateObject(wrappedValue: viewModel)
|
||||||
self.isLoading = isLoading
|
self.isLoading = isLoading
|
||||||
|
|
||||||
self.title = currentTitle
|
self.title = currentTitle
|
||||||
|
@ -53,13 +53,12 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
GeometryReader { proxy in
|
|
||||||
ScrollView(.vertical, showsIndicators: false) {
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
Text("라이브 수정")
|
Text("라이브 수정")
|
||||||
.font(.custom(Font.bold.rawValue, size: 18.3))
|
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color.grayee)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
|
@ -92,13 +91,13 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
.resizable()
|
.resizable()
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
.frame(width: 80, height: 116.8)
|
.frame(width: 80, height: 116.8)
|
||||||
.background(Color(hex: "3e3358"))
|
.background(Color.bg)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
Image("ic_camera")
|
Image("ic_camera")
|
||||||
.padding(10)
|
.padding(10)
|
||||||
.background(Color(hex: "9970ff"))
|
.background(Color.button)
|
||||||
.cornerRadius(30)
|
.cornerRadius(30)
|
||||||
.offset(x: 40, y: 40)
|
.offset(x: 40, y: 40)
|
||||||
}
|
}
|
||||||
|
@ -117,18 +116,27 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
ContentInputView()
|
ContentInputView()
|
||||||
.padding(.top, 33.3)
|
.padding(.top, 33.3)
|
||||||
|
|
||||||
|
LiveRoomMenuSelectView(
|
||||||
|
menu: $viewModel.menu,
|
||||||
|
isActivate: $viewModel.isActivateMenu,
|
||||||
|
menuCount: viewModel.menuList.count,
|
||||||
|
selectedMenu: viewModel.selectedMenu,
|
||||||
|
selectMenu: { viewModel.selectMenuPreset(selectedMenuPreset: $0) }
|
||||||
|
)
|
||||||
|
.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))
|
||||||
.foregroundColor(Color(hex: "9970ff"))
|
.foregroundColor(Color.button)
|
||||||
.padding(.vertical, 16)
|
.padding(.vertical, 16)
|
||||||
.frame(width: (screenSize().width - 40) / 2)
|
.frame(width: (screenSize().width - 40) / 2)
|
||||||
.background(Color(hex: "9970ff").opacity(0.2))
|
.background(Color.button.opacity(0.2))
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.overlay(
|
.overlay(
|
||||||
RoundedRectangle(cornerRadius: 10)
|
RoundedRectangle(cornerRadius: 10)
|
||||||
.strokeBorder(lineWidth: 1)
|
.strokeBorder(lineWidth: 1)
|
||||||
.foregroundColor(Color(hex: "9970ff"))
|
.foregroundColor(Color.button)
|
||||||
)
|
)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
isShowing = false
|
isShowing = false
|
||||||
|
@ -139,7 +147,7 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.padding(.vertical, 16)
|
.padding(.vertical, 16)
|
||||||
.frame(width: (screenSize().width - 40) / 2)
|
.frame(width: (screenSize().width - 40) / 2)
|
||||||
.background(Color(hex: "9970ff"))
|
.background(Color.button)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
confirmAction(
|
confirmAction(
|
||||||
|
@ -154,11 +162,14 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding(13.3)
|
.padding(13.3)
|
||||||
.frame(width: proxy.size.width, height: proxy.size.height)
|
|
||||||
.onTapGesture { hideKeyboard() }
|
.onTapGesture { hideKeyboard() }
|
||||||
|
.onAppear {
|
||||||
|
viewModel.getAllMenuPreset {
|
||||||
|
self.isShowing = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.background(Color(hex: "222222").edgesIgnoringSafeArea(.all))
|
.background(Color(hex: "222222").edgesIgnoringSafeArea(.all))
|
||||||
}
|
|
||||||
|
|
||||||
if viewModel.isShowPopup {
|
if viewModel.isShowPopup {
|
||||||
LiveRoomDialogView(
|
LiveRoomDialogView(
|
||||||
|
@ -193,15 +204,15 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color.grayee)
|
||||||
.accentColor(Color(hex: "3bb9f1"))
|
.accentColor(Color.button)
|
||||||
.keyboardType(.default)
|
.keyboardType(.default)
|
||||||
.padding(.top, 12)
|
.padding(.top, 12)
|
||||||
.padding(.horizontal, 6.7)
|
.padding(.horizontal, 6.7)
|
||||||
|
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.frame(height: 1)
|
.frame(height: 1)
|
||||||
.foregroundColor(Color(hex: "909090").opacity(0.7))
|
.foregroundColor(Color.gray90.opacity(0.7))
|
||||||
.padding(.top, 8.3)
|
.padding(.top, 8.3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,16 +223,16 @@ struct LiveRoomInfoEditDialog: View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
Text("공지")
|
Text("공지")
|
||||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color.grayee)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Text("\(notice.count)자")
|
Text("\(notice.count)자")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "ff5c49")) +
|
.foregroundColor(Color.mainRed) +
|
||||||
Text(" / 1000자")
|
Text(" / 1000자")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "777777"))
|
.foregroundColor(Color.gray77)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextViewWrapper(
|
TextViewWrapper(
|
||||||
|
|
|
@ -13,4 +13,7 @@ struct EditLiveRoomInfoRequest: Encodable {
|
||||||
let numberOfPeople: Int?
|
let numberOfPeople: Int?
|
||||||
let beginDateTimeString: String?
|
let beginDateTimeString: String?
|
||||||
let timezone: String?
|
let timezone: String?
|
||||||
|
var menuPanId: Int = 0
|
||||||
|
var menuPan: String = ""
|
||||||
|
var isActiveMenuPan: Bool? = nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,19 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var menuId = 0
|
||||||
|
@Published var menu = ""
|
||||||
|
@Published var menuList = [GetMenuPresetResponse]()
|
||||||
|
|
||||||
|
@Published var isActivateMenu = false {
|
||||||
|
didSet {
|
||||||
|
if !isActivateMenu {
|
||||||
|
menu = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Published var selectedMenu: SelectedMenu? = nil
|
||||||
|
|
||||||
var signatureImageUrls = [String]()
|
var signatureImageUrls = [String]()
|
||||||
var isShowSignatureImage = false
|
var isShowSignatureImage = false
|
||||||
|
|
||||||
|
@ -634,10 +647,13 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
notice: liveRoomInfo!.notice != notice ? notice : nil,
|
notice: liveRoomInfo!.notice != notice ? notice : nil,
|
||||||
numberOfPeople: nil,
|
numberOfPeople: nil,
|
||||||
beginDateTimeString: nil,
|
beginDateTimeString: nil,
|
||||||
timezone: nil
|
timezone: nil,
|
||||||
|
menuPanId: isActivateMenu ? menuId : 0,
|
||||||
|
menuPan: isActivateMenu ? menu : "",
|
||||||
|
isActiveMenuPan: isActivateMenu
|
||||||
)
|
)
|
||||||
|
|
||||||
if (request.title == nil && request.notice == nil && coverImage == nil) {
|
if (request.title == nil && request.notice == nil && coverImage == nil && menu == liveRoomInfo?.menuPan) {
|
||||||
self.errorMessage = "변경사항이 없습니다."
|
self.errorMessage = "변경사항이 없습니다."
|
||||||
self.isShowErrorPopup = true
|
self.isShowErrorPopup = true
|
||||||
return
|
return
|
||||||
|
@ -648,7 +664,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
let encoder = JSONEncoder()
|
let encoder = JSONEncoder()
|
||||||
encoder.outputFormatting = .withoutEscapingSlashes
|
encoder.outputFormatting = .withoutEscapingSlashes
|
||||||
|
|
||||||
if (request.title != nil || request.notice != nil) {
|
if (request.title != nil || request.notice != nil || menu != liveRoomInfo?.menuPan) {
|
||||||
let jsonData = try? encoder.encode(request)
|
let jsonData = try? encoder.encode(request)
|
||||||
if let jsonData = jsonData {
|
if let jsonData = jsonData {
|
||||||
multipartData.append(MultipartFormData(provider: .data(jsonData), name: "request"))
|
multipartData.append(MultipartFormData(provider: .data(jsonData), name: "request"))
|
||||||
|
@ -665,8 +681,6 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
repository.editLiveRoomInfo(roomId: AppState.shared.roomId, parameters: multipartData)
|
repository.editLiveRoomInfo(roomId: AppState.shared.roomId, parameters: multipartData)
|
||||||
.sink { result in
|
.sink { result in
|
||||||
switch result {
|
switch result {
|
||||||
|
@ -684,6 +698,11 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
|
|
||||||
if decoded.success {
|
if decoded.success {
|
||||||
self.coverImage = nil
|
self.coverImage = nil
|
||||||
|
self.menuList.removeAll()
|
||||||
|
self.isActivateMenu = false
|
||||||
|
self.selectedMenu = nil
|
||||||
|
self.menu = ""
|
||||||
|
self.isShowMenuPan = false
|
||||||
self.getRoomInfo()
|
self.getRoomInfo()
|
||||||
|
|
||||||
let editRoomInfoMessage = LiveRoomChatRawMessage(
|
let editRoomInfoMessage = LiveRoomChatRawMessage(
|
||||||
|
@ -694,12 +713,102 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
)
|
)
|
||||||
|
|
||||||
self.agora.sendRawMessageToGroup(rawMessage: editRoomInfoMessage)
|
self.agora.sendRawMessageToGroup(rawMessage: editRoomInfoMessage)
|
||||||
|
self.errorMessage = "라이브 정보가 수정되었습니다."
|
||||||
|
self.isShowErrorPopup = true
|
||||||
} else {
|
} else {
|
||||||
self.errorMessage = decoded.message ?? "라이브 정보를 수정하지 못했습니다.\n다시 시도해 주세요."
|
self.errorMessage = decoded.message ?? "라이브 정보를 수정하지 못했습니다.\n다시 시도해 주세요."
|
||||||
self.isShowPopup = true
|
self.isShowErrorPopup = true
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
self.errorMessage = "라이브 정보를 수정하지 못했습니다.\n다시 시도해 주세요."
|
self.errorMessage = "라이브 정보를 수정하지 못했습니다.\n다시 시도해 주세요."
|
||||||
|
self.isShowErrorPopup = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &subscription)
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectMenuPreset(selectedMenuPreset: SelectedMenu) {
|
||||||
|
if menuList.isEmpty && (selectedMenuPreset == .MENU_2 || selectedMenuPreset == .MENU_3) {
|
||||||
|
errorMessage = "메뉴 1을 먼저 설정하세요"
|
||||||
|
isShowPopup = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if menuList.count == 1 && selectedMenuPreset == .MENU_3 {
|
||||||
|
errorMessage = "메뉴 1과 메뉴 2를 먼저 설정하세요"
|
||||||
|
isShowPopup = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.selectedMenu != selectedMenuPreset {
|
||||||
|
self.selectedMenu = selectedMenuPreset
|
||||||
|
|
||||||
|
if menuList.count > selectedMenuPreset.rawValue {
|
||||||
|
let menu = menuList[selectedMenuPreset.rawValue]
|
||||||
|
self.menu = menu.menu
|
||||||
|
self.menuId = menu.id
|
||||||
|
} else {
|
||||||
|
self.menu = ""
|
||||||
|
self.menuId = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAllMenuPreset(onFailure: @escaping () -> Void) {
|
||||||
|
isLoading = true
|
||||||
|
|
||||||
|
repository.getAllMenuPreset(creatorId: UserDefaults.int(forKey: .userId))
|
||||||
|
.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(ApiResponse<[GetMenuPresetResponse]>.self, from: responseData)
|
||||||
|
|
||||||
|
if let data = decoded.data, decoded.success {
|
||||||
|
self.menuList.removeAll()
|
||||||
|
self.menuList.append(contentsOf: data)
|
||||||
|
self.isActivateMenu = false
|
||||||
|
self.selectedMenu = nil
|
||||||
|
|
||||||
|
for (index, menuPreset) in self.menuList.enumerated() {
|
||||||
|
if menuPreset.isActive {
|
||||||
|
switch index {
|
||||||
|
case 1:
|
||||||
|
self.selectMenuPreset(selectedMenuPreset: .MENU_2)
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
self.selectMenuPreset(selectedMenuPreset: .MENU_3)
|
||||||
|
|
||||||
|
default:
|
||||||
|
self.selectMenuPreset(selectedMenuPreset: .MENU_1)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.isActivateMenu = true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onFailure()
|
||||||
|
if let message = decoded.message {
|
||||||
|
self.errorMessage = message
|
||||||
|
} else {
|
||||||
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
|
}
|
||||||
|
|
||||||
|
self.isShowPopup = true
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
onFailure()
|
||||||
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
self.isShowPopup = true
|
self.isShowPopup = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct LiveRoomMenuSelectView: View {
|
||||||
@Binding var isActivate: Bool
|
@Binding var isActivate: Bool
|
||||||
|
|
||||||
let menuCount: Int
|
let menuCount: Int
|
||||||
let selectedMenu: SelectedMenu
|
let selectedMenu: SelectedMenu?
|
||||||
let selectMenu: (SelectedMenu) -> Void
|
let selectMenu: (SelectedMenu) -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -32,7 +32,10 @@ struct LiveRoomMenuSelectView: View {
|
||||||
Image(isActivate ? "btn_toggle_on_big" : "btn_toggle_off_big")
|
Image(isActivate ? "btn_toggle_on_big" : "btn_toggle_off_big")
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 33.3, height: 20)
|
.frame(width: 33.3, height: 20)
|
||||||
.onTapGesture { isActivate.toggle() }
|
.onTapGesture {
|
||||||
|
isActivate.toggle()
|
||||||
|
selectMenu(.MENU_1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(.top, 8)
|
.padding(.top, 8)
|
||||||
|
|
||||||
|
@ -71,7 +74,7 @@ struct LiveRoomMenuSelectView: View {
|
||||||
text: $menu,
|
text: $menu,
|
||||||
placeholder: "메뉴판을 작성해주세요.",
|
placeholder: "메뉴판을 작성해주세요.",
|
||||||
textColorHex: "eeeeee",
|
textColorHex: "eeeeee",
|
||||||
backgroundColorHex: "222222"
|
backgroundColorHex: "303030"
|
||||||
)
|
)
|
||||||
.frame(height: 200)
|
.frame(height: 200)
|
||||||
.cornerRadius(6.7)
|
.cornerRadius(6.7)
|
||||||
|
|
|
@ -344,10 +344,12 @@ struct LiveRoomViewV2: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
|
if viewModel.liveRoomInfo == nil {
|
||||||
viewModel.quitRoom()
|
viewModel.quitRoom()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.cornerRadius(16.7, corners: [.topLeft, .topRight])
|
.cornerRadius(16.7, corners: [.topLeft, .topRight])
|
||||||
.offset(y: -(keyboardHandler.keyboardHeight > 0 ? keyboardHandler.keyboardHeight : 0))
|
.offset(y: -(keyboardHandler.keyboardHeight > 0 ? keyboardHandler.keyboardHeight : 0))
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
|
Loading…
Reference in New Issue