parent
83d51a525b
commit
bcba83a8a7
|
@ -6,7 +6,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import RefreshableScrollView
|
|
||||||
|
|
||||||
struct ContentMainView: View {
|
struct ContentMainView: View {
|
||||||
|
|
||||||
|
@ -16,12 +15,7 @@ struct ContentMainView: View {
|
||||||
ZStack(alignment: .bottomTrailing) {
|
ZStack(alignment: .bottomTrailing) {
|
||||||
Color.black.ignoresSafeArea()
|
Color.black.ignoresSafeArea()
|
||||||
|
|
||||||
RefreshableScrollView(
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
refreshing: $viewModel.isLoading,
|
|
||||||
action: {
|
|
||||||
viewModel.refresh()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
Text("콘텐츠 마켓")
|
Text("콘텐츠 마켓")
|
||||||
.font(.custom(Font.bold.rawValue, size: 21.3))
|
.font(.custom(Font.bold.rawValue, size: 21.3))
|
||||||
|
@ -30,9 +24,7 @@ struct ContentMainView: View {
|
||||||
.padding(.horizontal, 13.3)
|
.padding(.horizontal, 13.3)
|
||||||
|
|
||||||
if !viewModel.isLoading {
|
if !viewModel.isLoading {
|
||||||
ContentMainNewContentCreatorView()
|
ContentMainRecommendSeriesView()
|
||||||
.padding(.bottom, 26.7)
|
|
||||||
.padding(.horizontal, 13.3)
|
|
||||||
|
|
||||||
ContentMainBannerView()
|
ContentMainBannerView()
|
||||||
.padding(.bottom, 26.7)
|
.padding(.bottom, 26.7)
|
||||||
|
@ -124,10 +116,10 @@ struct ContentMainView: View {
|
||||||
AppState.shared.setAppStep(step: .createContent)
|
AppState.shared.setAppStep(step: .createContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if viewModel.isLoading {
|
|
||||||
LoadingView()
|
if viewModel.isLoading {
|
||||||
}
|
LoadingView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
//
|
|
||||||
// ContentMainNewContentCreatorItemView.swift
|
|
||||||
// SodaLive
|
|
||||||
//
|
|
||||||
// Created by klaus on 2023/08/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
import Kingfisher
|
|
||||||
|
|
||||||
struct ContentMainNewContentCreatorItemView: View {
|
|
||||||
|
|
||||||
let item: GetNewContentUploadCreator
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
VStack(spacing: 8) {
|
|
||||||
KFImage(URL(string: item.creatorProfileImageUrl))
|
|
||||||
.resizable()
|
|
||||||
.scaledToFill()
|
|
||||||
.frame(width: screenSize().width * 0.18, height: screenSize().width * 0.18, alignment: .top)
|
|
||||||
.clipShape(Circle())
|
|
||||||
|
|
||||||
Text(item.creatorNickname)
|
|
||||||
.font(.custom(Font.medium.rawValue, size: 11.3))
|
|
||||||
.foregroundColor(Color(hex: "bbbbbb"))
|
|
||||||
.frame(width: screenSize().width * 0.18)
|
|
||||||
.lineLimit(1)
|
|
||||||
}
|
|
||||||
.onTapGesture {
|
|
||||||
AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ContentMainNewContentCreatorItemView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
ContentMainNewContentCreatorItemView(
|
|
||||||
item: GetNewContentUploadCreator(
|
|
||||||
creatorId: 2,
|
|
||||||
creatorNickname: "수다친구112",
|
|
||||||
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
//
|
|
||||||
// ContentMainNewContentCreatorView.swift
|
|
||||||
// SodaLive
|
|
||||||
//
|
|
||||||
// Created by klaus on 2023/08/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct ContentMainNewContentCreatorView: View {
|
|
||||||
|
|
||||||
@StateObject private var viewModel = ContentMainNewContentCreatorViewModel()
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
ZStack {
|
|
||||||
if !viewModel.newContentUploadCreatorList.isEmpty {
|
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
|
||||||
HStack(spacing: 21.3) {
|
|
||||||
ForEach(0..<viewModel.newContentUploadCreatorList.count, id: \.self) { index in
|
|
||||||
let item = viewModel.newContentUploadCreatorList[index]
|
|
||||||
ContentMainNewContentCreatorItemView(item: item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if viewModel.isLoading {
|
|
||||||
ActivityIndicatorView()
|
|
||||||
.frame(width: 100, height: 100)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.onAppear {
|
|
||||||
viewModel.getNewContentUploadCreatorList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ContentMainNewContentCreatorView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
ContentMainNewContentCreatorView()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// ContentMainRecommendSeriesView.swift
|
||||||
|
// SodaLive
|
||||||
|
//
|
||||||
|
// Created by klaus on 5/7/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct ContentMainRecommendSeriesView: View {
|
||||||
|
|
||||||
|
@StateObject private var viewModel = ContentMainRecommendSeriesViewModel()
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
|
if !viewModel.seriesList.isEmpty {
|
||||||
|
VStack(alignment: .leading, spacing: 13.3) {
|
||||||
|
Text("추천 시리즈")
|
||||||
|
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||||
|
.foregroundColor(Color.grayee)
|
||||||
|
|
||||||
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
|
HStack(alignment: .top, spacing: 13.3) {
|
||||||
|
ForEach(0..<viewModel.seriesList.count, id: \.self) {
|
||||||
|
let item = viewModel.seriesList[$0]
|
||||||
|
SeriesListBigItemView(item: item, isVisibleCreator: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.bottom, 26.7)
|
||||||
|
.padding(.horizontal, 13.3)
|
||||||
|
} else {
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onAppear {
|
||||||
|
viewModel.getRecommendSeriesList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
ContentMainRecommendSeriesView()
|
||||||
|
}
|
|
@ -1,28 +1,26 @@
|
||||||
//
|
//
|
||||||
// ContentMainNewContentCreatorViewModel.swift
|
// ContentMainRecommendSeriesViewModel.swift
|
||||||
// SodaLive
|
// SodaLive
|
||||||
//
|
//
|
||||||
// Created by klaus on 2023/12/11.
|
// Created by klaus on 5/7/24.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
final class ContentMainNewContentCreatorViewModel: ObservableObject {
|
final class ContentMainRecommendSeriesViewModel: ObservableObject {
|
||||||
|
|
||||||
private let repository = ContentRepository()
|
private let repository = SeriesRepository()
|
||||||
private var subscription = Set<AnyCancellable>()
|
private var subscription = Set<AnyCancellable>()
|
||||||
|
|
||||||
@Published var errorMessage = ""
|
@Published var errorMessage = ""
|
||||||
@Published var isShowPopup = false
|
@Published var isShowPopup = false
|
||||||
@Published var isLoading = false
|
@Published var isLoading = false
|
||||||
|
|
||||||
@Published var newContentUploadCreatorList = [GetNewContentUploadCreator]()
|
@Published var seriesList = [SeriesListItem]()
|
||||||
|
|
||||||
func getNewContentUploadCreatorList() {
|
func getRecommendSeriesList() {
|
||||||
isLoading = true
|
repository.getRecommendSeriesList()
|
||||||
|
|
||||||
repository.getNewContentUploadCreatorList()
|
|
||||||
.sink { result in
|
.sink { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .finished:
|
case .finished:
|
||||||
|
@ -36,23 +34,23 @@ final class ContentMainNewContentCreatorViewModel: ObservableObject {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let jsonDecoder = JSONDecoder()
|
let jsonDecoder = JSONDecoder()
|
||||||
let decoded = try jsonDecoder.decode(ApiResponse<[GetNewContentUploadCreator]>.self, from: responseData)
|
let decoded = try jsonDecoder.decode(ApiResponse<[SeriesListItem]>.self, from: responseData)
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
|
|
||||||
if let data = decoded.data, decoded.success {
|
if let data = decoded.data, decoded.success {
|
||||||
self.newContentUploadCreatorList.removeAll()
|
self.seriesList.removeAll()
|
||||||
self.newContentUploadCreatorList.append(contentsOf: data)
|
self.seriesList.append(contentsOf: data)
|
||||||
} else {
|
} else {
|
||||||
if let message = decoded.message {
|
if let message = decoded.message {
|
||||||
self.errorMessage = message
|
self.errorMessage = message
|
||||||
} else {
|
} else {
|
||||||
self.errorMessage = "크리에이터 리스트를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
self.errorMessage = "추천 시리즈를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
}
|
}
|
||||||
|
|
||||||
self.isShowPopup = true
|
self.isShowPopup = true
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
self.errorMessage = "크리에이터 리스트를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
self.errorMessage = "추천 시리즈를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
self.isShowPopup = true
|
self.isShowPopup = true
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ enum SeriesApi {
|
||||||
case getSeriesList(creatorId: Int, sortType: SeriesListAllViewModel.SeriesSortType, page: Int, size: Int)
|
case getSeriesList(creatorId: Int, sortType: SeriesListAllViewModel.SeriesSortType, page: Int, size: Int)
|
||||||
case getSeriesDetail(seriesId: Int)
|
case getSeriesDetail(seriesId: Int)
|
||||||
case getSeriesContentList(seriesId: Int, page: Int, size: Int)
|
case getSeriesContentList(seriesId: Int, page: Int, size: Int)
|
||||||
|
case getRecommendSeriesList
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SeriesApi: TargetType {
|
extension SeriesApi: TargetType {
|
||||||
|
@ -29,12 +30,15 @@ extension SeriesApi: TargetType {
|
||||||
|
|
||||||
case .getSeriesContentList(let seriesId, _, _):
|
case .getSeriesContentList(let seriesId, _, _):
|
||||||
return "/audio-content/series/\(seriesId)/content"
|
return "/audio-content/series/\(seriesId)/content"
|
||||||
|
|
||||||
|
case .getRecommendSeriesList:
|
||||||
|
return "/audio-content/series/recommend"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var method: Moya.Method {
|
var method: Moya.Method {
|
||||||
switch self {
|
switch self {
|
||||||
case .getSeriesList, .getSeriesDetail, .getSeriesContentList:
|
case .getSeriesList, .getSeriesDetail, .getSeriesContentList, .getRecommendSeriesList:
|
||||||
return .get
|
return .get
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +55,7 @@ extension SeriesApi: TargetType {
|
||||||
|
|
||||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||||
|
|
||||||
case .getSeriesDetail:
|
case .getSeriesDetail, .getRecommendSeriesList:
|
||||||
return .requestPlain
|
return .requestPlain
|
||||||
|
|
||||||
case .getSeriesContentList(_, let page, let size):
|
case .getSeriesContentList(_, let page, let size):
|
||||||
|
|
|
@ -24,4 +24,8 @@ class SeriesRepository {
|
||||||
func getSeriesContentList(seriesId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
func getSeriesContentList(seriesId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
||||||
return api.requestPublisher(.getSeriesContentList(seriesId: seriesId, page: page, size: size))
|
return api.requestPublisher(.getSeriesContentList(seriesId: seriesId, page: page, size: size))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getRecommendSeriesList() -> AnyPublisher<Response, MoyaError> {
|
||||||
|
return api.requestPublisher(.getRecommendSeriesList)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,7 @@ struct UserProfileSeriesView: View {
|
||||||
HStack(alignment: .top, spacing: 13.3) {
|
HStack(alignment: .top, spacing: 13.3) {
|
||||||
ForEach(0..<items.count, id: \.self) {
|
ForEach(0..<items.count, id: \.self) {
|
||||||
let item = items[$0]
|
let item = items[$0]
|
||||||
SeriesListBigItemView(item: item)
|
SeriesListBigItemView(item: item, isVisibleCreator: false)
|
||||||
.contentShape(Rectangle())
|
|
||||||
.onTapGesture {
|
|
||||||
AppState.shared
|
|
||||||
.setAppStep(step: .seriesDetail(seriesId: item.seriesId))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import Kingfisher
|
||||||
struct SeriesListBigItemView: View {
|
struct SeriesListBigItemView: View {
|
||||||
|
|
||||||
let item: SeriesListItem
|
let item: SeriesListItem
|
||||||
|
let isVisibleCreator: Bool
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
@ -22,6 +23,10 @@ struct SeriesListBigItemView: View {
|
||||||
.frame(width: 116.7, height: 165, alignment: .center)
|
.frame(width: 116.7, height: 165, alignment: .center)
|
||||||
.cornerRadius(5)
|
.cornerRadius(5)
|
||||||
.clipped()
|
.clipped()
|
||||||
|
.onTapGesture {
|
||||||
|
AppState.shared
|
||||||
|
.setAppStep(step: .seriesDetail(seriesId: item.seriesId))
|
||||||
|
}
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
HStack(spacing: 3.3) {
|
HStack(spacing: 3.3) {
|
||||||
|
@ -57,6 +62,25 @@ struct SeriesListBigItemView: View {
|
||||||
.foregroundColor(Color.grayee)
|
.foregroundColor(Color.grayee)
|
||||||
.lineLimit(2)
|
.lineLimit(2)
|
||||||
|
|
||||||
|
if isVisibleCreator {
|
||||||
|
HStack(spacing: 3) {
|
||||||
|
KFImage(URL(string: item.creator.profileImage))
|
||||||
|
.resizable()
|
||||||
|
.scaledToFill()
|
||||||
|
.frame(width: 16, height: 16, alignment: .center)
|
||||||
|
.clipShape(Circle())
|
||||||
|
|
||||||
|
Text(item.creator.nickname)
|
||||||
|
.font(.custom(Font.medium.rawValue, size: 10))
|
||||||
|
.foregroundColor(Color.gray77)
|
||||||
|
.lineLimit(1)
|
||||||
|
}
|
||||||
|
.onTapGesture {
|
||||||
|
AppState.shared
|
||||||
|
.setAppStep(step: .creatorDetail(userId: item.creator.creatorId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text(item.publishedDaysOfWeek)
|
Text(item.publishedDaysOfWeek)
|
||||||
.font(.custom(Font.medium.rawValue, size: 11))
|
.font(.custom(Font.medium.rawValue, size: 11))
|
||||||
.foregroundColor(Color.gray77)
|
.foregroundColor(Color.gray77)
|
||||||
|
@ -81,6 +105,7 @@ struct SeriesListBigItemView: View {
|
||||||
numberOfContent: 10,
|
numberOfContent: 10,
|
||||||
isNew: true,
|
isNew: true,
|
||||||
isPopular: true
|
isPopular: true
|
||||||
)
|
),
|
||||||
|
isVisibleCreator: true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue