diff --git a/SodaLive/Sources/Content/Create/ContentCreateView.swift b/SodaLive/Sources/Content/Create/ContentCreateView.swift index 6edb497..dced44b 100644 --- a/SodaLive/Sources/Content/Create/ContentCreateView.swift +++ b/SodaLive/Sources/Content/Create/ContentCreateView.swift @@ -219,7 +219,7 @@ struct ContentCreateView: View { VStack(spacing: 13.3) { Text("소장 설정") .font(.custom(Font.bold.rawValue, size: 16.7)) - .foregroundColor(Color(hex: "eeeeee")) + .foregroundColor(Color.grayee) .frame(maxWidth: .infinity, alignment: .leading) HStack(spacing: 13.3) { @@ -241,7 +241,7 @@ struct ContentCreateView: View { VStack(spacing: 0) { Text(viewModel.isOnlyRental ? "대여 가격" : "소장 가격") .font(.custom(Font.medium.rawValue, size: 13.3)) - .foregroundColor(Color(hex: "d2d2d2")) + .foregroundColor(Color.grayd2) .frame(maxWidth: .infinity, alignment: .leading) HStack(spacing: 0) { @@ -249,7 +249,7 @@ struct ContentCreateView: View { .autocapitalization(.none) .disableAutocorrection(true) .font(.custom(Font.bold.rawValue, size: 14.7)) - .foregroundColor(Color(hex: "eeeeee")) + .foregroundColor(Color.grayee) .cornerRadius(6.7) .keyboardType(.numberPad) .padding(.trailing, 10) @@ -258,16 +258,16 @@ struct ContentCreateView: View { Text("캔") .font(.custom(Font.medium.rawValue, size: 13.3)) - .foregroundColor(Color(hex: "777777")) + .foregroundColor(Color.gray77) } .padding(.vertical, 17) .padding(.horizontal, 13.3) - .background(Color(hex: "222222")) + .background(Color.gray22) .cornerRadius(5.3) .padding(.top, 5.3) Rectangle() - .foregroundColor(Color(hex: "232323")) + .foregroundColor(Color.gray23) .frame(height: 1) .padding(.top, 11) @@ -289,6 +289,44 @@ struct ContentCreateView: View { } .padding(.top, 26.7) + if viewModel.price > 0 && !viewModel.isOnlyRental { + VStack(spacing: 13.3) { + Text("한정판 설정") + .font(.custom(Font.bold.rawValue, size: 16.7)) + .foregroundColor(Color.grayee) + .frame(maxWidth: .infinity, alignment: .leading) + + HStack(spacing: 13.3) { + SelectButtonView(title: "무제한", isChecked: !viewModel.isLimited) { + if viewModel.isLimited { + viewModel.isLimited = false + } + } + + SelectButtonView(title: "한정판", isChecked: viewModel.isLimited) { + if !viewModel.isLimited { + viewModel.isLimited = true + } + } + } + + if viewModel.isLimited { + TextField("한정판 개수를 입력하세요", text: $viewModel.limitedString) + .autocapitalization(.none) + .disableAutocorrection(true) + .font(.custom(Font.bold.rawValue, size: 14.7)) + .foregroundColor(Color.grayee) + .cornerRadius(6.7) + .keyboardType(.numberPad) + .padding(.vertical, 17) + .padding(.horizontal, 13.3) + .background(Color.gray22) + .cornerRadius(5.3) + } + } + .padding(.top, 26.7) + } + VStack(spacing: 13.3) { Text("미리듣기") .font(.custom(Font.bold.rawValue, size: 16.7)) diff --git a/SodaLive/Sources/Content/Create/ContentCreateViewModel.swift b/SodaLive/Sources/Content/Create/ContentCreateViewModel.swift index 9684ee0..8cae2f0 100644 --- a/SodaLive/Sources/Content/Create/ContentCreateViewModel.swift +++ b/SodaLive/Sources/Content/Create/ContentCreateViewModel.swift @@ -55,15 +55,48 @@ final class ContentCreateViewModel: ObservableObject { didSet { if isFree { priceString = "0" + isLimited = false isOnlyRental = false isGeneratePreview = true } } } - @Published var isOnlyRental = false + @Published var isOnlyRental = false { + didSet { + if isOnlyRental { + isLimited = false + } + } + } @Published var isGeneratePreview = true + @Published var isLimited = false { + didSet { + if !isLimited { + limitedString = "" + } + } + } + + @Published var limited: Int? = nil { + didSet { + if let limited = limited, limited <= 0 { + limitedString = "" + } + } + } + + @Published var limitedString: String = "" { + didSet { + if limitedString == "" { + limited = nil + } else { + limited = Int(limitedString) + } + } + } + @Published var previewStartTime: String = "" @Published var previewEndTime: String = "" @Published var releaseDateString: String = Date().convertDateFormat(dateFormat: "yyyy.MM.dd") @@ -92,6 +125,7 @@ final class ContentCreateViewModel: ObservableObject { detail: detail, tags: hashtags, price: price, + limited: limited, releaseDate: isActiveReservation ? "\(releaseDate.convertDateFormat(dateFormat: "yyyy-MM-dd")) \(releaseTime.convertDateFormat(dateFormat: "HH:mm"))" : nil, timezone: TimeZone.current.identifier, themeId: theme!.id, diff --git a/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift b/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift index e33c490..eef4a56 100644 --- a/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift +++ b/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift @@ -12,6 +12,7 @@ struct CreateAudioContentRequest: Encodable { let detail: String let tags: String let price: Int + let limited: Int? let releaseDate: String? let timezone: String let themeId: Int