-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Playback 2024: Longest Episode #2347
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
podcasts/End of Year/Stories/2024/LongestEpisode2024Story.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import SwiftUI | ||
import PocketCastsDataModel | ||
|
||
struct LongestEpisode2024Story: ShareableStory { | ||
@Environment(\.renderForSharing) var renderForSharing: Bool | ||
@Environment(\.animated) var animated: Bool | ||
|
||
@ObservedObject private var animationViewModel = PlayPauseAnimationViewModel(duration: 0.8, animation: Animation.spring(_:)) | ||
|
||
var identifier: String = "longest_episode" | ||
|
||
let episode: Episode | ||
|
||
let podcast: Podcast | ||
|
||
@State var firstCover: Double = 0.4 | ||
@State var secondCover: Double = 0.32 | ||
@State var thirdCover: Double = 0.24 | ||
@State var fourthCover: Double = 0.16 | ||
@State var fifthCover: Double = 0.08 | ||
@State var sixthCover: Double = 0 | ||
|
||
var backgroundColor = Color(hex: "#E0EFAD") | ||
|
||
var tintColor: Color { | ||
.white | ||
} | ||
|
||
var body: some View { | ||
GeometryReader { geometry in | ||
let isSmallScreen = geometry.size.height <= 600 | ||
VStack(alignment: .leading) { | ||
Spacer() | ||
ZStack { | ||
covers() | ||
let stickerSize = CGSize(width: 194, height: 135) | ||
Image("playback-sticker-phew") | ||
.resizable() | ||
.frame(width: stickerSize.width, height: stickerSize.height) | ||
.position(x: -6, y: 0, for: stickerSize, in: geometry.frame(in: .global), corner: .topTrailing) | ||
} | ||
.frame(width: geometry.size.width * 0.9) | ||
.padding(.top, isSmallScreen ? 0 : 20) | ||
VStack(alignment: .leading, spacing: isSmallScreen ? 4 : 16) { | ||
let timeString = episode.playedUpTo.storyTimeDescriptionForSharing | ||
Text("The longest episode you listened to was \(timeString)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the EOY English only? No need to localize these? |
||
.font(.system(size: 31, weight: .bold)) | ||
Text("It was \"\(episode.title ?? "unknown")\" from \"\(podcast.title ?? "unknown")\"") | ||
.font(.system(size: 15, weight: .light)) | ||
} | ||
.padding(.horizontal, 24) | ||
.padding(.bottom, isSmallScreen ? 4 : 16) | ||
} | ||
} | ||
.background(backgroundColor) | ||
.onAppear { | ||
if animated { | ||
setInitialCoverOffsetForAnimation() | ||
animationViewModel.play() | ||
} | ||
} | ||
} | ||
|
||
@ViewBuilder func covers() -> some View { | ||
GeometryReader { geometry in | ||
PodcastCoverContainer(geometry: geometry) { | ||
ZStack { | ||
PodcastCover(podcastUuid: podcast.uuid) | ||
.frame(width: geometry.size.width * 0.5, height: geometry.size.width * 0.5) | ||
.offset(x: -geometry.size.width * firstCover, y: geometry.size.width * firstCover) | ||
.modifier(animationViewModel.animate($firstCover, to: 0.4)) | ||
|
||
PodcastCover(podcastUuid: podcast.uuid) | ||
.frame(width: geometry.size.width * 0.55, height: geometry.size.width * 0.55) | ||
.offset(x: -geometry.size.width * secondCover, y: geometry.size.width * secondCover) | ||
.modifier(animationViewModel.animate($secondCover, to: 0.32)) | ||
|
||
PodcastCover(podcastUuid: podcast.uuid) | ||
.frame(width: geometry.size.width * 0.6, height: geometry.size.width * 0.6) | ||
.offset(x: -geometry.size.width * thirdCover, y: geometry.size.width * thirdCover) | ||
.modifier(animationViewModel.animate($thirdCover, to: 0.24)) | ||
|
||
PodcastCover(podcastUuid: podcast.uuid) | ||
.frame(width: geometry.size.width * 0.65, height: geometry.size.width * 0.65) | ||
.offset(x: -geometry.size.width * fourthCover, y: geometry.size.width * fourthCover) | ||
.modifier(animationViewModel.animate($fourthCover, to: 0.16)) | ||
|
||
PodcastCover(podcastUuid: podcast.uuid) | ||
.frame(width: geometry.size.width * 0.7, height: geometry.size.width * 0.7) | ||
.offset(x: -geometry.size.width * fifthCover, y: geometry.size.width * fifthCover) | ||
.modifier(animationViewModel.animate($fifthCover, to: 0.08)) | ||
|
||
PodcastCover(podcastUuid: podcast.uuid, higherQuality: true) | ||
.frame(width: geometry.size.width * 0.75, height: geometry.size.width * 0.75) | ||
.offset(x: -geometry.size.width * sixthCover, y: geometry.size.width * sixthCover) | ||
.modifier(animationViewModel.animate($sixthCover, to: 0)) | ||
} | ||
.offset(x: geometry.size.width * 0.04, y: geometry.size.height * 0.09) | ||
} | ||
} | ||
} | ||
|
||
func onAppear() { | ||
Analytics.track(.endOfYearStoryShown, story: identifier) | ||
} | ||
|
||
func onPause() { | ||
animationViewModel.pause() | ||
} | ||
|
||
func onResume() { | ||
animationViewModel.play() | ||
} | ||
|
||
func willShare() { | ||
Analytics.track(.endOfYearStoryShare, story: identifier) | ||
} | ||
|
||
func sharingAssets() -> [Any] { | ||
[ | ||
StoryShareableProvider.new(AnyView(self)), | ||
StoryShareableText(L10n.eoyStoryLongestEpisodeShareText("%1$@"), episode: episode) | ||
] | ||
} | ||
|
||
private func setInitialCoverOffsetForAnimation() { | ||
firstCover = 0.8 | ||
secondCover = 0.8 | ||
thirdCover = 0.8 | ||
fourthCover = 0.8 | ||
fifthCover = 0.8 | ||
sixthCover = 0.8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
podcasts/EndOfYear.xcassets/playback-sticker-phew.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "playback-sticker-phew.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...sts/EndOfYear.xcassets/playback-sticker-phew.imageset/playback-sticker-phew.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this color ever change? Can it be a let variable?