feat: 메인 홈

- 라이브, 인기 크리, 최신 콘텐츠, 이벤트 배너 UI 추가
This commit is contained in:
Yu Sung
2025-07-11 22:31:15 +09:00
parent e121ec1ee4
commit 5a9b95c2bf
29 changed files with 622 additions and 137 deletions

View File

@@ -8,7 +8,7 @@
import SwiftUI
struct HomeTabView: View {
@StateObject var viewModel = ContentMainTabHomeViewModel()
@StateObject var viewModel = HomeTabViewModel()
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
@AppStorage("role") private var role: String = UserDefaults.string(forKey: UserDefaultsKey.role)
@@ -35,80 +35,88 @@ struct HomeTabView: View {
ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .leading, spacing: 48) {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("지금")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 라이브중")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.white)
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
if !viewModel.liveList.isEmpty {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("지금")
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 라이브중")
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(0..<viewModel.liveList.count, id: \.self) {
HomeLiveItemView(item: viewModel.liveList[$0])
}
}
.padding(.horizontal, 24)
}
}
}
if !viewModel.creatorRanking.isEmpty {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("인기")
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 크리에이터")
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(0..<viewModel.creatorRanking.count, id: \.self) {
HomeCreatorRankingItemView(rank: $0 + 1, item: viewModel.creatorRanking[$0])
}
}
.padding(.horizontal, 24)
}
}
}
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("인기")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 크리에이터")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.white)
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
HomeLatestContentView(
onClickMore: {
AppState.shared
.setAppStep(step: .newContentAll(isFree: false))
},
themeList: viewModel.latestContentThemeList,
contentList: viewModel.latestContentList
) {
viewModel.getLatestContentByTheme(theme: $0)
}
}
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("최신")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 콘텐츠")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.white)
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
}
if !viewModel.eventBannerList.isEmpty {
SectionEventBannerView(items: viewModel.eventBannerList)
}
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("오직")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 보이스온에서만")
.font(.custom(Font.bold.rawValue, size: 26))
.foregroundColor(.white)
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
if !viewModel.originalAudioDramaList.isEmpty {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("오직")
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 보이스온에서만")
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
.padding(.horizontal, 24)
}
}
}
@@ -116,85 +124,132 @@ struct HomeTabView: View {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("요일별")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 시리즈")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
.padding(.horizontal, 24)
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
.padding(.horizontal, 24)
}
}
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("보온")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 주간 차트")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
.padding(.horizontal, 24)
}
}
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("추천")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 채널")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
.padding(.horizontal, 24)
}
}
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
Text("무료")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.button)
Text(" 콘텐츠")
.font(.custom(Font.bold.rawValue, size: 26))
.font(.custom(Font.preBold.rawValue, size: 26))
.foregroundColor(.white)
}
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
}
.padding(.horizontal, 24)
}
}
Text("""
- 회사명 : 주식회사 소다라이브
- 대표자 : 이재형
- 주소 : 경기도 성남시 분당구 황새울로335번길 10, 5층 563A호
- 사업자등록번호 : 870-81-03220
- 통신판매업신고 : 제2024-성남분당B-1012호
- 고객센터 : 02.2055.1477 (이용시간 10:00~19:00)
- 대표 이메일 : sodalive.official@gmail.com
""")
.font(.custom(Font.medium.rawValue, size: 11))
.foregroundColor(Color.gray77)
.padding(.top, 30)
.padding(.horizontal, 13.3)
}
.padding(24)
.padding(.vertical, 24)
}
}
}
.onAppear {
viewModel.fetchData()
}
}
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
HStack {
Spacer()
Text(viewModel.errorMessage)
.padding(.vertical, 13.3)
.frame(width: screenSize().width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color.button)
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.cornerRadius(20)
.padding(.bottom, 66.7)
Spacer()
}
}
}
}