11 Commits

27 changed files with 420 additions and 133 deletions

View File

@@ -31,6 +31,14 @@ struct ContentRankingAllView: View {
.background(Color(hex: "222222")) .background(Color(hex: "222222"))
.padding(.top, 13.3) .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) { ScrollView(.vertical, showsIndicators: false) {
VStack(spacing: 20) { VStack(spacing: 20) {
ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in
@@ -141,6 +149,7 @@ struct ContentRankingAllView: View {
} }
} }
.onAppear { .onAppear {
viewModel.getContentRankingSortType()
viewModel.getContentRanking() viewModel.getContentRanking()
} }
} }

View File

@@ -19,6 +19,15 @@ final class ContentRankingAllViewModel: ObservableObject {
@Published var dateString = "" @Published var dateString = ""
@Published var contentRankingItemList = [GetAudioContentRankingItem]() @Published var contentRankingItemList = [GetAudioContentRankingItem]()
@Published var contentRankingSortList = [String]()
@Published var selectedContentRankingSort = "매출" {
didSet {
page = 1
isLast = false
getContentRanking()
}
}
var page = 1 var page = 1
var isLast = false var isLast = false
@@ -28,7 +37,7 @@ final class ContentRankingAllViewModel: ObservableObject {
if (!isLast && !isLoading && page <= 5) { if (!isLast && !isLoading && page <= 5) {
isLoading = true isLoading = true
repository.getContentRanking(page: page, size: pageSize) repository.getContentRanking(page: page, size: pageSize, sortType: selectedContentRankingSort)
.sink { result in .sink { result in
switch result { switch result {
case .finished: case .finished:
@@ -76,4 +85,40 @@ final class ContentRankingAllViewModel: ObservableObject {
.store(in: &subscription) .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)
}
} }

View File

@@ -29,7 +29,8 @@ enum ContentApi {
case getNewContentThemeList case getNewContentThemeList
case getNewContentAllOfTheme(theme: String, page: Int, size: Int) case getNewContentAllOfTheme(theme: String, page: Int, size: Int)
case getAudioContentListByCurationId(curationId: Int, page: Int, size: Int, sort: ContentCurationViewModel.Sort) 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 { extension ContentApi: TargetType {
@@ -101,6 +102,9 @@ extension ContentApi: TargetType {
case .getContentRanking: case .getContentRanking:
return "/audio-content/ranking" return "/audio-content/ranking"
case .getContentRankingSortType:
return "/audio-content/ranking-sort-type"
} }
} }
@@ -108,7 +112,8 @@ extension ContentApi: TargetType {
switch self { switch self {
case .getAudioContentList, .getAudioContentDetail, .getOrderList, .getAudioContentThemeList, case .getAudioContentList, .getAudioContentDetail, .getOrderList, .getAudioContentThemeList,
.getAudioContentCommentList, .getAudioContentCommentReplyList, .getMain, .getNewContentOfTheme, .getAudioContentCommentList, .getAudioContentCommentReplyList, .getMain, .getNewContentOfTheme,
.getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking: .getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking,
.getContentRankingSortType:
return .get return .get
case .likeContent, .modifyAudioContent, .modifyComment: case .likeContent, .modifyAudioContent, .modifyComment:
@@ -220,13 +225,17 @@ extension ContentApi: TargetType {
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
case .getContentRanking(let page, let size): case .getContentRanking(let page, let size, let sortType):
let parameters = [ let parameters = [
"page": page - 1, "page": page - 1,
"size": size, "size": size,
"sort-type": sortType
] as [String : Any] ] as [String : Any]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
case .getContentRankingSortType:
return .requestPlain
} }
} }

View File

@@ -93,7 +93,11 @@ final class ContentRepository {
return api.requestPublisher(.getAudioContentListByCurationId(curationId: curationId, page: page, size: size, sort: sort)) return api.requestPublisher(.getAudioContentListByCurationId(curationId: curationId, page: page, size: size, sort: sort))
} }
func getContentRanking(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> { func getContentRankingSortType() -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.getContentRanking(page: page, size: size)) 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))
} }
} }

View File

