114 lines
4.7 KiB
Swift
114 lines
4.7 KiB
Swift
//
|
|
// SeriesMainHomeView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 11/14/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SeriesMainHomeView: View {
|
|
|
|
@StateObject var viewModel = SeriesMainHomeViewModel()
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
VStack(spacing: 48) {
|
|
if !viewModel.banners.isEmpty {
|
|
SeriesMainHomeBannerView(bannerList: viewModel.banners)
|
|
.padding(.top, 24)
|
|
}
|
|
|
|
if !viewModel.completedSeriesList.isEmpty {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack(spacing: 0) {
|
|
Text("완결 시리즈")
|
|
.font(.custom(Font.preBold.rawValue, size: 24))
|
|
.foregroundColor(.white)
|
|
|
|
Spacer()
|
|
|
|
Text("전체보기")
|
|
.font(.custom(Font.preRegular.rawValue, size: 14))
|
|
.foregroundColor(.init(hex: "78909C"))
|
|
}
|
|
.padding(.horizontal, 24)
|
|
|
|
ScrollView(.horizontal, showsIndicators: false) {
|
|
LazyHStack(spacing: 16) {
|
|
ForEach(0..<viewModel.completedSeriesList.count, id: \.self) {
|
|
let item = viewModel.completedSeriesList[$0]
|
|
NavigationLink {
|
|
SeriesDetailView(seriesId: item.seriesId)
|
|
} label: {
|
|
SeriesMainItemView(item: item)
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, 24)
|
|
}
|
|
}
|
|
}
|
|
|
|
if !viewModel.recommendSeriesList.isEmpty {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack(spacing: 0) {
|
|
Text("추천 시리즈")
|
|
.font(.custom(Font.preBold.rawValue, size: 24))
|
|
.foregroundColor(.white)
|
|
|
|
Spacer()
|
|
|
|
Image("ic_refresh")
|
|
.onTapGesture {
|
|
viewModel.getRecommendSeriesList()
|
|
}
|
|
}
|
|
.padding(.horizontal, 24)
|
|
|
|
let horizontalPadding: CGFloat = 24
|
|
let gridSpacing: CGFloat = 16
|
|
let width = (screenSize().width - (horizontalPadding * 2) - gridSpacing) / 2
|
|
|
|
LazyVGrid(
|
|
columns: Array(
|
|
repeating: GridItem(
|
|
.flexible(),
|
|
spacing: gridSpacing,
|
|
alignment: .topLeading
|
|
),
|
|
count: 2
|
|
),
|
|
alignment: .leading,
|
|
spacing: gridSpacing
|
|
) {
|
|
ForEach(viewModel.recommendSeriesList.indices, id: \.self) {
|
|
let item = viewModel.recommendSeriesList[$0]
|
|
NavigationLink {
|
|
SeriesDetailView(seriesId: item.seriesId)
|
|
} label: {
|
|
SeriesMainItemView(item: item, width: width, height: width * 227 / 160)
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, horizontalPadding)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
viewModel.fetchHome()
|
|
}
|
|
|
|
if viewModel.isLoading {
|
|
LoadingView()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
SeriesMainHomeView()
|
|
}
|