255 lines
13 KiB
Swift
255 lines
13 KiB
Swift
//
|
|
// SeriesDetailView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 4/29/24.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Kingfisher
|
|
|
|
struct SeriesDetailView: View {
|
|
|
|
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
|
|
@ObservedObject var viewModel = SeriesDetailViewModel()
|
|
|
|
let seriesId: Int
|
|
|
|
@State private var isShowFollowNotifyDialog: Bool = false
|
|
@State private var creatorId: Int = 0
|
|
|
|
var body: some View {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
ZStack(alignment: .top) {
|
|
Color.gray11.ignoresSafeArea()
|
|
|
|
if let seriesDetail = viewModel.seriesDetail {
|
|
KFImage(URL(string: seriesDetail.coverImage))
|
|
.cancelOnDisappear(true)
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(maxWidth: .infinity)
|
|
.blur(radius: 25)
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
VStack(spacing: 0) {
|
|
HStack(spacing: 0) {
|
|
Image("ic_back")
|
|
.resizable()
|
|
.frame(width: 20, height: 20)
|
|
.onTapGesture {
|
|
if presentationMode.wrappedValue.isPresented {
|
|
presentationMode.wrappedValue.dismiss()
|
|
} else {
|
|
AppState.shared.back()
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(.horizontal, 13.3)
|
|
.frame(height: 50)
|
|
|
|
ZStack {
|
|
Rectangle()
|
|
.frame(maxWidth: .infinity)
|
|
.foregroundColor(Color.gray11)
|
|
.cornerRadius(21.3, corners: [.topLeft, .topRight])
|
|
.padding(.top, 94)
|
|
|
|
KFImage(URL(string: seriesDetail.coverImage))
|
|
.cancelOnDisappear(true)
|
|
.downsampling(
|
|
size: CGSize(
|
|
width: 400 * screenSize().width / 1080,
|
|
height: 564 * screenSize().width / 1080
|
|
)
|
|
)
|
|
.resizable()
|
|
.scaledToFill()
|
|
.frame(
|
|
width: 400 * screenSize().width / 1080,
|
|
height: 564 * screenSize().width / 1080
|
|
)
|
|
.cornerRadius(5)
|
|
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
Text(seriesDetail.displayTitle)
|
|
.appFont(size: 18.3, weight: .bold)
|
|
.foregroundColor(Color.grayee)
|
|
.padding(.horizontal, 13.3)
|
|
.padding(.top, 24)
|
|
|
|
HStack(spacing: 5.3) {
|
|
Text(seriesDetail.displayGenre)
|
|
.font(.custom(Font.medium.rawValue, size: 12))
|
|
.foregroundColor(Color(hex: "3bac6a"))
|
|
.padding(.horizontal, 5.3)
|
|
.padding(.vertical, 3.3)
|
|
.background(Color(hex: "28312b"))
|
|
.cornerRadius(2.6)
|
|
|
|
if seriesDetail.isAdult {
|
|
Text("19세")
|
|
.font(.custom(Font.medium.rawValue, size: 12))
|
|
.foregroundColor(Color(hex: "f1291c"))
|
|
.padding(.horizontal, 5.3)
|
|
.padding(.vertical, 3.3)
|
|
.background(Color(hex: "312827"))
|
|
.cornerRadius(2.6)
|
|
} else {
|
|
Text("전체연령가")
|
|
.font(.custom(Font.medium.rawValue, size: 12))
|
|
.foregroundColor(Color(hex: "d2d2d2"))
|
|
.padding(.horizontal, 5.3)
|
|
.padding(.vertical, 3.3)
|
|
.background(Color(hex: "222222"))
|
|
.cornerRadius(2.6)
|
|
}
|
|
|
|
Text("\(seriesDetail.publishedDaysOfWeek) 연재")
|
|
.font(.custom(Font.medium.rawValue, size: 12))
|
|
.foregroundColor(Color(hex: "909090"))
|
|
}
|
|
.padding(.top, 8)
|
|
.padding(.horizontal, 13.3)
|
|
|
|
ScrollView(.horizontal, showsIndicators: false) {
|
|
HStack(spacing: 5.3) {
|
|
ForEach(0..<seriesDetail.displayKeywords.count, id: \.self) {
|
|
SeriesKeywordChipView(keyword: seriesDetail.displayKeywords[$0])
|
|
}
|
|
}
|
|
}
|
|
.padding(.top, 16)
|
|
.padding(.horizontal, 13.3)
|
|
|
|
HStack(spacing: 0) {
|
|
HStack(spacing: 5.3) {
|
|
KFImage(URL(string: seriesDetail.creator.profileImage))
|
|
.cancelOnDisappear(true)
|
|
.downsampling(
|
|
size: CGSize(
|
|
width: 26.7,
|
|
height: 26.7
|
|
)
|
|
)
|
|
.resizable()
|
|
.scaledToFit()
|
|
.clipShape(Circle())
|
|
.frame(width: 26.7, height: 26.7)
|
|
|
|
Text(seriesDetail.creator.nickname)
|
|
.font(.custom(Font.medium.rawValue, size: 12))
|
|
.foregroundColor(Color.gray90)
|
|
}
|
|
.onTapGesture {
|
|
AppState.shared.setAppStep(step: .creatorDetail(userId: seriesDetail.creator.creatorId))
|
|
}
|
|
|
|
Spacer()
|
|
|
|
if seriesDetail.creator.creatorId != UserDefaults.int(forKey: .userId) {
|
|
let asset = FollowButtonImageAsset(
|
|
type: viewModel.isFollow
|
|
? (viewModel.isNotify ? .following : .followingNoAlarm)
|
|
: .follow
|
|
)
|
|
asset.imageView()
|
|
.onTapGesture {
|
|
if viewModel.isFollow {
|
|
creatorId = seriesDetail.creator.creatorId
|
|
isShowFollowNotifyDialog = true
|
|
} else {
|
|
viewModel.follow(seriesDetail.creator.creatorId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(.top, 16)
|
|
.padding(.horizontal, 13.3)
|
|
|
|
HStack(spacing: 0) {
|
|
SeriesDetailTabView(
|
|
title: I18n.SeriesDetail.home,
|
|
width: screenSize().width / 2,
|
|
isSelected: viewModel.currentTab == .home
|
|
) {
|
|
if viewModel.currentTab != .home {
|
|
viewModel.currentTab = .home
|
|
}
|
|
}
|
|
|
|
SeriesDetailTabView(
|
|
title: I18n.SeriesDetail.introduction,
|
|
width: screenSize().width / 2,
|
|
isSelected: viewModel.currentTab == .introduction
|
|
) {
|
|
if viewModel.currentTab != .introduction {
|
|
viewModel.currentTab = .introduction
|
|
}
|
|
}
|
|
}
|
|
.padding(.top, 16)
|
|
|
|
Rectangle()
|
|
.foregroundColor(Color.gray90.opacity(0.5))
|
|
.frame(height: 1)
|
|
.frame(maxWidth: .infinity)
|
|
|
|
switch(viewModel.currentTab) {
|
|
case .introduction:
|
|
SeriesDetailIntroductionView(
|
|
width: screenSize().width - 26.7,
|
|
seriesDetail: seriesDetail
|
|
)
|
|
|
|
default:
|
|
SeriesDetailHomeView(
|
|
title: seriesDetail.displayTitle,
|
|
seriesId: seriesDetail.seriesId,
|
|
contentCount: seriesDetail.contentCount,
|
|
contentList: seriesDetail.contentList
|
|
)
|
|
}
|
|
}
|
|
.padding(.bottom, 10)
|
|
.background(Color.gray11)
|
|
}
|
|
}
|
|
|
|
if isShowFollowNotifyDialog {
|
|
CreatorFollowNotifyDialog(
|
|
isShowing: $isShowFollowNotifyDialog,
|
|
onClickNotifyAll: {
|
|
viewModel.follow(creatorId, follow: true, notify: true)
|
|
creatorId = 0
|
|
},
|
|
onClickNotifyNone: {
|
|
viewModel.follow(creatorId, follow: true, notify: false)
|
|
creatorId = 0
|
|
},
|
|
onClickUnFollow: {
|
|
viewModel.follow(creatorId, follow: false, notify: false)
|
|
creatorId = 0
|
|
}
|
|
)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("")
|
|
.navigationBarBackButtonHidden()
|
|
}
|
|
.onAppear {
|
|
viewModel.seriesId = seriesId
|
|
viewModel.getSeriesDetail()
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
SeriesDetailView(seriesId: 0)
|
|
}
|