Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
41b7247a44 | ||
![]() |
63a259f890 | ||
![]() |
7c8f9b1460 | ||
![]() |
27df89d78e | ||
![]() |
cf7f1527b7 | ||
![]() |
68675ebfe8 | ||
![]() |
0079f248ee | ||
![]() |
6583e07f45 | ||
![]() |
902b772267 | ||
![]() |
cdad53ae7b | ||
![]() |
995c6adab7 |
@@ -31,6 +31,14 @@ struct ContentRankingAllView: View {
|
||||
.background(Color(hex: "222222"))
|
||||
.padding(.top, 13.3)
|
||||
|
||||
ContentMainRankingSortView(
|
||||
sorts: viewModel.contentRankingSortList,
|
||||
selectSort: { viewModel.selectedContentRankingSort = $0 },
|
||||
selectedSort: $viewModel.selectedContentRankingSort
|
||||
)
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
.padding(.vertical, 16.7)
|
||||
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack(spacing: 20) {
|
||||
ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in
|
||||
@@ -141,6 +149,7 @@ struct ContentRankingAllView: View {
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
viewModel.getContentRankingSortType()
|
||||
viewModel.getContentRanking()
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,15 @@ final class ContentRankingAllViewModel: ObservableObject {
|
||||
|
||||
@Published var dateString = ""
|
||||
@Published var contentRankingItemList = [GetAudioContentRankingItem]()
|
||||
@Published var contentRankingSortList = [String]()
|
||||
|
||||
@Published var selectedContentRankingSort = "매출" {
|
||||
didSet {
|
||||
page = 1
|
||||
isLast = false
|
||||
getContentRanking()
|
||||
}
|
||||
}
|
||||
|
||||
var page = 1
|
||||
var isLast = false
|
||||
@@ -28,7 +37,7 @@ final class ContentRankingAllViewModel: ObservableObject {
|
||||
if (!isLast && !isLoading && page <= 5) {
|
||||
isLoading = true
|
||||
|
||||
repository.getContentRanking(page: page, size: pageSize)
|
||||
repository.getContentRanking(page: page, size: pageSize, sortType: selectedContentRankingSort)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
@@ -76,4 +85,40 @@ final class ContentRankingAllViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
}
|
||||
|
||||
func getContentRankingSortType() {
|
||||
repository.getContentRankingSortType()
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: { [unowned self] response in
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
let jsonDecoder = JSONDecoder()
|
||||
let decoded = try jsonDecoder.decode(ApiResponse<[String]>.self, from: responseData)
|
||||
|
||||
if let data = decoded.data, decoded.success {
|
||||
self.contentRankingSortList.removeAll()
|
||||
self.contentRankingSortList.append(contentsOf: data)
|
||||
} 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)
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,8 @@ enum ContentApi {
|
||||
case getNewContentThemeList
|
||||
case getNewContentAllOfTheme(theme: String, page: Int, size: Int)
|
||||
case getAudioContentListByCurationId(curationId: Int, page: Int, size: Int, sort: ContentCurationViewModel.Sort)
|
||||
case getContentRanking(page: Int, size: Int)
|
||||
case getContentRanking(page: Int, size: Int, sortType: String)
|
||||
case getContentRankingSortType
|
||||
}
|
||||
|
||||
extension ContentApi: TargetType {
|
||||
@@ -101,6 +102,9 @@ extension ContentApi: TargetType {
|
||||
|
||||
case .getContentRanking:
|
||||
return "/audio-content/ranking"
|
||||
|
||||
case .getContentRankingSortType:
|
||||
return "/audio-content/ranking-sort-type"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +112,8 @@ extension ContentApi: TargetType {
|
||||
switch self {
|
||||
case .getAudioContentList, .getAudioContentDetail, .getOrderList, .getAudioContentThemeList,
|
||||
.getAudioContentCommentList, .getAudioContentCommentReplyList, .getMain, .getNewContentOfTheme,
|
||||
.getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking:
|
||||
.getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking,
|
||||
.getContentRankingSortType:
|
||||
return .get
|
||||
|
||||
case .likeContent, .modifyAudioContent, .modifyComment:
|
||||
@@ -220,13 +225,17 @@ extension ContentApi: TargetType {
|
||||
|
||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||
|
||||
case .getContentRanking(let page, let size):
|
||||
case .getContentRanking(let page, let size, let sortType):
|
||||
let parameters = [
|
||||
"page": page - 1,
|
||||
"size": size,
|
||||
"sort-type": sortType
|
||||
] as [String : Any]
|
||||
|
||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||
|
||||
case .getContentRankingSortType:
|
||||
return .requestPlain
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -93,7 +93,11 @@ final class ContentRepository {
|
||||
return api.requestPublisher(.getAudioContentListByCurationId(curationId: curationId, page: page, size: size, sort: sort))
|
||||
}
|
||||
|
||||
func getContentRanking(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getContentRanking(page: page, size: size))
|
||||
func getContentRankingSortType() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getContentRankingSortType)
|
||||
}
|
||||
|
||||
func getContentRanking(page: Int, size: Int, sortType: String = "매출") -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getContentRanking(page: page, size: size, sortType: sortType))
|
||||
}
|
||||
}
|
||||
|
@@ -194,7 +194,7 @@ struct ContentCreateView: View {
|
||||
.padding(.top, 26.7)
|
||||
|
||||
VStack(spacing: 13.3) {
|
||||
Text("가격설정")
|
||||
Text("가격 설정")
|
||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -214,8 +214,30 @@ struct ContentCreateView: View {
|
||||
}
|
||||
|
||||
if !viewModel.isFree {
|
||||
VStack(spacing: 13.3) {
|
||||
Text("소장 설정")
|
||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
HStack(spacing: 13.3) {
|
||||
SelectButtonView(title: "소장/대여", isChecked: !viewModel.isOnlyRental) {
|
||||
if viewModel.isOnlyRental {
|
||||
viewModel.isOnlyRental = false
|
||||
}
|
||||
}
|
||||
|
||||
SelectButtonView(title: "대여만", isChecked: viewModel.isOnlyRental) {
|
||||
if !viewModel.isOnlyRental {
|
||||
viewModel.isOnlyRental = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 13.3)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
Text("소장가격")
|
||||
Text(viewModel.isOnlyRental ? "대여 가격" : "소장 가격")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "d2d2d2"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -247,7 +269,7 @@ struct ContentCreateView: View {
|
||||
.frame(height: 1)
|
||||
.padding(.top, 11)
|
||||
|
||||
Text("※ 이용기간 대여 (7일) | 소장 (서비스종료시까지)")
|
||||
Text("※ 이용기간 대여 (15일) | 소장 (서비스종료시까지)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -321,60 +343,62 @@ struct ContentCreateView: View {
|
||||
.padding(.top, 26.7)
|
||||
.padding(.horizontal, 13.3)
|
||||
|
||||
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)
|
||||
}
|
||||
if !viewModel.isFree {
|
||||
VStack(spacing: 10) {
|
||||
Text("미리듣기 시간 설정")
|
||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
VStack(spacing: 5.3) {
|
||||
Text("종료 시간")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "d2d2d2"))
|
||||
.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)
|
||||
}
|
||||
|
||||
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)
|
||||
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, 3.3)
|
||||
.padding(.top, 26.7)
|
||||
.padding(.horizontal, 13.3)
|
||||
}
|
||||
.padding(.top, 26.7)
|
||||
.padding(.horizontal, 13.3)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
|
@@ -54,10 +54,13 @@ final class ContentCreateViewModel: ObservableObject {
|
||||
didSet {
|
||||
if isFree {
|
||||
priceString = "0"
|
||||
isOnlyRental = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published var isOnlyRental = false
|
||||
|
||||
@Published var previewStartTime: String = ""
|
||||
@Published var previewEndTime: String = ""
|
||||
|
||||
@@ -74,6 +77,7 @@ final class ContentCreateViewModel: ObservableObject {
|
||||
price: price,
|
||||
themeId: theme!.id,
|
||||
isAdult: isAdult,
|
||||
isOnlyRental: isOnlyRental,
|
||||
isCommentAvailable: isAvailableComment,
|
||||
previewStartTime: previewStartTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewStartTime : nil,
|
||||
previewEndTime: previewEndTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewEndTime : nil
|
||||
|
@@ -14,6 +14,7 @@ struct CreateAudioContentRequest: Encodable {
|
||||
let price: Int
|
||||
let themeId: Int
|
||||
let isAdult: Bool
|
||||
let isOnlyRental: Bool
|
||||
let isCommentAvailable: Bool
|
||||
let previewStartTime: String?
|
||||
let previewEndTime: String?
|
||||
|
@@ -10,6 +10,7 @@ import SwiftUI
|
||||
struct ContentDetailPurchaseButton: View {
|
||||
|
||||
let price: Int
|
||||
let isOnlyRental: Bool
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
@@ -26,7 +27,7 @@ struct ContentDetailPurchaseButton: View {
|
||||
.font(.custom(Font.light.rawValue, size: 12))
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text(" 구매하기")
|
||||
Text(isOnlyRental ? " 대여하기" : " 구매하기")
|
||||
.font(.custom(Font.bold.rawValue, size: 14.7))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
|
@@ -91,7 +91,7 @@ struct ContentDetailView: View {
|
||||
!audioContent.existOrdered &&
|
||||
audioContent.orderType == nil &&
|
||||
audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) {
|
||||
ContentDetailPurchaseButton(price: audioContent.price)
|
||||
ContentDetailPurchaseButton(price: audioContent.price, isOnlyRental: audioContent.isOnlyRental)
|
||||
.contentShape(Rectangle())
|
||||
.padding(.horizontal, 13.3)
|
||||
.onTapGesture { isShowOrderView = true }
|
||||
@@ -161,6 +161,7 @@ struct ContentDetailView: View {
|
||||
ContentOrderDialogView(
|
||||
isShowing: $isShowOrderView,
|
||||
price: audioContent.price,
|
||||
isOnlyRental: audioContent.isOnlyRental,
|
||||
onTapPurchase: {
|
||||
viewModel.orderType = $0
|
||||
isShowOrderConfirmView = true
|
||||
@@ -186,6 +187,7 @@ struct ContentDetailView: View {
|
||||
isShowing: $isShowOrderConfirmView,
|
||||
audioContent: audioContent,
|
||||
orderType: orderType,
|
||||
isOnlyRental: audioContent.isOnlyRental,
|
||||
onClickConfirm: {
|
||||
viewModel.order(orderType: orderType)
|
||||
}
|
||||
|
@@ -298,13 +298,18 @@ final class ContentDetailViewModel: ObservableObject {
|
||||
|
||||
if decoded.success {
|
||||
self.orderType = nil
|
||||
self.errorMessage = "구매가 완료되었습니다."
|
||||
self.errorMessage = orderType == .RENTAL ? "대여가 완료되었습니다." : "구매가 완료되었습니다."
|
||||
self.isShowPopup = true
|
||||
self.getAudioContentDetail()
|
||||
ContentPlayManager.shared.conditionalStopAudio(contentId: contentId)
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
if message.contains("캔이 부족합니다") {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||
AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ struct ContentOrderConfirmDialogView: View {
|
||||
|
||||
let audioContent: GetAudioContentDetailResponse
|
||||
let orderType: OrderType
|
||||
let isOnlyRental: Bool
|
||||
let onClickConfirm: () -> Void
|
||||
|
||||
var body: some View {
|
||||
@@ -90,9 +91,15 @@ struct ContentOrderConfirmDialogView: View {
|
||||
.resizable()
|
||||
.frame(width: 16.7, height: 16.7)
|
||||
|
||||
Text("\(orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.6)) : audioContent.price)")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
if orderType == .RENTAL {
|
||||
Text("\(isOnlyRental ? audioContent.price : Int(ceil(Double(audioContent.price) * 0.6)))")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
} else {
|
||||
Text("\(audioContent.price)")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ struct ContentOrderDialogView: View {
|
||||
@Binding var isShowing: Bool
|
||||
|
||||
let price: Int
|
||||
let isOnlyRental: Bool
|
||||
let onTapPurchase: (OrderType) -> Void
|
||||
|
||||
var body: some View {
|
||||
@@ -31,7 +32,7 @@ struct ContentOrderDialogView: View {
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text("(이용기간 7일)")
|
||||
Text("(이용기간 15일)")
|
||||
.font(.custom(Font.light.rawValue, size: 12))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
@@ -43,7 +44,7 @@ struct ContentOrderDialogView: View {
|
||||
.resizable()
|
||||
.frame(width: 16.7, height: 16.7)
|
||||
|
||||
Text("\(Int(ceil(Double(price) * 0.6)))")
|
||||
Text(isOnlyRental ? "\(price)" : "\(Int(ceil(Double(price) * 0.6)))")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
}
|
||||
@@ -57,35 +58,37 @@ struct ContentOrderDialogView: View {
|
||||
}
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
VStack(alignment: .leading, spacing: 5.3) {
|
||||
Text("소장")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(.white)
|
||||
if !isOnlyRental {
|
||||
HStack(spacing: 0) {
|
||||
VStack(alignment: .leading, spacing: 5.3) {
|
||||
Text("소장")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text("(서비스 종료시까지)")
|
||||
.font(.custom(Font.light.rawValue, size: 12))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
|
||||
Text("(서비스 종료시까지)")
|
||||
.font(.custom(Font.light.rawValue, size: 12))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
HStack(spacing: 8) {
|
||||
Image("ic_can")
|
||||
.resizable()
|
||||
.frame(width: 16.7, height: 16.7)
|
||||
Spacer()
|
||||
|
||||
Text("\(price)")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
.padding(.horizontal, 13.3)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.cornerRadius(5.3)
|
||||
.onTapGesture {
|
||||
onTapPurchase(.KEEP)
|
||||
isShowing = false
|
||||
HStack(spacing: 8) {
|
||||
Image("ic_can")
|
||||
.resizable()
|
||||
.frame(width: 16.7, height: 16.7)
|
||||
|
||||
Text("\(price)")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
.padding(.horizontal, 13.3)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.cornerRadius(5.3)
|
||||
.onTapGesture {
|
||||
onTapPurchase(.KEEP)
|
||||
isShowing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ struct GetAudioContentDetailResponse: Decodable {
|
||||
let duration: String
|
||||
let isAdult: Bool
|
||||
let isMosaic: Bool
|
||||
let isOnlyRental: Bool
|
||||
let existOrdered: Bool
|
||||
let orderType: OrderType?
|
||||
let remainingTime: String?
|
||||
|
@@ -60,7 +60,7 @@ struct LiveRoomDonationDialogView: View {
|
||||
Image("ic_forward")
|
||||
}
|
||||
.onTapGesture {
|
||||
AppState.shared.setAppStep(step: .canCharge(refresh: {}))
|
||||
AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true))
|
||||
self.isShowing = false
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,6 @@ struct ContentMainItemView_Previews: PreviewProvider {
|
||||
contentId: 2,
|
||||
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
title: "ㅓ처랴햐햫햐햐",
|
||||
isAdult: true,
|
||||
creatorId: 8,
|
||||
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
creatorNickname: "유저2"
|
||||
|
@@ -48,7 +48,6 @@ struct ContentMainMyStashView_Previews: PreviewProvider {
|
||||
contentId: 1,
|
||||
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
title: "테스트",
|
||||
isAdult: false,
|
||||
creatorId: 7,
|
||||
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
creatorNickname: "유저1"
|
||||
|
@@ -55,7 +55,6 @@ struct ContentMainNewContentView_Previews: PreviewProvider {
|
||||
contentId: 1,
|
||||
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
title: "테스트",
|
||||
isAdult: false,
|
||||
creatorId: 7,
|
||||
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
creatorNickname: "유저1"
|
||||
|
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ContentMainRankingSortView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/11/03.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentMainRankingSortView: View {
|
||||
let sorts: [String]
|
||||
let selectSort: (String) -> Void
|
||||
|
||||
@Binding var selectedSort: String
|
||||
|
||||
var body: some View {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
ForEach(0..<sorts.count, id: \.self) { index in
|
||||
let sort = sorts[index]
|
||||
Text(sort)
|
||||
.font(.custom(Font.medium.rawValue, size: 14.7))
|
||||
.foregroundColor(Color(hex: selectedSort == sort ? "9970ff" : "777777"))
|
||||
.padding(.horizontal, 13.3)
|
||||
.padding(.vertical, 9.3)
|
||||
.border(
|
||||
Color(hex: selectedSort == sort ? "9970ff" : "eeeeee"),
|
||||
width: 0.5
|
||||
)
|
||||
.cornerRadius(16.7)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: CGFloat(16.7))
|
||||
.stroke(lineWidth: 0.5)
|
||||
.foregroundColor(Color(hex: selectedSort == sort ? "9970ff" : "eeeeee"))
|
||||
)
|
||||
.onTapGesture {
|
||||
if selectedSort != sort {
|
||||
selectSort(sort)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentMainRankingSortView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentMainRankingSortView(
|
||||
sorts: ["전체", "테마1", "테마2"],
|
||||
selectSort: { _ in },
|
||||
selectedSort: .constant("전체")
|
||||
)
|
||||
}
|
||||
}
|
@@ -10,8 +10,12 @@ import Kingfisher
|
||||
|
||||
struct ContentMainRankingView: View {
|
||||
|
||||
let sorts: [String]
|
||||
let item: GetAudioContentRanking
|
||||
|
||||
let selectSort: (String) -> Void
|
||||
@Binding var selectedSort: String
|
||||
|
||||
let rows = [
|
||||
GridItem(.fixed(60), alignment: .leading),
|
||||
GridItem(.fixed(60), alignment: .leading),
|
||||
@@ -47,6 +51,9 @@ struct ContentMainRankingView: View {
|
||||
.background(Color(hex: "222222"))
|
||||
.padding(.top, 13.3)
|
||||
|
||||
ContentMainRankingSortView(sorts: sorts, selectSort: selectSort, selectedSort: $selectedSort)
|
||||
.padding(.vertical, 16.7)
|
||||
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHGrid(rows: rows, spacing: 13.3) {
|
||||
ForEach(0..<item.items.count, id: \.self) { index in
|
||||
@@ -92,6 +99,7 @@ struct ContentMainRankingView: View {
|
||||
struct ContentMainRankingView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentMainRankingView(
|
||||
sorts: ["매출", "후원", "댓글"],
|
||||
item: GetAudioContentRanking(
|
||||
startDate: "2023년 10월 2일",
|
||||
endDate: "10월 9일",
|
||||
@@ -137,7 +145,9 @@ struct ContentMainRankingView_Previews: PreviewProvider {
|
||||
creatorNickname: "ㄹㄴ어ㅏㅣㅇㄴ런아ㅣ"
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
selectSort: { _ in },
|
||||
selectedSort: .constant("매출")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@@ -56,9 +56,15 @@ struct ContentMainView: View {
|
||||
.padding(.horizontal, 13.3)
|
||||
|
||||
if let contentRanking = viewModel.contentRanking {
|
||||
ContentMainRankingView(item: contentRanking)
|
||||
ContentMainRankingView(
|
||||
sorts: viewModel.contentRankingSortList,
|
||||
item: contentRanking,
|
||||
selectSort: { viewModel.selectedContentRankingSort = $0 },
|
||||
selectedSort: $viewModel.selectedContentRankingSort
|
||||
)
|
||||
.padding(.top, 40)
|
||||
.padding(.horizontal, 13.3)
|
||||
.animation(nil)
|
||||
}
|
||||
|
||||
if viewModel.curationList.count > 0 {
|
||||
|
@@ -24,6 +24,7 @@ final class ContentMainViewModel: ObservableObject {
|
||||
@Published var orderList = [GetAudioContentMainItem]()
|
||||
@Published var themeList = [String]()
|
||||
@Published var curationList = [GetAudioContentCurationResponse]()
|
||||
@Published var contentRankingSortList = [String]()
|
||||
@Published var contentRanking: GetAudioContentRanking? = nil
|
||||
|
||||
@Published var selectedTheme = "전체" {
|
||||
@@ -32,6 +33,12 @@ final class ContentMainViewModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Published var selectedContentRankingSort = "매출" {
|
||||
didSet {
|
||||
getContentRanking()
|
||||
}
|
||||
}
|
||||
|
||||
func getMain() {
|
||||
isLoading = true
|
||||
|
||||
@@ -59,6 +66,7 @@ final class ContentMainViewModel: ObservableObject {
|
||||
self.orderList.removeAll()
|
||||
self.curationList.removeAll()
|
||||
self.themeList.removeAll()
|
||||
self.contentRankingSortList.removeAll()
|
||||
|
||||
self.newContentUploadCreatorList.append(contentsOf: data.newContentUploadCreatorList)
|
||||
self.newContentList.append(contentsOf: data.newContentList)
|
||||
@@ -66,6 +74,7 @@ final class ContentMainViewModel: ObservableObject {
|
||||
self.orderList.append(contentsOf: data.orderList)
|
||||
self.curationList.append(contentsOf: data.curationList)
|
||||
self.contentRanking = data.contentRanking
|
||||
self.contentRankingSortList.append(contentsOf: data.contentRankingSortTypeList)
|
||||
|
||||
self.themeList.append("전체")
|
||||
self.themeList.append(contentsOf: data.themeList)
|
||||
@@ -124,4 +133,42 @@ final class ContentMainViewModel: ObservableObject {
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func getContentRanking() {
|
||||
isLoading = true
|
||||
|
||||
repository.getContentRanking(page: 1, size: 12, sortType: selectedContentRankingSort)
|
||||
.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<GetAudioContentRanking>.self, from: responseData)
|
||||
|
||||
if let data = decoded.data, decoded.success {
|
||||
self.contentRanking = data
|
||||
} 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)
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ struct GetAudioContentMainResponse: Decodable {
|
||||
let themeList: [String]
|
||||
let newContentList: [GetAudioContentMainItem]
|
||||
let curationList: [GetAudioContentCurationResponse]
|
||||
let contentRankingSortTypeList: [String]
|
||||
let contentRanking: GetAudioContentRanking
|
||||
}
|
||||
|
||||
@@ -44,7 +45,6 @@ struct GetAudioContentMainItem: Decodable {
|
||||
let contentId: Int
|
||||
let coverImageUrl: String
|
||||
let title: String
|
||||
let isAdult: Bool
|
||||
let creatorId: Int
|
||||
let creatorProfileImageUrl: String
|
||||
let creatorNickname: String
|
||||
|
@@ -784,26 +784,28 @@ struct LiveRoomView: View {
|
||||
viewModel.isShowDonationRankingPopup = true
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text("참여자")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
|
||||
Text("\(liveRoomInfo.participantsCount)")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.padding(.leading, 6.7)
|
||||
}
|
||||
.padding(.horizontal, 11.5)
|
||||
.padding(.vertical, 7.3)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12.8)
|
||||
.strokeBorder(lineWidth: 1)
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
viewModel.isShowProfileList = true
|
||||
if liveRoomInfo.creatorId == UserDefaults.int(forKey: .userId) {
|
||||
HStack(spacing: 0) {
|
||||
Text("참여자")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
|
||||
Text("\(liveRoomInfo.participantsCount)")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.padding(.leading, 6.7)
|
||||
}
|
||||
.padding(.horizontal, 11.5)
|
||||
.padding(.vertical, 7.3)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12.8)
|
||||
.strokeBorder(lineWidth: 1)
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
viewModel.isShowProfileList = true
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 13.3)
|
||||
|
@@ -27,7 +27,7 @@ struct CanPgPaymentView: View {
|
||||
ZStack {
|
||||
Color.black.ignoresSafeArea()
|
||||
|
||||
if viewModel.isShowPamentView {
|
||||
if viewModel.isShowPaymentView {
|
||||
BootpayUI(payload: viewModel.payload, requestType: BootpayRequest.TYPE_PAYMENT)
|
||||
.onConfirm {
|
||||
DEBUG_LOG("onConfirm: \($0)")
|
||||
@@ -38,28 +38,31 @@ struct CanPgPaymentView: View {
|
||||
}
|
||||
.onError {
|
||||
DEBUG_LOG("onError: \($0)")
|
||||
viewModel.isShowPamentView = false
|
||||
viewModel.isShowPaymentView = false
|
||||
viewModel.errorMessage = "결제 중 오류가 발생했습니다."
|
||||
viewModel.isShowPopup = true
|
||||
}
|
||||
.onDone {
|
||||
DEBUG_LOG("onDone: \($0)")
|
||||
viewModel.verifyPayment($0) {
|
||||
self.refresh()
|
||||
|
||||
if afterCompletionToGoBack {
|
||||
AppState.shared.back()
|
||||
} else {
|
||||
AppState.shared.setAppStep(step: .canStatus(refresh: refresh))
|
||||
}
|
||||
|
||||
let can = UserDefaults.int(forKey: .can)
|
||||
UserDefaults.set(can + canResponse.can + canResponse.rewardCan, forKey: .can)
|
||||
|
||||
self.refresh()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
if afterCompletionToGoBack {
|
||||
AppState.shared.back()
|
||||
AppState.shared.back()
|
||||
} else {
|
||||
AppState.shared.setAppStep(step: .canStatus(refresh: refresh))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onClose {
|
||||
DEBUG_LOG("onClose")
|
||||
viewModel.isShowPamentView = false
|
||||
viewModel.isShowPaymentView = false
|
||||
}
|
||||
} else {
|
||||
GeometryReader { proxy in
|
||||
@@ -147,6 +150,33 @@ struct CanPgPaymentView: View {
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
.padding(.top, 16.7)
|
||||
|
||||
HStack(spacing: 13.3) {
|
||||
Text("휴대폰 결제")
|
||||
.font(.custom( viewModel.paymentMethod == .phone ? Font.bold.rawValue : Font.medium.rawValue, size: 16.7))
|
||||
.foregroundColor(Color(hex: viewModel.paymentMethod == .phone ? "9970ff" : "eeeeee"))
|
||||
.frame(width: (screenSize().width - 40) / 2)
|
||||
.padding(.vertical, 16.7)
|
||||
.background(
|
||||
Color(hex: viewModel.paymentMethod == .phone ? "9970ff" : "232323")
|
||||
.opacity(viewModel.paymentMethod == .phone ? 0.3 : 1)
|
||||
)
|
||||
.cornerRadius(10)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.stroke(lineWidth: 1)
|
||||
.foregroundColor(Color(hex: viewModel.paymentMethod == .phone ? "9970ff" : "777777"))
|
||||
)
|
||||
.onTapGesture {
|
||||
if viewModel.paymentMethod != .phone {
|
||||
viewModel.paymentMethod = .phone
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
.padding(.top, 16.7)
|
||||
|
||||
HStack(spacing: 6.7) {
|
||||
Image(viewModel.isTermsAgree ? "btn_select_checked" : "btn_select_normal")
|
||||
.resizable()
|
||||
@@ -252,7 +282,7 @@ struct CanPgPaymentView: View {
|
||||
viewModel.payload.price = Double(canResponse.price)
|
||||
viewModel.payload.taxFree = 0
|
||||
|
||||
viewModel.isShowPamentView = true
|
||||
viewModel.isShowPaymentView = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import Bootpay
|
||||
enum PaymentMethod: String {
|
||||
case card = "디지털카드"
|
||||
case bank = "디지털계좌이체"
|
||||
case phone = "휴대폰"
|
||||
}
|
||||
|
||||
final class CanPgPaymentViewModel: ObservableObject {
|
||||
@@ -25,7 +26,7 @@ final class CanPgPaymentViewModel: ObservableObject {
|
||||
@Published var isShowPopup = false
|
||||
@Published var isLoading = false
|
||||
|
||||
@Published var isShowPamentView = false
|
||||
@Published var isShowPaymentView = false
|
||||
@Published var paymentMethod: PaymentMethod? = nil
|
||||
|
||||
let payload = Payload()
|
||||
@@ -98,6 +99,9 @@ final class CanPgPaymentViewModel: ObservableObject {
|
||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
self.errorMessage = "캔이 충전되었습니다"
|
||||
self.isShowPopup = true
|
||||
|
||||
onSuccess()
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
|
@@ -33,6 +33,24 @@ struct OrderListAllView: View {
|
||||
.frame(height: 50)
|
||||
.background(Color.black)
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text("총 ")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Text("\(viewModel.totalCount)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "dd4500"))
|
||||
|
||||
Text(" 개")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 13.3)
|
||||
.padding(.top, 13.3)
|
||||
|
||||
ScrollViewReader { reader in
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
LazyVStack(spacing: 10.7) {
|
||||
|
@@ -18,6 +18,7 @@ final class OrderListAllViewModel: ObservableObject {
|
||||
@Published var isLoading = false
|
||||
|
||||
@Published var orderList = [GetAudioContentOrderListItem]()
|
||||
@Published var totalCount = 0
|
||||
@Published var scrollToTop = false
|
||||
|
||||
var page = 1
|
||||
@@ -49,6 +50,8 @@ final class OrderListAllViewModel: ObservableObject {
|
||||
self.scrollToTop.toggle()
|
||||
}
|
||||
|
||||
self.totalCount = data.totalCount
|
||||
|
||||
if !data.items.isEmpty {
|
||||
page += 1
|
||||
self.orderList.append(contentsOf: data.items)
|
||||
|
Reference in New Issue
Block a user