@@ -214,8 +214,30 @@ struct ContentCreateView: View {
} }
if !viewModel.isFree { 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) { VStack(spacing: 0) {
Text("소장가격") Text(viewModel.isOnlyRental ? "대여 가격" : "소장 가격")
.font(.custom(Font.medium.rawValue, size: 13.3)) .font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "d2d2d2")) .foregroundColor(Color(hex: "d2d2d2"))
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
@@ -247,7 +269,7 @@ struct ContentCreateView: View {
.frame(height: 1) .frame(height: 1)
.padding(.top, 11) .padding(.top, 11)
Text("※ 이용기간 대여 (7일) | 소장 (서비스종료시까지)") Text("※ 이용기간 대여 (15일) | 소장 (서비스종료시까지)")
.font(.custom(Font.medium.rawValue, size: 13.3)) .font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777")) .foregroundColor(Color(hex: "777777"))
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
@@ -321,6 +343,7 @@ struct ContentCreateView: View {
.padding(.top, 26.7) .padding(.top, 26.7)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
if !viewModel.isFree {
VStack(spacing: 10) { VStack(spacing: 10) {
Text("미리듣기 시간 설정") Text("미리듣기 시간 설정")
.font(.custom(Font.bold.rawValue, size: 16.7)) .font(.custom(Font.bold.rawValue, size: 16.7))
@@ -375,6 +398,7 @@ struct ContentCreateView: View {
} }
.padding(.top, 26.7) .padding(.top, 26.7)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
}
VStack(spacing: 0) { VStack(spacing: 0) {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {

View File

@@ -54,10 +54,13 @@ final class ContentCreateViewModel: ObservableObject {
didSet { didSet {
if isFree { if isFree {
priceString = "0" priceString = "0"
isOnlyRental = false
} }
} }
} }
@Published var isOnlyRental = false
@Published var previewStartTime: String = "" @Published var previewStartTime: String = ""
@Published var previewEndTime: String = "" @Published var previewEndTime: String = ""
@@ -74,6 +77,7 @@ final class ContentCreateViewModel: ObservableObject {
price: price, price: price,
themeId: theme!.id, themeId: theme!.id,
isAdult: isAdult, isAdult: isAdult,
isOnlyRental: isOnlyRental,
isCommentAvailable: isAvailableComment, isCommentAvailable: isAvailableComment,
previewStartTime: previewStartTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewStartTime : nil, previewStartTime: previewStartTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewStartTime : nil,
previewEndTime: previewEndTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewEndTime : nil previewEndTime: previewEndTime.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 ? previewEndTime : nil

View File

@@ -14,6 +14,7 @@ struct CreateAudioContentRequest: Encodable {
let price: Int let price: Int
let themeId: Int let themeId: Int
let isAdult: Bool let isAdult: Bool
let isOnlyRental: Bool
let isCommentAvailable: Bool let isCommentAvailable: Bool
let previewStartTime: String? let previewStartTime: String?
let previewEndTime: String? let previewEndTime: String?

View File

@@ -10,6 +10,7 @@ import SwiftUI
struct ContentDetailPurchaseButton: View { struct ContentDetailPurchaseButton: View {
let price: Int let price: Int
let isOnlyRental: Bool
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
@@ -26,7 +27,7 @@ struct ContentDetailPurchaseButton: View {
.font(.custom(Font.light.rawValue, size: 12)) .font(.custom(Font.light.rawValue, size: 12))
.foregroundColor(.white) .foregroundColor(.white)
Text(" 구매하기") Text(isOnlyRental ? " 대여하기" : " 구매하기")
.font(.custom(Font.bold.rawValue, size: 14.7)) .font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(.white) .foregroundColor(.white)
} }

View File

@@ -91,7 +91,7 @@ struct ContentDetailView: View {
!audioContent.existOrdered && !audioContent.existOrdered &&
audioContent.orderType == nil && audioContent.orderType == nil &&
audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) { audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) {
ContentDetailPurchaseButton(price: audioContent.price) ContentDetailPurchaseButton(price: audioContent.price, isOnlyRental: audioContent.isOnlyRental)
.contentShape(Rectangle()) .contentShape(Rectangle())
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
.onTapGesture { isShowOrderView = true } .onTapGesture { isShowOrderView = true }
@@ -161,6 +161,7 @@ struct ContentDetailView: View {
ContentOrderDialogView( ContentOrderDialogView(
isShowing: $isShowOrderView, isShowing: $isShowOrderView,
price: audioContent.price, price: audioContent.price,
isOnlyRental: audioContent.isOnlyRental,
onTapPurchase: { onTapPurchase: {
viewModel.orderType = $0 viewModel.orderType = $0
isShowOrderConfirmView = true isShowOrderConfirmView = true
@@ -186,6 +187,7 @@ struct ContentDetailView: View {
isShowing: $isShowOrderConfirmView, isShowing: $isShowOrderConfirmView,
audioContent: audioContent, audioContent: audioContent,
orderType: orderType, orderType: orderType,
isOnlyRental: audioContent.isOnlyRental,
onClickConfirm: { onClickConfirm: {
viewModel.order(orderType: orderType) viewModel.order(orderType: orderType)
} }

View File

@@ -298,13 +298,18 @@ final class ContentDetailViewModel: ObservableObject {
if decoded.success { if decoded.success {
self.orderType = nil self.orderType = nil
self.errorMessage = "구매가 완료되었습니다." self.errorMessage = orderType == .RENTAL ? "대여가 완료되었습니다." : "구매가 완료되었습니다."
self.isShowPopup = true self.isShowPopup = true
self.getAudioContentDetail() self.getAudioContentDetail()
ContentPlayManager.shared.conditionalStopAudio(contentId: contentId) ContentPlayManager.shared.conditionalStopAudio(contentId: contentId)
} else { } else {
if let message = decoded.message { if let message = decoded.message {
self.errorMessage = message self.errorMessage = message
if message.contains("캔이 부족합니다") {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true))
}
}
} else { } else {
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
} }

View File

@@ -14,6 +14,7 @@ struct ContentOrderConfirmDialogView: View {
let audioContent: GetAudioContentDetailResponse let audioContent: GetAudioContentDetailResponse
let orderType: OrderType let orderType: OrderType
let isOnlyRental: Bool
let onClickConfirm: () -> Void let onClickConfirm: () -> Void
var body: some View { var body: some View {
@@ -90,9 +91,15 @@ struct ContentOrderConfirmDialogView: View {
.resizable() .resizable()
.frame(width: 16.7, height: 16.7) .frame(width: 16.7, height: 16.7)
Text("\(orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.6)) : audioContent.price)") if orderType == .RENTAL {
Text("\(isOnlyRental ? audioContent.price : Int(ceil(Double(audioContent.price) * 0.6)))")
.font(.custom(Font.bold.rawValue, size: 13.3)) .font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee")) .foregroundColor(Color(hex: "eeeeee"))
} else {
Text("\(audioContent.price)")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
}
Spacer() Spacer()
} }

View File

@@ -12,6 +12,7 @@ struct ContentOrderDialogView: View {
@Binding var isShowing: Bool @Binding var isShowing: Bool
let price: Int let price: Int
let isOnlyRental: Bool
let onTapPurchase: (OrderType) -> Void let onTapPurchase: (OrderType) -> Void
var body: some View { var body: some View {
@@ -31,7 +32,7 @@ struct ContentOrderDialogView: View {
.font(.custom(Font.bold.rawValue, size: 13.3)) .font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(.white) .foregroundColor(.white)
Text("(이용기간 7일)") Text("(이용기간 15일)")
.font(.custom(Font.light.rawValue, size: 12)) .font(.custom(Font.light.rawValue, size: 12))
.foregroundColor(.white) .foregroundColor(.white)
} }
@@ -43,7 +44,7 @@ struct ContentOrderDialogView: View {
.resizable() .resizable()
.frame(width: 16.7, height: 16.7) .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)) .font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee")) .foregroundColor(Color(hex: "eeeeee"))
} }
@@ -57,6 +58,7 @@ struct ContentOrderDialogView: View {
} }
} }
if !isOnlyRental {
HStack(spacing: 0) { HStack(spacing: 0) {
VStack(alignment: .leading, spacing: 5.3) { VStack(alignment: .leading, spacing: 5.3) {
Text("소장") Text("소장")
@@ -89,6 +91,7 @@ struct ContentOrderDialogView: View {
} }
} }
} }
}
.padding(24) .padding(24)
.background(Color(hex: "222222")) .background(Color(hex: "222222"))
} }

View File

@@ -19,6 +19,7 @@ struct GetAudioContentDetailResponse: Decodable {
let duration: String let duration: String
let isAdult: Bool let isAdult: Bool
let isMosaic: Bool let isMosaic: Bool
let isOnlyRental: Bool
let existOrdered: Bool let existOrdered: Bool
let orderType: OrderType? let orderType: OrderType?
let remainingTime: String? let remainingTime: String?

View File

@@ -60,7 +60,7 @@ struct LiveRoomDonationDialogView: View {
Image("ic_forward") Image("ic_forward")
} }
.onTapGesture { .onTapGesture {
AppState.shared.setAppStep(step: .canCharge(refresh: {})) AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true))
self.isShowing = false self.isShowing = false
} }
} }

View File

@@ -57,7 +57,6 @@ struct ContentMainItemView_Previews: PreviewProvider {
contentId: 2, contentId: 2,
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
title: "ㅓ처랴햐햫햐햐", title: "ㅓ처랴햐햫햐햐",
isAdult: true,
creatorId: 8, creatorId: 8,
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "유저2" creatorNickname: "유저2"

View File

@@ -48,7 +48,6 @@ struct ContentMainMyStashView_Previews: PreviewProvider {
contentId: 1, contentId: 1,
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
title: "테스트", title: "테스트",
isAdult: false,
creatorId: 7, creatorId: 7,
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "유저1" creatorNickname: "유저1"

View File

@@ -55,7 +55,6 @@ struct ContentMainNewContentView_Previews: PreviewProvider {
contentId: 1, contentId: 1,
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
title: "테스트", title: "테스트",
isAdult: false,
creatorId: 7, creatorId: 7,
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "유저1" creatorNickname: "유저1"

View File

@@ -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("전체")
)
}
}

View File

@@ -10,8 +10,12 @@ import Kingfisher
struct ContentMainRankingView: View { struct ContentMainRankingView: View {
let sorts: [String]
let item: GetAudioContentRanking let item: GetAudioContentRanking
let selectSort: (String) -> Void
@Binding var selectedSort: String
let rows = [ let rows = [
GridItem(.fixed(60), alignment: .leading), GridItem(.fixed(60), alignment: .leading),
GridItem(.fixed(60), alignment: .leading), GridItem(.fixed(60), alignment: .leading),
@@ -47,6 +51,9 @@ struct ContentMainRankingView: View {
.background(Color(hex: "222222")) .background(Color(hex: "222222"))
.padding(.top, 13.3) .padding(.top, 13.3)
ContentMainRankingSortView(sorts: sorts, selectSort: selectSort, selectedSort: $selectedSort)
.padding(.vertical, 16.7)
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
LazyHGrid(rows: rows, spacing: 13.3) { LazyHGrid(rows: rows, spacing: 13.3) {
ForEach(0..<item.items.count, id: \.self) { index in ForEach(0..<item.items.count, id: \.self) { index in
@@ -92,6 +99,7 @@ struct ContentMainRankingView: View {
struct ContentMainRankingView_Previews: PreviewProvider { struct ContentMainRankingView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
ContentMainRankingView( ContentMainRankingView(
sorts: ["매출", "후원", "댓글"],
item: GetAudioContentRanking( item: GetAudioContentRanking(
startDate: "2023년 10월 2일", startDate: "2023년 10월 2일",
endDate: "10월 9일", endDate: "10월 9일",
@@ -137,7 +145,9 @@ struct ContentMainRankingView_Previews: PreviewProvider {
creatorNickname: "ㄹㄴ어ㅏㅣㅇㄴ런아ㅣ" creatorNickname: "ㄹㄴ어ㅏㅣㅇㄴ런아ㅣ"
), ),
] ]
) ),
selectSort: { _ in },
selectedSort: .constant("매출")
) )
} }
} }

View File

@@ -56,9 +56,15 @@ struct ContentMainView: View {
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
if let contentRanking = viewModel.contentRanking { 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(.top, 40)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
.animation(nil)
} }
if viewModel.curationList.count > 0 { if viewModel.curationList.count > 0 {

View File

@@ -24,6 +24,7 @@ final class ContentMainViewModel: ObservableObject {
@Published var orderList = [GetAudioContentMainItem]() @Published var orderList = [GetAudioContentMainItem]()
@Published var themeList = [String]() @Published var themeList = [String]()
@Published var curationList = [GetAudioContentCurationResponse]() @Published var curationList = [GetAudioContentCurationResponse]()
@Published var contentRankingSortList = [String]()
@Published var contentRanking: GetAudioContentRanking? = nil @Published var contentRanking: GetAudioContentRanking? = nil
@Published var selectedTheme = "전체" { @Published var selectedTheme = "전체" {
@@ -32,6 +33,12 @@ final class ContentMainViewModel: ObservableObject {
} }
} }
@Published var selectedContentRankingSort = "매출" {
didSet {
getContentRanking()
}
}
func getMain() { func getMain() {
isLoading = true isLoading = true
@@ -59,6 +66,7 @@ final class ContentMainViewModel: ObservableObject {
self.orderList.removeAll() self.orderList.removeAll()
self.curationList.removeAll() self.curationList.removeAll()
self.themeList.removeAll() self.themeList.removeAll()
self.contentRankingSortList.removeAll()
self.newContentUploadCreatorList.append(contentsOf: data.newContentUploadCreatorList) self.newContentUploadCreatorList.append(contentsOf: data.newContentUploadCreatorList)
self.newContentList.append(contentsOf: data.newContentList) self.newContentList.append(contentsOf: data.newContentList)
@@ -66,6 +74,7 @@ final class ContentMainViewModel: ObservableObject {
self.orderList.append(contentsOf: data.orderList) self.orderList.append(contentsOf: data.orderList)
self.curationList.append(contentsOf: data.curationList) self.curationList.append(contentsOf: data.curationList)
self.contentRanking = data.contentRanking self.contentRanking = data.contentRanking
self.contentRankingSortList.append(contentsOf: data.contentRankingSortTypeList)
self.themeList.append("전체") self.themeList.append("전체")
self.themeList.append(contentsOf: data.themeList) self.themeList.append(contentsOf: data.themeList)
@@ -124,4 +133,42 @@ final class ContentMainViewModel: ObservableObject {
} }
.store(in: &subscription) .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)
}
} }

View File

@@ -14,6 +14,7 @@ struct GetAudioContentMainResponse: Decodable {
let themeList: [String] let themeList: [String]
let newContentList: [GetAudioContentMainItem] let newContentList: [GetAudioContentMainItem]
let curationList: [GetAudioContentCurationResponse] let curationList: [GetAudioContentCurationResponse]
let contentRankingSortTypeList: [String]
let contentRanking: GetAudioContentRanking let contentRanking: GetAudioContentRanking
} }
@@ -44,7 +45,6 @@ struct GetAudioContentMainItem: Decodable {
let contentId: Int let contentId: Int
let coverImageUrl: String let coverImageUrl: String
let title: String let title: String
let isAdult: Bool
let creatorId: Int let creatorId: Int
let creatorProfileImageUrl: String let creatorProfileImageUrl: String
let creatorNickname: String let creatorNickname: String

View File

@@ -784,6 +784,7 @@ struct LiveRoomView: View {
viewModel.isShowDonationRankingPopup = true viewModel.isShowDonationRankingPopup = true
} }
if liveRoomInfo.creatorId == UserDefaults.int(forKey: .userId) {
HStack(spacing: 0) { HStack(spacing: 0) {
Text("참여자") Text("참여자")
.font(.custom(Font.medium.rawValue, size: 12)) .font(.custom(Font.medium.rawValue, size: 12))
@@ -806,6 +807,7 @@ struct LiveRoomView: View {
viewModel.isShowProfileList = true viewModel.isShowProfileList = true
} }
} }
}
.padding(.top, 13.3) .padding(.top, 13.3)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
} }

View File

@@ -27,7 +27,7 @@ struct CanPgPaymentView: View {
ZStack { ZStack {
Color.black.ignoresSafeArea() Color.black.ignoresSafeArea()
if viewModel.isShowPamentView { if viewModel.isShowPaymentView {
BootpayUI(payload: viewModel.payload, requestType: BootpayRequest.TYPE_PAYMENT) BootpayUI(payload: viewModel.payload, requestType: BootpayRequest.TYPE_PAYMENT)
.onConfirm { .onConfirm {
DEBUG_LOG("onConfirm: \($0)") DEBUG_LOG("onConfirm: \($0)")
@@ -38,28 +38,31 @@ struct CanPgPaymentView: View {
} }
.onError { .onError {
DEBUG_LOG("onError: \($0)") DEBUG_LOG("onError: \($0)")
viewModel.isShowPamentView = false viewModel.isShowPaymentView = false
viewModel.errorMessage = "결제 중 오류가 발생했습니다." viewModel.errorMessage = "결제 중 오류가 발생했습니다."
viewModel.isShowPopup = true viewModel.isShowPopup = true
} }
.onDone { .onDone {
DEBUG_LOG("onDone: \($0)") DEBUG_LOG("onDone: \($0)")
viewModel.verifyPayment($0) { viewModel.verifyPayment($0) {
let can = UserDefaults.int(forKey: .can)
UserDefaults.set(can + canResponse.can + canResponse.rewardCan, forKey: .can)
self.refresh() self.refresh()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if afterCompletionToGoBack { if afterCompletionToGoBack {
AppState.shared.back() AppState.shared.back()
AppState.shared.back()
} else { } else {
AppState.shared.setAppStep(step: .canStatus(refresh: refresh)) AppState.shared.setAppStep(step: .canStatus(refresh: refresh))
} }
}
let can = UserDefaults.int(forKey: .can)
UserDefaults.set(can + canResponse.can + canResponse.rewardCan, forKey: .can)
} }
} }
.onClose { .onClose {
DEBUG_LOG("onClose") DEBUG_LOG("onClose")
viewModel.isShowPamentView = false viewModel.isShowPaymentView = false
} }
} else { } else {
GeometryReader { proxy in GeometryReader { proxy in
@@ -147,6 +150,33 @@ struct CanPgPaymentView: View {
.frame(width: screenSize().width - 26.7) .frame(width: screenSize().width - 26.7)
.padding(.top, 16.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) { HStack(spacing: 6.7) {
Image(viewModel.isTermsAgree ? "btn_select_checked" : "btn_select_normal") Image(viewModel.isTermsAgree ? "btn_select_checked" : "btn_select_normal")
.resizable() .resizable()
@@ -252,7 +282,7 @@ struct CanPgPaymentView: View {
viewModel.payload.price = Double(canResponse.price) viewModel.payload.price = Double(canResponse.price)
viewModel.payload.taxFree = 0 viewModel.payload.taxFree = 0
viewModel.isShowPamentView = true viewModel.isShowPaymentView = true
} }
} }
} }

View File

@@ -13,6 +13,7 @@ import Bootpay
enum PaymentMethod: String { enum PaymentMethod: String {
case card = "디지털카드" case card = "디지털카드"
case bank = "디지털계좌이체" case bank = "디지털계좌이체"
case phone = "휴대폰"
} }
final class CanPgPaymentViewModel: ObservableObject { final class CanPgPaymentViewModel: ObservableObject {
@@ -25,7 +26,7 @@ final class CanPgPaymentViewModel: ObservableObject {
@Published var isShowPopup = false @Published var isShowPopup = false
@Published var isLoading = false @Published var isLoading = false
@Published var isShowPamentView = false @Published var isShowPaymentView = false
@Published var paymentMethod: PaymentMethod? = nil @Published var paymentMethod: PaymentMethod? = nil
let payload = Payload() let payload = Payload()
@@ -98,6 +99,9 @@ final class CanPgPaymentViewModel: ObservableObject {
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
if decoded.success { if decoded.success {
self.errorMessage = "캔이 충전되었습니다"
self.isShowPopup = true
onSuccess() onSuccess()
} else { } else {
if let message = decoded.message { if let message = decoded.message {

View File

@@ -33,6 +33,24 @@ struct OrderListAllView: View {
.frame(height: 50) .frame(height: 50)
.background(Color.black) .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 ScrollViewReader { reader in
ScrollView(.vertical, showsIndicators: false) { ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 10.7) { LazyVStack(spacing: 10.7) {

View File

@@ -18,6 +18,7 @@ final class OrderListAllViewModel: ObservableObject {
@Published var isLoading = false @Published var isLoading = false
@Published var orderList = [GetAudioContentOrderListItem]() @Published var orderList = [GetAudioContentOrderListItem]()
@Published var totalCount = 0
@Published var scrollToTop = false @Published var scrollToTop = false
var page = 1 var page = 1
@@ -49,6 +50,8 @@ final class OrderListAllViewModel: ObservableObject {
self.scrollToTop.toggle() self.scrollToTop.toggle()
} }
self.totalCount = data.totalCount
if !data.items.isEmpty { if !data.items.isEmpty {
page += 1 page += 1
self.orderList.append(contentsOf: data.items) self.orderList.append(contentsOf: data.items)