Repository navigation
#929 #833 Home top-bar overflow menu #976
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
2 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 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
67 changes: 67 additions & 0 deletions
67
.../src/androidTest/java/dev/opencode/mobile/ui/components/OpenCodeOverflowMenuLayoutTest.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,67 @@ | ||
| package dev.opencode.mobile.ui.components | ||
|
|
||
| import androidx.activity.ComponentActivity | ||
| import androidx.compose.ui.test.getUnclippedBoundsInRoot | ||
| import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
| import androidx.compose.ui.test.onNodeWithTag | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.width | ||
| import dev.opencode.mobile.theme.OpenCodeTheme | ||
| import dev.opencode.mobile.ui.icons.OpenCodeIcons | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
|
|
||
| class OpenCodeOverflowMenuLayoutTest { | ||
| @get:Rule val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
|
|
||
| @Test | ||
| fun dividerKeepsThePanelAtItsContentWidth() { | ||
| composeTestRule.setContent { | ||
| OpenCodeTheme(darkTheme = false) { | ||
| OpenCodeTopBarOverflowHost( | ||
| expanded = true, | ||
| onDismissRequest = {}, | ||
| entries = | ||
| listOf( | ||
| OpenCodeOverflowMenuEntry( | ||
| title = "Archived sessions", | ||
| icon = OpenCodeIcons.Archive, | ||
| subtitle = "4 in All projects", | ||
| onClick = {}, | ||
| testTag = ARCHIVED_TAG, | ||
| ), | ||
| OpenCodeOverflowMenuEntry( | ||
| title = "Settings", | ||
| icon = OpenCodeIcons.Settings, | ||
| onClick = {}, | ||
| testTag = SETTINGS_TAG, | ||
| dividerAbove = true, | ||
| ), | ||
| ), | ||
| ) { | ||
| OpenCodeTopBar(title = "Sessions") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val archived = composeTestRule.onNodeWithTag(ARCHIVED_TAG).getUnclippedBoundsInRoot() | ||
| val settings = composeTestRule.onNodeWithTag(SETTINGS_TAG).getUnclippedBoundsInRoot() | ||
| val metrics = composeTestRule.activity.resources.displayMetrics | ||
| val windowWidth = metrics.widthPixels / metrics.density | ||
| assertTrue( | ||
| "Menu row is ${archived.width} wide in a $windowWidth dp window", | ||
| archived.width.value < windowWidth - 64f, | ||
| ) | ||
| // The tag sits inside the row padding, so the 200 dp minimum reads a little narrower. | ||
| assertTrue(archived.width >= 170.dp) | ||
| // Every row spans the panel, so the whole row takes the tap. | ||
| assertEquals(archived.width.value, settings.width.value, 0.5f) | ||
| } | ||
|
|
||
| private companion object { | ||
| const val ARCHIVED_TAG = "overflowArchived" | ||
| const val SETTINGS_TAG = "overflowSettings" | ||
| } | ||
| } |
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
26 changes: 26 additions & 0 deletions
26
android/app/src/main/java/dev/opencode/mobile/ui/main/HomeMenu.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,26 @@ | ||
| package dev.opencode.mobile.ui.main | ||
|
|
||
| import dev.opencode.mobile.ui.components.OpenCodeOverflowMenuEntry | ||
| import dev.opencode.mobile.ui.icons.OpenCodeIcons | ||
|
|
||
| /** | ||
| * Home's top-bar ⋯ menu. Feature entries come first, in the order given; Settings always closes | ||
| * the menu, after a divider when anything sits above it. | ||
| */ | ||
| object HomeMenu { | ||
| const val SETTINGS_TEST_TAG = "homeMenuSettings" | ||
|
|
||
| fun entries( | ||
| features: List<OpenCodeOverflowMenuEntry>, | ||
| settingsTitle: String, | ||
| onSettingsClick: () -> Unit, | ||
| ): List<OpenCodeOverflowMenuEntry> = | ||
| features + | ||
| OpenCodeOverflowMenuEntry( | ||
| title = settingsTitle, | ||
| icon = OpenCodeIcons.Settings, | ||
| onClick = onSettingsClick, | ||
| testTag = SETTINGS_TEST_TAG, | ||
| dividerAbove = features.isNotEmpty(), | ||
| ) | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.