From 30c70ee63803cd05e200cbf48710976aad195e1e Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Wed, 17 Dec 2025 00:35:16 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=9C=EB=A6=AC=EC=A6=88=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20-=20=EB=B2=88=EC=97=AD=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=EA=B0=80=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EB=B2=88?= =?UTF-8?q?=EC=97=AD=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detail/GetSeriesDetailResponse.swift | 51 +++++++++++++++++++ .../Detail/SeriesDetailIntroductionView.swift | 8 +-- .../Series/Detail/SeriesDetailView.swift | 10 ++-- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/SodaLive/Sources/Content/Series/Detail/GetSeriesDetailResponse.swift b/SodaLive/Sources/Content/Series/Detail/GetSeriesDetailResponse.swift index 70462eb..c39ca4f 100644 --- a/SodaLive/Sources/Content/Series/Detail/GetSeriesDetailResponse.swift +++ b/SodaLive/Sources/Content/Series/Detail/GetSeriesDetailResponse.swift @@ -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 + } +} diff --git a/SodaLive/Sources/Content/Series/Detail/SeriesDetailIntroductionView.swift b/SodaLive/Sources/Content/Series/Detail/SeriesDetailIntroductionView.swift index d85f464..44e95e3 100644 --- a/SodaLive/Sources/Content/Series/Detail/SeriesDetailIntroductionView.swift +++ b/SodaLive/Sources/Content/Series/Detail/SeriesDetailIntroductionView.swift @@ -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) } diff --git a/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift b/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift index 4e01d2f..ce11a42 100644 --- a/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift +++ b/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift @@ -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..