diff --git a/SodaLive/Sources/Content/Create/ContentCreateView.swift b/SodaLive/Sources/Content/Create/ContentCreateView.swift index da801bd..f4b2749 100644 --- a/SodaLive/Sources/Content/Create/ContentCreateView.swift +++ b/SodaLive/Sources/Content/Create/ContentCreateView.swift @@ -229,16 +229,22 @@ struct ContentCreateView: View { .foregroundColor(Color.grayee) .frame(maxWidth: .infinity, alignment: .leading) - HStack(spacing: 13.3) { - SelectButtonView(title: "소장/대여", isChecked: !viewModel.isOnlyRental) { - if viewModel.isOnlyRental { - viewModel.isOnlyRental = false + HStack(spacing: 6.7) { + SelectButtonView(title: "소장/대여", isChecked: viewModel.purchaseOption == .BOTH) { + if viewModel.purchaseOption != .BOTH { + viewModel.purchaseOption = .BOTH } } - SelectButtonView(title: "대여만", isChecked: viewModel.isOnlyRental) { - if !viewModel.isOnlyRental { - viewModel.isOnlyRental = true + SelectButtonView(title: "소장만", isChecked: viewModel.purchaseOption == .BUY_ONLY) { + if viewModel.purchaseOption != .BUY_ONLY { + viewModel.purchaseOption = .BUY_ONLY + } + } + + SelectButtonView(title: "대여만", isChecked: viewModel.purchaseOption == .RENT_ONLY) { + if viewModel.purchaseOption != .RENT_ONLY { + viewModel.purchaseOption = .RENT_ONLY } } } @@ -246,7 +252,7 @@ struct ContentCreateView: View { .padding(.top, 13.3) VStack(spacing: 0) { - Text(viewModel.isOnlyRental ? "대여 가격" : "소장 가격") + Text(viewModel.purchaseOption == .RENT_ONLY ? "대여 가격" : "소장 가격") .font(.custom(Font.medium.rawValue, size: 13.3)) .foregroundColor(Color.grayd2) .frame(maxWidth: .infinity, alignment: .leading) @@ -296,7 +302,7 @@ struct ContentCreateView: View { } .padding(.top, 26.7) - if viewModel.price > 0 && !viewModel.isOnlyRental { + if viewModel.price > 0 && viewModel.purchaseOption != .RENT_ONLY { 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 38e3b36..fdebf0f 100644 --- a/SodaLive/Sources/Content/Create/ContentCreateViewModel.swift +++ b/SodaLive/Sources/Content/Create/ContentCreateViewModel.swift @@ -56,15 +56,15 @@ final class ContentCreateViewModel: ObservableObject { if isFree { priceString = "0" isLimited = false - isOnlyRental = false isGeneratePreview = true + purchaseOption = PurchaseOption.BOTH } } } - @Published var isOnlyRental = false { + @Published var purchaseOption = PurchaseOption.BOTH { didSet { - if isOnlyRental { + if purchaseOption == .RENT_ONLY { isLimited = false } } @@ -125,12 +125,12 @@ final class ContentCreateViewModel: ObservableObject { detail: detail, tags: hashtags, price: price, + purchaseOption: purchaseOption, limited: limited, releaseDate: isActiveReservation ? "\(releaseDate.convertDateFormat(dateFormat: "yyyy-MM-dd")) \(releaseTime.convertDateFormat(dateFormat: "HH:mm"))" : nil, timezone: TimeZone.current.identifier, themeId: theme!.id, isAdult: isAdult, - isOnlyRental: isOnlyRental, isGeneratePreview: isGeneratePreview, isCommentAvailable: isAvailableComment, previewStartTime: isGeneratePreview && previewStartTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewStartTime : nil, diff --git a/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift b/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift index eef4a56..596f8d8 100644 --- a/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift +++ b/SodaLive/Sources/Content/Create/CreateAudioContentRequest.swift @@ -12,12 +12,12 @@ struct CreateAudioContentRequest: Encodable { let detail: String let tags: String let price: Int + let purchaseOption: PurchaseOption let limited: Int? let releaseDate: String? let timezone: String let themeId: Int let isAdult: Bool - let isOnlyRental: Bool let isGeneratePreview: Bool let isCommentAvailable: Bool let previewStartTime: String? diff --git a/SodaLive/Sources/Content/PurchaseOption.swift b/SodaLive/Sources/Content/PurchaseOption.swift new file mode 100644 index 0000000..5d75498 --- /dev/null +++ b/SodaLive/Sources/Content/PurchaseOption.swift @@ -0,0 +1,10 @@ +// +// PurchaseOption.swift +// SodaLive +// +// Created by klaus on 11/8/24. +// + +enum PurchaseOption: String, Codable { + case BOTH, BUY_ONLY, RENT_ONLY +}