From e56294d7d5c3675500d4a5d37eaadc0ad6b865e1 Mon Sep 17 00:00:00 2001 From: Brandon Titus Date: Wed, 30 Oct 2024 20:44:41 -0600 Subject: [PATCH 1/2] Fix indicator color in EoY 2024 Stories --- .../End of Year 2023/EndOfYear2023StoriesModel.swift | 4 ++++ .../End of Year 2024/EndOfYear2024StoriesModel.swift | 4 ++++ podcasts/End of Year/EndOfYearStoriesBuilder.swift | 1 + podcasts/End of Year/Stories/EndOfYearStoriesDataSource.swift | 4 ++++ podcasts/End of Year/StoriesDataSource.swift | 2 ++ podcasts/End of Year/StoriesModel.swift | 4 ++++ podcasts/End of Year/Views/StoriesView.swift | 3 ++- podcasts/End of Year/Views/StoryIndicator.swift | 4 ++-- 8 files changed, 23 insertions(+), 3 deletions(-) diff --git a/podcasts/End of Year/End of Year 2023/EndOfYear2023StoriesModel.swift b/podcasts/End of Year/End of Year 2023/EndOfYear2023StoriesModel.swift index d1e0749de1..f77134d332 100644 --- a/podcasts/End of Year/End of Year 2023/EndOfYear2023StoriesModel.swift +++ b/podcasts/End of Year/End of Year 2023/EndOfYear2023StoriesModel.swift @@ -7,6 +7,10 @@ class EndOfYear2023StoriesModel: StoryModel { var stories = [EndOfYear2023Story]() var data = EndOfYear2023StoriesData() + var indicatorColor: Color { + .white + } + required init() {} func populate(with dataManager: DataManager) { diff --git a/podcasts/End of Year/End of Year 2024/EndOfYear2024StoriesModel.swift b/podcasts/End of Year/End of Year 2024/EndOfYear2024StoriesModel.swift index 0aa752c0eb..53b4de7ffd 100644 --- a/podcasts/End of Year/End of Year 2024/EndOfYear2024StoriesModel.swift +++ b/podcasts/End of Year/End of Year 2024/EndOfYear2024StoriesModel.swift @@ -7,6 +7,10 @@ class EndOfYear2024StoriesModel: StoryModel { var stories = [EndOfYear2024Story]() var data = EndOfYear2024StoriesData() + var indicatorColor: Color { + .black + } + required init() { } func populate(with dataManager: DataManager) { diff --git a/podcasts/End of Year/EndOfYearStoriesBuilder.swift b/podcasts/End of Year/EndOfYearStoriesBuilder.swift index d0b351fdb6..f9bc37b911 100644 --- a/podcasts/End of Year/EndOfYearStoriesBuilder.swift +++ b/podcasts/End of Year/EndOfYearStoriesBuilder.swift @@ -59,4 +59,5 @@ protocol StoryModel { func overlaidShareView() -> AnyView? /// Shown at the bottom of the story as an additional safe area func footerShareView() -> AnyView? + var indicatorColor: Color { get } } diff --git a/podcasts/End of Year/Stories/EndOfYearStoriesDataSource.swift b/podcasts/End of Year/Stories/EndOfYearStoriesDataSource.swift index ce96149e1d..f79deef881 100644 --- a/podcasts/End of Year/Stories/EndOfYearStoriesDataSource.swift +++ b/podcasts/End of Year/Stories/EndOfYearStoriesDataSource.swift @@ -51,6 +51,10 @@ class EndOfYearStoriesDataSource: StoriesDataSource { func footerShareView() -> AnyView? { model.footerShareView() } + + var indicatorColor: Color { + model.indicatorColor + } } extension Array where Element: CaseIterable & Equatable { diff --git a/podcasts/End of Year/StoriesDataSource.swift b/podcasts/End of Year/StoriesDataSource.swift index c9051ec672..6bd5fe0010 100644 --- a/podcasts/End of Year/StoriesDataSource.swift +++ b/podcasts/End of Year/StoriesDataSource.swift @@ -37,6 +37,8 @@ protocol StoriesDataSource { func overlaidShareView() -> AnyView? /// Shown at the bottom of the story as an additional safe area func footerShareView() -> AnyView? + + var indicatorColor: Color { get } } extension StoriesDataSource { diff --git a/podcasts/End of Year/StoriesModel.swift b/podcasts/End of Year/StoriesModel.swift index f11f024391..b2a94a5a19 100644 --- a/podcasts/End of Year/StoriesModel.swift +++ b/podcasts/End of Year/StoriesModel.swift @@ -246,6 +246,10 @@ class StoriesModel: ObservableObject { func footerShareView() -> AnyView? { dataSource.footerShareView() } + + var indicatorColor: Color { + dataSource.indicatorColor + } } private extension StoriesModel { diff --git a/podcasts/End of Year/Views/StoriesView.swift b/podcasts/End of Year/Views/StoriesView.swift index 83812e24f7..9516b4aa44 100644 --- a/podcasts/End of Year/Views/StoriesView.swift +++ b/podcasts/End of Year/Views/StoriesView.swift @@ -62,6 +62,7 @@ struct StoriesView: View { } header + .foregroundStyle(model.indicatorColor) // Hide the share button if needed if model.showShareButton(index: model.currentStoryIndex) && !model.shouldShowUpsell(), let shareView = model.overlaidShareView() { @@ -256,8 +257,8 @@ private struct CloseButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { Image("eoy-close") + .renderingMode(.template) .font(style: .body, maxSizeCategory: .extraExtraExtraLarge) - .foregroundColor(.white) .padding(Constants.closeButtonPadding) .background(showButtonShapes ? Color.white.opacity(0.2) : nil) .cornerRadius(Constants.closeButtonRadius) diff --git a/podcasts/End of Year/Views/StoryIndicator.swift b/podcasts/End of Year/Views/StoryIndicator.swift index 9365b741e1..e46806b7a8 100644 --- a/podcasts/End of Year/Views/StoryIndicator.swift +++ b/podcasts/End of Year/Views/StoryIndicator.swift @@ -9,12 +9,12 @@ struct StoryIndicator: View { GeometryReader { geometry in ZStack(alignment: .leading) { Rectangle() - .foregroundColor(Color.white.opacity(Constants.storyIndicatorBackgroundOpacity)) + .opacity(Constants.storyIndicatorBackgroundOpacity) .cornerRadius(Constants.storyIndicatorBorderRadius) Rectangle() .frame(width: geometry.size.width * (model.progress - CGFloat(index)).clamped(to: 0.0 ..< 1.0), height: nil, alignment: .leading) - .foregroundColor(Color.white.opacity(Constants.storyIndicatorForegroundOpacity)) + .opacity(Constants.storyIndicatorForegroundOpacity) .cornerRadius(Constants.storyIndicatorBorderRadius) } } From 8fb1f08b9cd4709abac87f7d63da85464a18c0aa Mon Sep 17 00:00:00 2001 From: Brandon Titus Date: Thu, 31 Oct 2024 11:23:13 -0600 Subject: [PATCH 2/2] Fix unit tests --- PocketCastsTests/Tests/End of Year/StoriesModelTests.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PocketCastsTests/Tests/End of Year/StoriesModelTests.swift b/PocketCastsTests/Tests/End of Year/StoriesModelTests.swift index 1995f3653e..4200b9d162 100644 --- a/PocketCastsTests/Tests/End of Year/StoriesModelTests.swift +++ b/PocketCastsTests/Tests/End of Year/StoriesModelTests.swift @@ -151,6 +151,8 @@ class StoriesModelTests: XCTestCase { } class MockStoriesDataSource: StoriesDataSource { + var indicatorColor: Color = .white + var numberOfStories: Int = 2 var didCallStoryForWithStoryNumber: Int? @@ -192,6 +194,8 @@ class MockStoriesDataSource: StoriesDataSource { } class MockStoriesWithPlusDataSource: StoriesDataSource { + var indicatorColor: Color = .white + var numberOfStories: Int = 4 var didCallStoryForWithStoryNumber: Int?