-
Notifications
You must be signed in to change notification settings - Fork 135
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
End of Year: add stories Data Source and gestures #389
Conversation
Instead of relying on progress.
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.
Nice, this is shaping up! I found a bug with tapping back while on the first story (see video below).
I also left a few other comments below. Let me know what you think.
private let dataSource: StoriesDataSource | ||
private let publisher: Timer.TimerPublisher | ||
private var cancellable: Cancellable? | ||
private var interval: TimeInterval = 5.seconds |
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.
I wonder if in the future we should move this into the datasource to allow different story views to have different durations?
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.
Yes, that's the idea! I'll do it in another PR. :)
} | ||
|
||
func previous() { | ||
progress = Double(Int(progress) - 1) |
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.
If I tap the previous action while on the first view the progress gets set to -1 which causes progress to be delayed by 5 seconds before it starts ticking up again.
storiesbug.mov
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.
Good catch! Fixed in e44ffee
if currentStory >= self.numberOfStories { | ||
newProgress = 0 | ||
self.currentStory = 0 |
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.
What do you think about offloading this behavior to the datasource to allow it to decide how it wants to handle when we reach the end of the stories?
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.
This is also another idea I have for subsequent tasks. :)
height: value.predictedEndLocation.y - value.location.y | ||
) | ||
|
||
// If a quick swipe down is performed, dismiss the view |
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.
Are we also planning on adding a swipe next/back gesture?
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.
Hmm, is swipe next/back gesture common in stories inside the same "context"?
I know it's a thing when you want to "advance" (to the next user, for example), but not for the next story.
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.
Good point. I don't think it's needed anymore.
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.
Nice work!
This PR adds a data source protocol to populate the Stories view with stories and also adds a few gestures.
Simulator.Screen.Recording.-.iPhone.14.-.2022-10-13.at.12.39.14.mp4
About the data source
I tried to be as generic as possible with how we display stories to allow different cases to be used without much effort.
In order to show stories, we need to pass a data source that conforms to
StoriesDataSource
. Each story is simply aView
.This makes it possible for a story to be a custom view, an image, or a video. It's also generic enough to be used for other purposes in the future.
Take a look at the
TestStoriesDataSource
for an example.The overall API is still in its early days, so we'll change it as the feature gets developed.
To test
endOfYear
flag inFeatureFlag.swift
¶ Swipe down can be improved with better effects (like with the view following the gesture) but this will be done in another task
Checklist
CHANGELOG.md
if necessary.