feat: 메인 홈
- 요일별 시리즈, 오디션 추가
This commit is contained in:
172
SodaLive/Sources/Content/Series/DayOfWeekSeriesView.swift
Normal file
172
SodaLive/Sources/Content/Series/DayOfWeekSeriesView.swift
Normal file
@@ -0,0 +1,172 @@
|
||||
//
|
||||
// DayOfWeekSeriesView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 7/11/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct DayOfWeek {
|
||||
let dayOfWeekStr: String
|
||||
let dayOfWeek: SeriesPublishedDaysOfWeek
|
||||
}
|
||||
|
||||
struct DayOfWeekSeriesView: View {
|
||||
|
||||
let seriesList: [SeriesListItem]
|
||||
let onTapDayOfWeek: (SeriesPublishedDaysOfWeek) -> Void
|
||||
|
||||
@State private var dayOfWeek: SeriesPublishedDaysOfWeek = .FRI
|
||||
|
||||
private let dayOfWeekItems: [DayOfWeek] = [
|
||||
DayOfWeek(dayOfWeekStr: "월", dayOfWeek: .MON),
|
||||
DayOfWeek(dayOfWeekStr: "화", dayOfWeek: .TUE),
|
||||
DayOfWeek(dayOfWeekStr: "수", dayOfWeek: .WED),
|
||||
DayOfWeek(dayOfWeekStr: "목", dayOfWeek: .THU),
|
||||
DayOfWeek(dayOfWeekStr: "금", dayOfWeek: .FRI),
|
||||
DayOfWeek(dayOfWeekStr: "토", dayOfWeek: .SAT),
|
||||
DayOfWeek(dayOfWeekStr: "일", dayOfWeek: .SUN),
|
||||
DayOfWeek(dayOfWeekStr: "랜덤", dayOfWeek: .RANDOM),
|
||||
]
|
||||
|
||||
// 요일 숫자에 맞춰 배열
|
||||
private let dayOfWeeks: [SeriesPublishedDaysOfWeek] = [
|
||||
.RANDOM,
|
||||
.SUN,
|
||||
.MON,
|
||||
.TUE,
|
||||
.WED,
|
||||
.THU,
|
||||
.FRI,
|
||||
.SAT
|
||||
]
|
||||
|
||||
var body: some View {
|
||||
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: 5) {
|
||||
ForEach(0..<dayOfWeekItems.count, id: \.self) {
|
||||
let item = dayOfWeekItems[$0]
|
||||
DayOfWeekDayView(dayOfWeek: item.dayOfWeekStr, isSelected: dayOfWeek == item.dayOfWeek)
|
||||
.onTapGesture {
|
||||
if dayOfWeek != item.dayOfWeek {
|
||||
dayOfWeek = item.dayOfWeek
|
||||
onTapDayOfWeek(item.dayOfWeek)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 24)
|
||||
}
|
||||
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 16) {
|
||||
ForEach(0..<seriesList.count, id: \.self) {
|
||||
SeriesItemView(item: seriesList[$0])
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 24)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
dayOfWeek = dayOfWeeks[Calendar.current.component(.weekday, from: Date())]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DayOfWeekDayView: View {
|
||||
let dayOfWeek: String
|
||||
let isSelected: Bool
|
||||
|
||||
var body: some View {
|
||||
Text(dayOfWeek)
|
||||
.font(
|
||||
.custom(
|
||||
isSelected ? Font.preBold.rawValue : Font.preRegular.rawValue,
|
||||
size: 18
|
||||
)
|
||||
)
|
||||
.foregroundColor(.white)
|
||||
.padding(.vertical, 8)
|
||||
.padding(.horizontal, 11)
|
||||
.background(Color(hex: "263238").cornerRadius(16))
|
||||
.overlay {
|
||||
RoundedRectangle(cornerRadius: 16)
|
||||
.strokeBorder(
|
||||
LinearGradient(
|
||||
stops: [
|
||||
.init(color: Color.main, location: 0.24),
|
||||
.init(color: Color(hex: "6D5ED7"), location: 1.0)
|
||||
],
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
),
|
||||
lineWidth: isSelected ? 4 : 0
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
DayOfWeekSeriesView(
|
||||
seriesList: [
|
||||
SeriesListItem(
|
||||
seriesId: 1,
|
||||
title: "제목, 관심사,프로필+방장, 참여인원(어딘가..)",
|
||||
coverImage: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
publishedDaysOfWeek: "매주 수, 토요일",
|
||||
isComplete: true,
|
||||
creator: SeriesListItemCreator(
|
||||
creatorId: 1,
|
||||
nickname: "creator",
|
||||
profileImage: "https://test-cf.sodalive.net/profile/default-profile.png"
|
||||
),
|
||||
numberOfContent: 10,
|
||||
isNew: true,
|
||||
isPopular: true
|
||||
),
|
||||
SeriesListItem(
|
||||
seriesId: 2,
|
||||
title: "제목, 관심사,프로필+방장, 참여인원(어딘가..)",
|
||||
coverImage: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
publishedDaysOfWeek: "매주 수, 토요일",
|
||||
isComplete: false,
|
||||
creator: SeriesListItemCreator(
|
||||
creatorId: 1,
|
||||
nickname: "creator",
|
||||
profileImage: "https://test-cf.sodalive.net/profile/default-profile.png"
|
||||
),
|
||||
numberOfContent: 10,
|
||||
isNew: false,
|
||||
isPopular: true
|
||||
),
|
||||
SeriesListItem(
|
||||
seriesId: 1,
|
||||
title: "제목, 관심사,프로필+방장, 참여인원(어딘가..)",
|
||||
coverImage: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
publishedDaysOfWeek: "매주 수, 토요일",
|
||||
isComplete: false,
|
||||
creator: SeriesListItemCreator(
|
||||
creatorId: 1,
|
||||
nickname: "creator",
|
||||
profileImage: "https://test-cf.sodalive.net/profile/default-profile.png"
|
||||
),
|
||||
numberOfContent: 10,
|
||||
isNew: true,
|
||||
isPopular: false
|
||||
)
|
||||
]
|
||||
) { _ in }
|
||||
}
|
||||
Reference in New Issue
Block a user