라이브

- 메뉴판 UI 추가
This commit is contained in:
Yu Sung
2024-03-08 16:58:00 +09:00
parent aa4171b095
commit b6411c3ccb
13 changed files with 381 additions and 123 deletions

View File

@@ -19,4 +19,7 @@ struct CreateLiveRoomRequest: Encodable {
var password: String? = nil
let timezone: String = TimeZone.current.identifier
var beginDateTimeString: String? = nil
var menuPanId: Int = 0
var menuPan: String = ""
var isActiveMenuPan: Bool = false
}

View File

@@ -41,7 +41,7 @@ struct LiveRoomCreateView: View {
Text("라이브 만들기")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
}
Spacer()
@@ -49,13 +49,13 @@ struct LiveRoomCreateView: View {
if viewModel.isShowGetRecentInfoButton {
Text("최근 데이터 가져오기")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "9970ff"))
.foregroundColor(Color.button)
.padding(.vertical, 8)
.padding(.horizontal, 10.7)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke()
.foregroundColor(Color(hex: "9970ff"))
.foregroundColor(Color.button)
)
.onTapGesture {
viewModel.getRecentInfo()
@@ -71,7 +71,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 0) {
Text("썸네일")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.padding(.horizontal, 13.3)
.padding(.top, 13.3)
.frame(width: screenSize().width, alignment: .leading)
@@ -95,13 +95,13 @@ struct LiveRoomCreateView: View {
.resizable()
.scaledToFit()
.frame(width: 80, height: 116.8)
.background(Color(hex: "3e3358"))
.background(Color.bg)
.cornerRadius(10)
}
Image("ic_camera")
.padding(10)
.background(Color(hex: "9970ff"))
.background(Color.button)
.cornerRadius(30)
.offset(x: 40, y: 40)
}
@@ -115,25 +115,32 @@ struct LiveRoomCreateView: View {
.frame(width: screenSize().width - 26.7)
.padding(.top, 33.3)
TagSelectView()
ContentInputView()
.frame(width: screenSize().width - 26.7)
.padding(.top, 33.3)
}
VStack(spacing: 0) {
ContentInputView()
.frame(width: screenSize().width - 26.7)
.padding(.top, 33.3)
VStack(spacing: 33.3) {
LiveRoomMenuSelectView(
menu: $viewModel.menu,
isActivate: $viewModel.isActivateMenu,
menuCount: viewModel.menuList.count,
selectedMenu: viewModel.selectedMenu ?? .MENU_1,
selectMenu: {
viewModel.selectMenuPreset(selectedMenuPreset: $0)
}
)
.frame(width: screenSize().width - 26.7)
if viewModel.roomType != .SECRET {
TimeSettingView()
.padding(.top, 33.3)
}
TagSelectView()
.frame(width: screenSize().width - 26.7)
TimeSettingView()
NumberOfPeopleLimitView()
.frame(width: screenSize().width - 26.7)
.padding(.top, 33.3)
}
.padding(.top, 33.3)
VStack(spacing: 0) {
RoomTypeSettingView()
@@ -146,11 +153,9 @@ struct LiveRoomCreateView: View {
.padding(.top, 33.3)
}
if UserDefaults.string(forKey: .role) == MemberRole.CREATOR.rawValue {
PriceSettingView()
.frame(width: screenSize().width - 26.7)
.padding(.top, 33.3)
}
PriceSettingView()
.frame(width: screenSize().width - 26.7)
.padding(.top, 33.3)
}
HStack(alignment: .top, spacing: 0) {
@@ -167,23 +172,23 @@ struct LiveRoomCreateView: View {
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color.white)
.frame(width: screenSize().width - 26.7, height: 50)
.background(Color(hex: "9970ff"))
.background(Color.button)
.cornerRadius(10)
.padding(.vertical, 13.3)
}
}
.frame(width: screenSize().width)
.background(Color(hex: "222222"))
.background(Color.gray22)
.cornerRadius(16.7, corners: [.topLeft, .topRight])
.padding(.top, 30)
Rectangle()
.foregroundColor(Color(hex: "222222"))
.foregroundColor(Color.gray22)
.frame(width: screenSize().width, height: keyboardHandler.keyboardHeight)
if proxy.safeAreaInsets.bottom > 0 {
Rectangle()
.foregroundColor(Color(hex: "222222"))
.foregroundColor(Color.gray22)
.frame(width: screenSize().width, height: 15.3)
}
}
@@ -234,7 +239,7 @@ struct LiveRoomCreateView: View {
.padding(.vertical, 13.3)
.frame(width: geo.size.width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color(hex: "9970ff"))
.background(Color.button)
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.cornerRadius(20)
@@ -245,6 +250,7 @@ struct LiveRoomCreateView: View {
}
.onAppear {
viewModel.timeSettingMode = timeSettingMode
viewModel.getAllMenuPreset()
}
}
@@ -253,7 +259,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 0) {
Text("제목")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.padding(.horizontal, 13.3)
.frame(width: screenSize().width, alignment: .leading)
@@ -261,15 +267,15 @@ struct LiveRoomCreateView: View {
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
.accentColor(Color(hex: "3bb9f1"))
.foregroundColor(Color.grayee)
.accentColor(Color.button)
.keyboardType(.default)
.padding(.top, 12)
.padding(.horizontal, 6.7)
Rectangle()
.frame(height: 1)
.foregroundColor(Color(hex: "909090").opacity(0.7))
.foregroundColor(Color.gray90.opacity(0.7))
.padding(.top, 8.3)
}
}
@@ -279,7 +285,7 @@ struct LiveRoomCreateView: View {
VStack(alignment: .leading, spacing: 13.3) {
Text("관심사")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
Button(action: {
hideKeyboard()
@@ -287,15 +293,15 @@ struct LiveRoomCreateView: View {
}) {
Text("관심사 선택")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "9970ff"))
.foregroundColor(Color.button)
.padding(.vertical, 13.7)
.frame(width: screenSize().width - 26.7)
.background(Color(hex: "9970ff").opacity(0.2))
.background(Color.button.opacity(0.2))
.cornerRadius(24.3)
.overlay(
RoundedRectangle(cornerRadius: 24.3)
.stroke()
.foregroundColor(Color(hex: "9970ff"))
.foregroundColor(Color.button)
)
}
@@ -315,7 +321,7 @@ struct LiveRoomCreateView: View {
}
}
.padding(10)
.background(Color(hex: "9970ff"))
.background(Color.button)
.cornerRadius(24.3)
}
}
@@ -330,16 +336,16 @@ struct LiveRoomCreateView: View {
HStack(spacing: 0) {
Text("공지")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
Spacer()
Text("\(viewModel.content.count)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ff5c49")) +
.foregroundColor(Color.mainRed) +
Text(" / 1000자")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777"))
.foregroundColor(Color.gray77)
}
TextViewWrapper(
@@ -348,7 +354,7 @@ struct LiveRoomCreateView: View {
textColorHex: "eeeeee",
backgroundColorHex: "222222"
)
.frame(width: screenSize().width - 26.7, height: 133.3)
.frame(width: screenSize().width - 26.7, height: 200)
.cornerRadius(6.7)
.padding(.top, 13.3)
}
@@ -359,7 +365,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 0) {
Text("시간설정")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: screenSize().width - 26.7, alignment: .leading)
HStack(spacing: 13.3) {
@@ -400,15 +406,11 @@ struct LiveRoomCreateView: View {
.foregroundColor(
viewModel.timeSettingMode == timeSettingMode ?
.white :
Color(hex: "9970ff")
Color.button
)
}
.frame(width: buttonWidth, height: 48.7)
.background(
viewModel.timeSettingMode == timeSettingMode ?
Color(hex: "9970ff") :
Color(hex: "1f1734")
)
.background(viewModel.timeSettingMode == timeSettingMode ? Color.button : Color.bg)
.cornerRadius(6.7)
.onTapGesture {
hideKeyboard()
@@ -424,7 +426,7 @@ struct LiveRoomCreateView: View {
VStack(alignment: .leading, spacing: 6.7) {
Text("예약 날짜")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
Button(action: {
hideKeyboard()
@@ -432,11 +434,11 @@ struct LiveRoomCreateView: View {
}) {
Text(viewModel.reservationDateString)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: buttonWidth, height: 48.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(Color(hex: "9970ff"), lineWidth: 1.3)
.stroke(Color.button, lineWidth: 1.3)
)
}
}
@@ -444,7 +446,7 @@ struct LiveRoomCreateView: View {
VStack(alignment: .leading, spacing: 6.7) {
Text("예약 시간")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
Button(action: {
hideKeyboard()
@@ -452,18 +454,18 @@ struct LiveRoomCreateView: View {
}) {
Text(viewModel.reservationTimeString)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: buttonWidth, height: 48.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(Color(hex: "9970ff"), lineWidth: 1.3)
.stroke(Color.button, lineWidth: 1.3)
)
}
}
}
.frame(width: screenSize().width)
.padding(.vertical, 13.3)
.background(Color(hex: "222222"))
.background(Color.gray22)
}
@ViewBuilder
@@ -471,7 +473,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 13.3) {
Text("참여인원 설정")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: screenSize().width - 26.7, alignment: .leading)
TextField("최대 인원 999명", text: $viewModel.numberOfPeople)
@@ -479,12 +481,12 @@ struct LiveRoomCreateView: View {
.disableAutocorrection(true)
.multilineTextAlignment(.center)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
.accentColor(Color(hex: "3bb9f1"))
.foregroundColor(Color.grayee)
.accentColor(Color.button)
.keyboardType(.numberPad)
.padding(.vertical, 15.7)
.frame(width: screenSize().width - 26.7, alignment: .center)
.background(Color(hex: "222222"))
.background(Color.gray22)
.cornerRadius(6.7)
}
}
@@ -508,12 +510,12 @@ struct LiveRoomCreateView: View {
Button(action: { self.isShowSelectDateView = false }) {
Text("확인")
.font(.system(size: 16))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.padding(.vertical, 10)
.frame(width: proxy.size.width - 53.4)
}
}
.background(Color(hex: "222222"))
.background(Color.gray22)
.cornerRadius(6.7)
}
.frame(width: proxy.size.width)
@@ -539,12 +541,12 @@ struct LiveRoomCreateView: View {
Button(action: { self.isShowSelectTimeView = false }) {
Text("확인")
.font(.system(size: 16))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.padding(.vertical, 10)
.frame(width: proxy.size.width)
}
}
.background(Color(hex: "222222"))
.background(Color.gray22)
.cornerRadius(6.7)
}
.frame(width: proxy.size.width)
@@ -556,7 +558,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 0) {
Text("공개 설정")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: screenSize().width - 26.7, alignment: .leading)
HStack(spacing: 13.3) {
@@ -591,18 +593,10 @@ struct LiveRoomCreateView: View {
Text(title)
.font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(
viewModel.roomType == type ?
.white :
Color(hex: "9970ff")
)
.foregroundColor(viewModel.roomType == type ? .white : Color.button)
}
.frame(width: buttonWidth, height: 48.7)
.background(
viewModel.roomType == type ?
Color(hex: "9970ff") :
Color(hex: "1f1734")
)
.background(viewModel.roomType == type ? Color.button : Color.bg)
.cornerRadius(6.7)
.onTapGesture {
hideKeyboard()
@@ -617,7 +611,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 13.3) {
Text("방 비밀번호 입력")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: screenSize().width - 26.7, alignment: .leading)
TextField("방 입장 비밀번호 6자리를 입력해 주세요.", text: $viewModel.password)
@@ -625,12 +619,12 @@ struct LiveRoomCreateView: View {
.disableAutocorrection(true)
.multilineTextAlignment(.center)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
.accentColor(Color(hex: "3bb9f1"))
.foregroundColor(Color.grayee)
.accentColor(Color.button)
.keyboardType(.numberPad)
.padding(.vertical, 15.7)
.frame(width: screenSize().width - 26.7, alignment: .center)
.background(Color(hex: "222222"))
.background(Color.grayee)
.cornerRadius(6.7)
}
}
@@ -640,7 +634,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 13.3) {
Text("연령 제한")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: screenSize().width - 26.7, alignment: .leading)
HStack(spacing: 13.3) {
@@ -668,18 +662,10 @@ struct LiveRoomCreateView: View {
Text(title)
.font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(
viewModel.isAdult == isAdult ?
.white :
Color(hex: "9970ff")
)
.foregroundColor(viewModel.isAdult == isAdult ? .white : Color.button)
}
.frame(width: buttonWidth, height: 48.7)
.background(
viewModel.isAdult == isAdult ?
Color(hex: "9970ff") :
Color(hex: "1f1734")
)
.background(viewModel.isAdult == isAdult ? Color.button : Color.bg)
.cornerRadius(6.7)
.onTapGesture {
hideKeyboard()
@@ -694,7 +680,7 @@ struct LiveRoomCreateView: View {
VStack(spacing: 13.3) {
Text("티켓 가격")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color.grayee)
.frame(width: screenSize().width - 26.7, alignment: .leading)
HStack(spacing: 13.3) {
@@ -719,35 +705,23 @@ struct LiveRoomCreateView: View {
.disableAutocorrection(true)
.multilineTextAlignment(.center)
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "9970ff"))
.accentColor(Color(hex: "3bb9f1"))
.foregroundColor(Color.button)
.accentColor(Color.button)
.keyboardType(.numberPad)
Spacer()
Text("")
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(
Color(hex: "9970ff")
)
.foregroundColor(Color.button)
}
.padding(.horizontal, 13.3)
.frame(width: screenSize().width - 26.7, height: 48.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(
Color(hex: !viewModel.prices.contains(viewModel.price) ?
"9970ff" :
"777777"
),
lineWidth: 1
)
)
.background(
!viewModel.prices.contains(viewModel.price) ?
Color(hex:"9970ff").opacity(0.3):
Color(hex: "232323")
.stroke(!viewModel.prices.contains(viewModel.price) ? Color.button : Color.gray77, lineWidth: 1)
)
.background(!viewModel.prices.contains(viewModel.price) ? Color.button.opacity(0.3): Color.gray23)
}
}
@@ -761,23 +735,17 @@ struct LiveRoomCreateView: View {
Font.medium.rawValue,
size: 14.7
))
.foregroundColor(
Color(hex: viewModel.price == price ? "9970ff" : "777777")
)
.foregroundColor(viewModel.price == price ? Color.button : Color.gray77)
}
.frame(width: buttonWidth, height: 48.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(
Color(hex: viewModel.price == price ? "9970ff" : "777777"),
viewModel.price == price ? Color.button : Color.gray77,
lineWidth: 1
)
)
.background(
viewModel.price == price ?
Color(hex:"9970ff").opacity(0.3):
Color(hex: "232323")
)
.background(viewModel.price == price ? Color.button.opacity(0.3) : Color.gray23)
.cornerRadius(6.7)
.onTapGesture {
hideKeyboard()

View File

@@ -9,13 +9,19 @@ import UIKit
import Moya
import Combine
enum SelectedMenu: Int {
case MENU_1 = 0
case MENU_2 = 1
case MENU_3 = 2
}
final class LiveRoomCreateViewModel: ObservableObject {
enum TimeSettingMode: String {
case NOW, RESERVATION
}
enum LiveRoomType: String, Codable {
case OPEN, PRIVATE, SECRET
case OPEN, PRIVATE
}
let prices = [0, 100, 300, 500, 1000, 2000]
@@ -40,15 +46,12 @@ final class LiveRoomCreateViewModel: ObservableObject {
@Published var roomType: LiveRoomType = .OPEN {
didSet {
if roomType == .SECRET {
timeSettingMode = .NOW
}
if roomType != .PRIVATE {
password = ""
}
}
}
@Published var password = "" {
didSet {
if password.count > 6 {
@@ -77,6 +80,14 @@ final class LiveRoomCreateViewModel: ObservableObject {
@Published var isShowPopup = false
@Published var isShowGetRecentInfoButton = true
private var menuId = 0
@Published var menu = ""
@Published var menuList = [GetMenuPresetResponse]()
@Published var isActivateMenu = false
@Published var selectedMenu: SelectedMenu? = nil
private let repository = LiveRepository()
private var subscription = Set<AnyCancellable>()
@@ -164,10 +175,13 @@ final class LiveRoomCreateViewModel: ObservableObject {
isAdult: isAdult,
price: price,
type: roomType,
password: (roomType == .PRIVATE && !password.trimmingCharacters(in: .whitespaces).isEmpty) ? password : nil
password: (roomType == .PRIVATE && !password.trimmingCharacters(in: .whitespaces).isEmpty) ? password : nil,
menuPanId: isActivateMenu ? menuId : 0,
menuPan: isActivateMenu ? menu : "",
isActiveMenuPan: isActivateMenu
)
if timeSettingMode == .RESERVATION && roomType != .SECRET {
if timeSettingMode == .RESERVATION {
request.beginDateTimeString = "\(reservationDate.convertDateFormat(dateFormat: "yyyy-MM-dd")) \(reservationTime.convertDateFormat(dateFormat: "HH:mm"))"
}
@@ -233,6 +247,73 @@ final class LiveRoomCreateViewModel: ObservableObject {
}
}
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() {
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.selectMenuPreset(selectedMenuPreset: .MENU_1)
} else {
if let message = decoded.message {
self.errorMessage = message
} else {
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
}
self.isShowPopup = true
}
} catch {
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
self.isShowPopup = true
}
}
.store(in: &subscription)
}
private func validate() -> Bool {
if coverImage == nil && coverImagePath == nil {
self.errorMessage = "커버이미지를 선택해주세요."