From 696aed5c00ff397d18254d9c90476725b8f2923b Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Fri, 8 Nov 2024 20:26:42 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20-=20=EC=86=8C=EC=9E=A5=EB=A7=8C=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=ED=95=9C=20=EC=BD=98=ED=85=90=EC=B8=A0=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Create/ContentCreateView.swift | 24 ++++++++++++------- .../Create/ContentCreateViewModel.swift | 8 +++---- .../Create/CreateAudioContentRequest.swift | 2 +- SodaLive/Sources/Content/PurchaseOption.swift | 10 ++++++++ 4 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 SodaLive/Sources/Content/PurchaseOption.swift 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 +}