-
Notifications
You must be signed in to change notification settings - Fork 171
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
Media navigation with swipe gesture #4161
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
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.
Note to myself: why the caption has vanished here?
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.
Fixed in 4f4c994
1d87a2b
to
74be5a5
Compare
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.
There are a few nits that you can decide to change or not and some more docs in the new classes/methods would be nice, but mainly I think we need to fix backpagination with either the fix discussed privately or something similar, otherwise the gallery seems to get stuck.
} | ||
HorizontalPager( | ||
state = pagerState, | ||
modifier = Modifier, |
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 probably not needed?
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, removed.
fun start() { | ||
if (!isStarted.compareAndSet(false, true)) { | ||
return | ||
} | ||
flow { |
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.
Do we have a way to stop this flow, i.e. when the user leaves the gallery screen? Or is it ok if the gallery keeps loading in bg while the user is checking the room?
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.
There is no way so far, but the flow will complete when the room will be destroyed.
The idea is to share the flow between the gallery and the media viewer with swipe. This will have to be reworked a bit when we will open the viewer from the timeline.
.takeIf { it != -1 } | ||
?: 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.
I think this could be .coerceAtLeast(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.
Yes, done
onDismiss = { | ||
onBackClick() | ||
}, |
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.
Nit: this can probably be just onDismiss = onBackClick,
. Same below.
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, done
.takeIf { it != -1 } | ||
?: 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.
coerceAtLeast(0)
here too?
@@ -115,7 +115,7 @@ private fun VoiceInfoRow( | |||
} | |||
Spacer(Modifier.width(8.dp)) | |||
Text( | |||
text = if (state.progress > 0f) state.time else voice.duration ?: state.time, | |||
text = if (state.progress > 0f) state.time else voice.mediaInfo.duration ?: state.time, |
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.
voice.mediaInfo.duration?.takeIf { state.progress > 0f } ?: state.time
maybe?
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.
The correct alternative would be
voice.mediaInfo.duration?.takeIf { state.progress == 0f } ?: state.time
and I prefer not compare float using equality.
.takeIf { it != -1 } | ||
?: 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.
I keep writing the coerceAtLeast(0)
suggestion and the function keeps moving 😅 .
onDismiss = { | ||
onBackClick() | ||
}, |
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 can probably be inlined as some other previous cases.
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.
Done
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.
👌
loadingItem?.let { item -> | ||
LaunchedEffect(item.timestamp) { | ||
state.eventSink(MediaGalleryEvents.LoadMore(item.direction)) |
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.
Nit: if (loadingItem != null)
and use loadingItem
inside maybe? It's easier to step the debugger this way.
Thanks for the review @jmartinesp . I (think I) have fixed all the remarks except the main one. I am working on it while the CI is recording the screenshots. I want to add unit test on this part. |
@jmartinesp I have fixed the pagination issue and covered it by a unit test in da22758 Let me know if it's OK for you! |
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.
Thanks for addressing the previous nits, with the back pagination issue fixed it should be good to merge!
Quality Gate passedIssues Measures |
Content
Add ability to swipe between media (images and videos) and files (files, audio and voice message) when navigating from the gallery.
Note: for now, when opening a media from the room, swipe is not supported. This support will come later.
Motivation and context
Closes #4174
Related to #1484
Screenshots / GIFs
SwipeMedia.mp4
Tests
Tested devices
Checklist