시리즈 상세 - 번역 데이터가 있으면 번역 데이터를 표시하도록 수정

This commit is contained in:
Yu Sung
2025-12-17 00:35:16 +09:00
parent b61f432b72
commit 30c70ee638
3 changed files with 60 additions and 9 deletions

View File

@@ -17,6 +17,7 @@ struct GetSeriesDetailResponse: Decodable {
let writer: String?
let studio: String?
let publishedDate: String
let publishedDateUtc: String
let creator: GetSeriesDetailCreator
let rentalMinPrice: Int
let rentalMaxPrice: Int
@@ -27,6 +28,8 @@ struct GetSeriesDetailResponse: Decodable {
let publishedDaysOfWeek: String
let contentList: [GetSeriesContentListItem]
let contentCount: Int
let translated: TranslatedSeries?
let translatedGenre: String?
}
struct GetSeriesDetailCreator: Decodable {
@@ -36,3 +39,51 @@ struct GetSeriesDetailCreator: Decodable {
let isFollow: Bool
let isNotify: Bool
}
struct TranslatedSeries: Decodable {
let title: String
let introduction: String
let keywords: [String]
}
// :
extension GetSeriesDetailResponse {
//
var displayTitle: String { translated?.title ?? title }
//
var displayIntroduction: String { translated?.introduction ?? introduction }
//
var displayKeywords: [String] { translated?.keywords ?? keywordList }
//
var displayGenre: String { translatedGenre ?? genre }
// ISO8601 UTC yyyy.MM.dd
var displayPublishedDate: String {
// publishedDateUtc : ISO8601
let iso = ISO8601DateFormatter()
// .withInternetDateTime , fractional seconds
iso.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
func format(_ date: Date) -> String {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .gregorian)
formatter.timeZone = .current
formatter.locale = Locale(identifier: Locale.current.identifier)
formatter.dateFormat = "yyyy.MM.dd"
return formatter.string(from: date)
}
if let date = iso.date(from: publishedDateUtc) {
return format(date)
} else {
// fractional seconds
let isoNoFrac = ISO8601DateFormatter()
isoNoFrac.formatOptions = [.withInternetDateTime]
if let date = isoNoFrac.date(from: publishedDateUtc) {
return format(date)
}
}
//
return publishedDate
}
}

View File

@@ -21,7 +21,7 @@ struct SeriesDetailIntroductionView: View {
.padding(.top, 16)
.padding(.horizontal, 13.3)
FlowLayout(mode: .scrollable, items: seriesDetail.keywordList, itemSpacing: 5.3) {
FlowLayout(mode: .scrollable, items: seriesDetail.displayKeywords, itemSpacing: 5.3) {
SeriesKeywordChipView(keyword: $0)
}
.padding(.horizontal, 13.3)
@@ -35,7 +35,7 @@ struct SeriesDetailIntroductionView: View {
.font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(Color.grayee)
Text(seriesDetail.introduction)
Text(seriesDetail.displayIntroduction)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color.gray77)
.lineSpacing(4)
@@ -83,7 +83,7 @@ struct SeriesDetailIntroductionView: View {
}
VStack(alignment: .leading, spacing: 13.3) {
Text(seriesDetail.genre)
Text(seriesDetail.displayGenre)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color.white)
@@ -107,7 +107,7 @@ struct SeriesDetailIntroductionView: View {
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color.white)
Text(seriesDetail.publishedDate)
Text(seriesDetail.displayPublishedDate)
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color.white)
}

View File

@@ -76,14 +76,14 @@ struct SeriesDetailView: View {
}
VStack(alignment: .leading, spacing: 0) {
Text(seriesDetail.title)
Text(seriesDetail.displayTitle)
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color.grayee)
.padding(.horizontal, 13.3)
.padding(.top, 24)
HStack(spacing: 5.3) {
Text(seriesDetail.genre)
Text(seriesDetail.displayGenre)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "3bac6a"))
.padding(.horizontal, 5.3)
@@ -118,8 +118,8 @@ struct SeriesDetailView: View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 5.3) {
ForEach(0..<seriesDetail.keywordList.count, id: \.self) {
SeriesKeywordChipView(keyword: seriesDetail.keywordList[$0])
ForEach(0..<seriesDetail.displayKeywords.count, id: \.self) {
SeriesKeywordChipView(keyword: seriesDetail.displayKeywords[$0])
}
}
}
@@ -209,7 +209,7 @@ struct SeriesDetailView: View {
default:
SeriesDetailHomeView(
title: seriesDetail.title,
title: seriesDetail.displayTitle,
seriesId: seriesDetail.seriesId,
contentCount: seriesDetail.contentCount,
contentList: seriesDetail.contentList