예약 업로드 추가

This commit is contained in:
Yu Sung 2024-01-10 17:08:22 +09:00
parent a27952bbca
commit c1e598a8bf
5 changed files with 281 additions and 63 deletions

View File

@ -16,6 +16,8 @@ struct ContentCreateView: View {
@State private var isShowPhotoPicker = false @State private var isShowPhotoPicker = false
@State private var isShowSelectAudioView = false @State private var isShowSelectAudioView = false
@State private var isShowSelectThemeView = false @State private var isShowSelectThemeView = false
@State private var isShowSelectDateView = false
@State private var isShowSelectTimeView = false
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { BaseView(isLoading: $viewModel.isLoading) {
@ -37,7 +39,7 @@ struct ContentCreateView: View {
.resizable() .resizable()
.scaledToFill() .scaledToFill()
.frame(width: 107, height: 107) .frame(width: 107, height: 107)
.background(Color(hex: "3e3358")) .background(Color(hex: "13181b"))
.cornerRadius(8) .cornerRadius(8)
.clipped() .clipped()
} else { } else {
@ -46,13 +48,13 @@ struct ContentCreateView: View {
.scaledToFit() .scaledToFit()
.padding(13.3) .padding(13.3)
.frame(width: 107, height: 107) .frame(width: 107, height: 107)
.background(Color(hex: "3e3358")) .background(Color(hex: "13181b"))
.cornerRadius(8) .cornerRadius(8)
} }
Image("ic_camera") Image("ic_camera")
.padding(10) .padding(10)
.background(Color(hex: "9970ff")) .background(Color(hex: "3bb9f1"))
.cornerRadius(30) .cornerRadius(30)
.offset(x: 50, y: 36) .offset(x: 50, y: 36)
} }
@ -67,15 +69,15 @@ struct ContentCreateView: View {
Text(viewModel.fileName.trimmingCharacters(in: .whitespacesAndNewlines) == "" ? "파일선택" : viewModel.fileName) Text(viewModel.fileName.trimmingCharacters(in: .whitespacesAndNewlines) == "" ? "파일선택" : viewModel.fileName)
.font(.custom(Font.medium.rawValue, size: 16.7)) .font(.custom(Font.medium.rawValue, size: 16.7))
.foregroundColor(Color(hex: "9970ff")) .foregroundColor(Color(hex: "3bb9f1"))
.padding(.vertical, 10) .padding(.vertical, 10)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color(hex: "9970ff").opacity(0.2)) .background(Color(hex: "13181b"))
.cornerRadius(5.3) .cornerRadius(5.3)
.overlay( .overlay(
RoundedCorner(radius: 8) RoundedCorner(radius: 8)
.stroke(lineWidth: 2) .stroke(lineWidth: 2)
.foregroundColor(Color(hex: "9970ff")) .foregroundColor(Color(hex: "3bb9f1"))
) )
.padding(.top, 13.3) .padding(.top, 13.3)
.onTapGesture { isShowSelectAudioView = true } .onTapGesture { isShowSelectAudioView = true }
@ -150,16 +152,16 @@ struct ContentCreateView: View {
viewModel.theme!.theme : viewModel.theme!.theme :
"테마 선택") "테마 선택")
.font(.custom(Font.bold.rawValue, size: 16.7)) .font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "9970ff")) .foregroundColor(Color(hex: "3bb9f1"))
} }
.padding(.vertical, viewModel.theme != nil ? 8 : 13.3) .padding(.vertical, viewModel.theme != nil ? 8 : 13.3)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color(hex: "9970ff").opacity(0.2)) .background(Color(hex: "13181b"))
.cornerRadius(24) .cornerRadius(24)
.overlay( .overlay(
RoundedRectangle(cornerRadius: 24) RoundedRectangle(cornerRadius: 24)
.stroke(lineWidth: 2) .stroke(lineWidth: 2)
.foregroundColor(Color(hex: "9970ff")) .foregroundColor(Color(hex: "3bb9f1"))
) )
.padding(.top, 13.3) .padding(.top, 13.3)
.onTapGesture { .onTapGesture {
@ -287,6 +289,62 @@ struct ContentCreateView: View {
} }
.padding(.top, 26.7) .padding(.top, 26.7)
} }
if !viewModel.isFree {
VStack(spacing: 10) {
Text("미리듣기 시간 설정")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
.frame(maxWidth: .infinity, alignment: .leading)
Text("미리듣기 시간을 직접 설정하지 않으면 콘텐츠 앞부분 30초가 자동으로 설정됩니다. 미리듣기의 시간제한은 없습니다.")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777"))
.frame(maxWidth: .infinity, alignment: .leading)
HStack(spacing: 13.3) {
VStack(spacing: 5.3) {
Text("시작 시간")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "d2d2d2"))
.frame(maxWidth: .infinity, alignment: .leading)
TextField("00:00:00", text: $viewModel.previewStartTime)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.bold.rawValue, size: 14.6))
.foregroundColor(Color(hex: "777777"))
.padding(.vertical, 16.7)
.padding(.horizontal, 13.3)
.background(Color(hex: "222222"))
.cornerRadius(6.7)
.keyboardType(.default)
.multilineTextAlignment(.center)
}
VStack(spacing: 5.3) {
Text("종료 시간")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "d2d2d2"))
.frame(maxWidth: .infinity, alignment: .leading)
TextField("00:00:30", text: $viewModel.previewEndTime)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.bold.rawValue, size: 14.6))
.foregroundColor(Color(hex: "777777"))
.padding(.vertical, 16.7)
.padding(.horizontal, 13.3)
.background(Color(hex: "222222"))
.cornerRadius(6.7)
.keyboardType(.default)
.multilineTextAlignment(.center)
}
}
.padding(.top, 3.3)
}
.padding(.top, 26.7)
}
} }
.padding(.top, 26.7) .padding(.top, 26.7)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
@ -343,62 +401,79 @@ struct ContentCreateView: View {
.padding(.top, 26.7) .padding(.top, 26.7)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
if !viewModel.isFree { VStack(spacing: 13.3) {
VStack(spacing: 10) { Text("예약 공개")
Text("미리듣기 시간 설정") .font(.custom(Font.bold.rawValue, size: 16.7))
.font(.custom(Font.bold.rawValue, size: 16.7)) .foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(Color(hex: "eeeeee")) .frame(maxWidth: .infinity, alignment: .leading)
.frame(maxWidth: .infinity, alignment: .leading)
HStack(spacing: 13.3) {
Text("미리듣기 시간을 직접 설정하지 않으면 콘텐츠 앞부분 30초가 자동으로 설정됩니다. 미리듣기의 시간제한은 없습니다.") SelectButtonView(title: "지금 공개", isChecked: !viewModel.isActiveReservation) {
.font(.custom(Font.medium.rawValue, size: 13.3)) if viewModel.isActiveReservation {
.foregroundColor(Color(hex: "777777")) viewModel.isActiveReservation = false
.frame(maxWidth: .infinity, alignment: .leading) }
}
HStack(spacing: 13.3) {
VStack(spacing: 5.3) { SelectButtonView(title: "예약 공개", isChecked: viewModel.isActiveReservation) {
Text("시작 시간") if !viewModel.isActiveReservation {
.font(.custom(Font.medium.rawValue, size: 13.3)) viewModel.isActiveReservation = true
.foregroundColor(Color(hex: "d2d2d2"))
.frame(maxWidth: .infinity, alignment: .leading)
TextField("00:00:00", text: $viewModel.previewStartTime)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.bold.rawValue, size: 14.6))
.foregroundColor(Color(hex: "777777"))
.padding(.vertical, 16.7)
.padding(.horizontal, 13.3)
.background(Color(hex: "222222"))
.cornerRadius(6.7)
.keyboardType(.default)
.multilineTextAlignment(.center)
}
VStack(spacing: 5.3) {
Text("종료 시간")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "d2d2d2"))
.frame(maxWidth: .infinity, alignment: .leading)
TextField("00:00:30", text: $viewModel.previewEndTime)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.bold.rawValue, size: 14.6))
.foregroundColor(Color(hex: "777777"))
.padding(.vertical, 16.7)
.padding(.horizontal, 13.3)
.background(Color(hex: "222222"))
.cornerRadius(6.7)
.keyboardType(.default)
.multilineTextAlignment(.center)
} }
} }
.padding(.top, 3.3)
} }
.padding(.top, 26.7)
.padding(.horizontal, 13.3) if viewModel.isActiveReservation {
HStack(spacing: 13.3) {
VStack(alignment: .leading, spacing: 6.7) {
Text("예약 날짜")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
Button(action: {
hideKeyboard()
self.isShowSelectDateView = true
}) {
Text(viewModel.releaseDateString)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
.frame(maxWidth: .infinity)
.frame(height: 48.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(Color(hex: "3bb9f1"), lineWidth: 1.3)
)
}
}
VStack(alignment: .leading, spacing: 6.7) {
Text("예약 시간")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
Button(action: {
hideKeyboard()
self.isShowSelectTimeView = true
}) {
Text(viewModel.releaseTimeString)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color(hex: "eeeeee"))
.frame(maxWidth: .infinity)
.frame(height: 48.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(Color(hex: "3bb9f1"), lineWidth: 1.3)
)
}
}
}
.padding(.horizontal, 13.3)
.padding(.vertical, 14.2)
.frame(maxWidth: .infinity)
.background(Color(hex: "222222"))
.padding(.top, 22.7)
}
} }
.padding(.top, 26.7)
.padding(.horizontal, 13.3)
VStack(spacing: 0) { VStack(spacing: 0) {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
@ -407,7 +482,7 @@ struct ContentCreateView: View {
.foregroundColor(Color.white) .foregroundColor(Color.white)
.frame(height: 50) .frame(height: 50)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color(hex: "9970ff")) .background(Color(hex: "3bb9f1"))
.cornerRadius(10) .cornerRadius(10)
.padding(13.3) .padding(13.3)
} }
@ -449,6 +524,14 @@ struct ContentCreateView: View {
} }
} }
if isShowSelectDateView {
SelectDatePicker(selectedDate: $viewModel.releaseDate, isShowing: $isShowSelectDateView)
}
if isShowSelectTimeView {
QuarterTimePickerView(selectedTime: $viewModel.releaseTime, isShowing: $isShowSelectTimeView)
}
if isShowPhotoPicker { if isShowPhotoPicker {
ImagePicker( ImagePicker(
isShowing: $isShowPhotoPicker, isShowing: $isShowPhotoPicker,
@ -494,7 +577,7 @@ struct ContentCreateView: View {
.padding(.vertical, 13.3) .padding(.vertical, 13.3)
.frame(width: screenSize().width - 66.7, alignment: .center) .frame(width: screenSize().width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12)) .font(.custom(Font.medium.rawValue, size: 12))
.background(Color(hex: "9970ff")) .background(Color(hex: "3bb9f1"))
.foregroundColor(Color.white) .foregroundColor(Color.white)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.cornerRadius(20) .cornerRadius(20)

View File

@ -34,6 +34,7 @@ final class ContentCreateViewModel: ObservableObject {
} }
@Published var isAvailableComment = true @Published var isAvailableComment = true
@Published var isActiveReservation = false
@Published var isAdult = false @Published var isAdult = false
@Published var priceString = "0" { @Published var priceString = "0" {
didSet { didSet {
@ -63,6 +64,20 @@ final class ContentCreateViewModel: ObservableObject {
@Published var previewStartTime: String = "" @Published var previewStartTime: String = ""
@Published var previewEndTime: String = "" @Published var previewEndTime: String = ""
@Published var releaseDateString: String = Date().convertDateFormat(dateFormat: "yyyy.MM.dd")
@Published var releaseTimeString: String = Date().convertDateFormat(dateFormat: "a hh:mm")
var releaseDate = Date() {
willSet {
releaseDateString = newValue.convertDateFormat(dateFormat: "yyyy.MM.dd")
}
}
var releaseTime = Date() {
willSet {
releaseTimeString = newValue.convertDateFormat(dateFormat: "a hh:mm")
}
}
var placeholder = "내용을 입력하세요" var placeholder = "내용을 입력하세요"
@ -75,6 +90,8 @@ final class ContentCreateViewModel: ObservableObject {
detail: detail, detail: detail,
tags: hashtags, tags: hashtags,
price: price, price: price,
releaseDate: isActiveReservation ? "\(releaseDate.convertDateFormat(dateFormat: "yyyy-MM-dd")) \(releaseTime.convertDateFormat(dateFormat: "HH:mm"))" : nil,
timezone: TimeZone.current.identifier,
themeId: theme!.id, themeId: theme!.id,
isAdult: isAdult, isAdult: isAdult,
isOnlyRental: isOnlyRental, isOnlyRental: isOnlyRental,

View File

@ -12,6 +12,8 @@ struct CreateAudioContentRequest: Encodable {
let detail: String let detail: String
let tags: String let tags: String
let price: Int let price: Int
let releaseDate: String?
let timezone: String
let themeId: Int let themeId: Int
let isAdult: Bool let isAdult: Bool
let isOnlyRental: Bool let isOnlyRental: Bool

View File

@ -0,0 +1,63 @@
//
// QuarterTimePickerView.swift
// SodaLive
//
// Created by klaus on 2024/01/10.
//
import SwiftUI
struct QuarterTimePickerView: View {
@Binding var selectedTime: Date
@Binding var isShowing: Bool
var body: some View {
GeometryReader { proxy in
ZStack {
Color
.black
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
VStack(spacing: 0) {
DatePicker(
"",
selection: $selectedTime,
displayedComponents: .hourAndMinute
)
.datePickerStyle(WheelDatePickerStyle())
.labelsHidden()
.environment(\.locale, Locale.init(identifier: "ko"))
.frame(width: proxy.size.width - 53.4)
.onAppear {
UIDatePicker.appearance().minuteInterval = 15
}
.onDisappear {
UIDatePicker.appearance().minuteInterval = 1
}
Button(action: { self.isShowing = false }) {
Text("확인")
.font(.system(size: 16))
.foregroundColor(Color(hex: "eeeeee"))
.padding(.vertical, 10)
.frame(width: proxy.size.width)
}
}
.background(Color(hex: "222222"))
.cornerRadius(6.7)
}
.frame(width: proxy.size.width)
}
}
}
struct QuarterTimePickerView_Previews: PreviewProvider {
static var previews: some View {
QuarterTimePickerView(
selectedTime: .constant(Date()),
isShowing: .constant(true)
)
}
}

View File

@ -0,0 +1,53 @@
//
// SelectDatePicker.swift
// SodaLive
//
// Created by klaus on 2024/01/10.
//
import SwiftUI
struct SelectDatePicker: View {
@Binding var selectedDate: Date
@Binding var isShowing: Bool
var body: some View {
GeometryReader { proxy in
ZStack {
Color
.black
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
VStack(spacing: 0) {
DatePicker("", selection: $selectedDate, in: Date()..., displayedComponents: .date)
.datePickerStyle(WheelDatePickerStyle())
.labelsHidden()
.environment(\.locale, Locale.init(identifier: "ko"))
.frame(width: proxy.size.width)
Button(action: { self.isShowing = false }) {
Text("확인")
.font(.system(size: 16))
.foregroundColor(Color(hex: "eeeeee"))
.padding(.vertical, 10)
.frame(width: proxy.size.width - 53.4)
}
}
.background(Color(hex: "222222"))
.cornerRadius(6.7)
}
.frame(width: proxy.size.width)
}
}
}
struct SelectDatePicker_Previews: PreviewProvider {
static var previews: some View {
SelectDatePicker(
selectedDate: .constant(Date()),
isShowing: .constant(true)
)
}
}