Files
sodalive-ios/SodaLive/Sources/Content/Series/Main/Home/SeriesMainHomeView.swift
Yu Sung 280e424385 커스텀 폰트 pretendard-medium, gmarket-medium를 사용하고 있던 것을 appFont 모디
파이어를 사용하여 한국어는 pretendard, 그 외에는 시스템 폰트를 사용하도록 수정
2026-01-23 03:09:20 +09:00

133 lines
5.6 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("완결 시리즈")
.appFont(size: 24, weight: .bold)
.foregroundColor(.white)
Spacer()
Text("전체보기")
.font(.custom(Font.preRegular.rawValue, size: 14))
.foregroundColor(.init(hex: "78909C"))
.onTapGesture {
AppState.shared
.setAppStep(step: .seriesAll(isCompleted: true))
}
}
.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("추천 시리즈")
.appFont(size: 24, weight: .bold)
.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)
}
}
}
}
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
HStack {
Spacer()
Text(viewModel.errorMessage)
.padding(.vertical, 13.3)
.frame(width: screenSize().width - 66.7, alignment: .center)
.appFont(size: 12, weight: .medium)
.background(Color.button)
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.cornerRadius(20)
.padding(.bottom, 66.7)
Spacer()
}
}
.onAppear {
viewModel.fetchHome()
}
if viewModel.isLoading {
LoadingView()
}
}
}
}
#Preview {
SeriesMainHomeView()
}