Repository navigation
feat: add the mini and fullscreen players #206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3105546
docs: plan the mini and fullscreen players
j0ker70 d61cb57
docs: record the maintainer's answers to the plan
j0ker70 79f8b4c
docs: apply the second plan check's notes
j0ker70 7cea4ad
docs: keep the fullscreen controls clear of the system bars
j0ker70 c14dba3
docs: apply the fourth plan check's notes
j0ker70 4f21a55
docs: fold the fifth plan check's notes into the plan
j0ker70 4319bf7
feat: add the fullscreen glyphs and the duration-scrim opacity
j0ker70 25fb4f1
feat: add the mini and fullscreen players
j0ker70 5de9fbc
docs: describe the mini and fullscreen players
j0ker70 1ca534d
fix: give fullscreen text a content color and take key focus
j0ker70 e49e2d6
docs: make the mini player's reopen check one that can be seen
j0ker70 042d3f4
fix: give the mini player's text a content color and its height back
j0ker70 61960ff
fix: keep a pause through a link refresh, and fullscreen's controls i…
j0ker70 b84153b
fix: keep fullscreen's control row at the bottom
j0ker70 aa4d9e3
fix: keep fullscreen's exit button when the times are wide
j0ker70 09af977
fix: keep fullscreen's controls while a finger is held down
j0ker70 084ee33
test: add the mini and fullscreen players' screenshot tests
j0ker70 dd37b38
fix: keep fullscreen's failure Banner clear of the title
j0ker70 4dc54ad
docs: archive the mini and fullscreen players change
j0ker70 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 hidden or 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 hidden or 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 hidden or 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
83 changes: 60 additions & 23 deletions
83
app/src/main/kotlin/io/github/dewfallapp/navigation/DewfallNavigation.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,41 +1,78 @@ | ||
| package io.github.dewfallapp.navigation | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.consumeWindowInsets | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.layout.onSizeChanged | ||
| import androidx.compose.ui.platform.LocalDensity | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.lifecycle.viewmodel.navigation3.rememberViewModelStoreNavEntryDecorator | ||
| import androidx.navigation3.runtime.entryProvider | ||
| import androidx.navigation3.runtime.rememberNavBackStack | ||
| import androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecorator | ||
| import androidx.navigation3.ui.NavDisplay | ||
| import io.github.dewfallapp.feature.player.ui.MiniPlayer | ||
| import io.github.dewfallapp.feature.player.ui.PlayerRoute | ||
| import io.github.dewfallapp.feature.youtubesearch.ui.YouTubeSearch | ||
|
|
||
| /** | ||
| * The app's screens and the back stack between them. Only :app knows Navigation 3. Features take | ||
| * plain actions, such as opening a video, and never see each other. The back stack survives | ||
| * configuration changes and process death, and each entry keeps its own saved state and ViewModels, | ||
| * which are cleared when it leaves the back stack. See docs/architecture.md#navigation. | ||
| * The app's screens, the back stack between them, and the mini player under them. Only :app knows | ||
| * Navigation 3. Features take plain actions, such as opening a video, and never see each other. The | ||
| * back stack survives configuration changes and process death, and each entry keeps its own saved | ||
| * state and ViewModels, which are cleared when it leaves the back stack. See | ||
| * docs/architecture.md#navigation. | ||
| * | ||
| * The mini player sits under the screens while no video screen is on top, and the screens end at | ||
| * its top edge: the box above it gives up the mini player's height from the window insets at its | ||
| * bottom, so a screen's own safe drawing padding leaves out the navigation bar, and keeps the part | ||
| * of the keyboard that reaches above the mini player. | ||
| */ | ||
| @Composable | ||
| internal fun DewfallNavigation(modifier: Modifier = Modifier) { | ||
| val backStack = rememberNavBackStack(SearchKey) | ||
| NavDisplay( | ||
| backStack = backStack, | ||
| onBack = { backStack.goBack() }, | ||
| modifier = modifier, | ||
| entryDecorators = | ||
| listOf( | ||
| rememberSaveableStateHolderNavEntryDecorator(), | ||
| rememberViewModelStoreNavEntryDecorator(), | ||
| ), | ||
| entryProvider = | ||
| entryProvider { | ||
| entry<SearchKey> { | ||
| YouTubeSearch(onOpenVideo = { videoId -> backStack.openVideo(videoId) }) | ||
| } | ||
| entry<PlayerKey>(clazzContentKey = { key -> key.entryId }) { key -> | ||
| PlayerRoute(videoId = key.videoId, onClose = { backStack.close(key) }) | ||
| } | ||
| }, | ||
| ) | ||
| val showsMiniPlayer = backStack.showsMiniPlayer() | ||
| var miniPlayerHeight by remember { mutableStateOf(0.dp) } | ||
| val density = LocalDensity.current | ||
| Column(modifier = modifier.fillMaxSize()) { | ||
| NavDisplay( | ||
| backStack = backStack, | ||
| onBack = { backStack.goBack() }, | ||
| modifier = | ||
| Modifier.weight(1f) | ||
| .consumeWindowInsets( | ||
| PaddingValues(bottom = if (showsMiniPlayer) miniPlayerHeight else 0.dp), | ||
| ), | ||
| entryDecorators = | ||
| listOf( | ||
| rememberSaveableStateHolderNavEntryDecorator(), | ||
| rememberViewModelStoreNavEntryDecorator(), | ||
| ), | ||
| entryProvider = | ||
| entryProvider { | ||
| entry<SearchKey> { | ||
| YouTubeSearch(onOpenVideo = { videoId -> backStack.openVideo(videoId) }) | ||
| } | ||
| entry<PlayerKey>(clazzContentKey = { key -> key.entryId }) { key -> | ||
| PlayerRoute(videoId = key.videoId, onMinimize = { backStack.close(key) }) | ||
| } | ||
| }, | ||
| ) | ||
| if (showsMiniPlayer) { | ||
| // The box reports 0 when the mini player draws nothing, such as after it closes, so | ||
| // the screens above get the navigation bar's inset back. | ||
| Box( | ||
| Modifier.onSizeChanged { miniPlayerHeight = with(density) { it.height.toDp() } }, | ||
| ) { | ||
| MiniPlayer(onOpenVideo = { videoId -> backStack.openVideo(videoId) }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
...signsystem/src/main/kotlin/io/github/dewfallapp/core/designsystem/theme/DewfallOpacity.kt
This file contains hidden or 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,14 @@ | ||
| package io.github.dewfallapp.core.designsystem.theme | ||
|
|
||
| /** | ||
| * Dewfall's opacities that Material 3's components don't already apply, from the opacity tokens in | ||
| * docs/design/claude-design/design-system/tokens.json. Each one comes with its first use. A token | ||
| * edit there is copied here by hand, and DesignTokensTest fails until both agree. | ||
| */ | ||
| object DewfallOpacity { | ||
| /** | ||
| * duration-scrim, 0.8. `surface` at this opacity behind the duration tag on a thumbnail, and | ||
| * behind the fullscreen player's controls over video. | ||
| */ | ||
| const val DURATION_SCRIM = 0.8f | ||
| } |
This file contains hidden or 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,18 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- | ||
| The fullscreen glyph from Material Symbols Rounded, weight 400, grade 0, optical size 24, outlined, | ||
| as the design system's Iconography asks. Copied from | ||
| symbols/android/fullscreen/materialsymbolsrounded/fullscreen_24px.xml in | ||
| github.com/google/material-design-icons at commit 10ecc14790, under the Apache License 2.0, | ||
| whose text is in docs/design/claude-design/design-system/licenses/MaterialSymbols-Apache-2.0.txt. | ||
| Screens tint it with a MaterialTheme color role. | ||
| --> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960"> | ||
| <path | ||
| android:fillColor="#FF000000" | ||
| android:pathData="M200,760L280,760Q297,760 308.5,771.5Q320,783 320,800Q320,817 308.5,828.5Q297,840 280,840L160,840Q143,840 131.5,828.5Q120,817 120,800L120,680Q120,663 131.5,651.5Q143,640 160,640Q177,640 188.5,651.5Q200,663 200,680L200,760ZM760,760L760,680Q760,663 771.5,651.5Q783,640 800,640Q817,640 828.5,651.5Q840,663 840,680L840,800Q840,817 828.5,828.5Q817,840 800,840L680,840Q663,840 651.5,828.5Q640,817 640,800Q640,783 651.5,771.5Q663,760 680,760L760,760ZM200,200L200,280Q200,297 188.5,308.5Q177,320 160,320Q143,320 131.5,308.5Q120,297 120,280L120,160Q120,143 131.5,131.5Q143,120 160,120L280,120Q297,120 308.5,131.5Q320,143 320,160Q320,177 308.5,188.5Q297,200 280,200L200,200ZM760,200L680,200Q663,200 651.5,188.5Q640,177 640,160Q640,143 651.5,131.5Q663,120 680,120L800,120Q817,120 828.5,131.5Q840,143 840,160L840,280Q840,297 828.5,308.5Q817,320 800,320Q783,320 771.5,308.5Q760,297 760,280L760,200Z" /> | ||
| </vector> |
Oops, something went wrong.
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.
Bound the mini player height so that Search keeps usable space.
The mini player has no maximum height. Its title has no line limit or overflow setting, and
miniPlayerContentpasses the item title through without a length limit. A long title can wrap onto many lines and grow the mini player. The mini player sits in an unweightedBox, which the parentColumnmeasures before the weightedNavDisplay. On a short split-screen window at a large font size, the mini player can take all of the remaining height. Search then has no usable area while the mini player is open. The back gesture and the close control still work.Keep the mini player at a bounded height so that
NavDisplayalways has usable space. Choose the bound: a title line limit, an ellipsis, or a maximum height. Check the result in a 320 dp high window at the largest font size.Source: Path instructions