Skip to content

Conversation

tiwiz
Copy link
Contributor

@tiwiz tiwiz commented Jul 31, 2025

No description provided.

@tiwiz tiwiz marked this pull request as ready for review July 31, 2025 17:12
@tiwiz tiwiz requested a review from dturner as a code owner July 31, 2025 17:12
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @tiwiz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the groundwork for implementing a flexible and adaptive three-pane (List-List-Detail) UI pattern within the application. It introduces core components and strategies that allow the user interface to intelligently adjust its layout based on the available screen real estate, providing an optimized experience across various device form factors.

Highlights

  • Adaptive Layout Implementation: New DualPaneScene and ThreePaneScene components, along with their respective SceneStrategy implementations, are added to manage multi-pane layouts based on WindowSizeClass. These strategies dynamically determine how many panes to display (one, two, or three) based on the available screen width.
  • New Three-Pane Activity Example: A ThreePanesActivity is introduced as a practical example of how to integrate the new adaptive navigation strategies. This activity demonstrates a List-List-Detail flow, where the UI adapts from a single pane to a dual-pane or three-pane layout as the window size increases.
  • Dependency Updates and Additions: The project's build.gradle.kts file has been updated to include androidx.window and androidx.window.core dependencies, which are crucial for adaptive layouts. Additionally, several existing dependencies, including Kotlin, Compose BOM, and Navigation3, have been updated to their latest versions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@tiwiz tiwiz changed the title Started strategy for Three Panes List-List-Detail [WIP] Three Panes (List-List-Detail) Strategy Jul 31, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new three-pane layout strategy, which is a great addition for adaptive UIs. The implementation is a good starting point. My review includes a critical fix for a UI bug in the list display, along with several suggestions to improve code clarity, maintainability, and documentation accuracy. These include correcting KDocs, removing redundant dependencies and code, and adopting more idiomatic Kotlin constructs.

@@ -71,6 +71,8 @@ dependencies {
implementation(libs.androidx.material3.windowsizeclass)
implementation(libs.androidx.adaptive.layout)
implementation(libs.androidx.material3.navigation3)
implementation(libs.androidx.window)
implementation(libs.androidx.window.core)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The androidx.window:window-core dependency is a transitive dependency of androidx.window. You only need to declare the androidx.window dependency. Including redundant dependencies can make dependency management more complex and is generally discouraged.

Comment on lines +45 to +47
* A [SceneStrategy] that always creates a 1-entry [Scene] simply displaying the last entry in the
* list.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The KDoc for DualPaneSceneStrategy is inaccurate. It states that it always creates a "1-entry [Scene]", but it actually creates a DualPaneScene which contains two entries when screen width and back stack depth conditions are met. Please update the documentation to reflect the actual behavior.

Suggested change
* A [SceneStrategy] that always creates a 1-entry [Scene] simply displaying the last entry in the
* list.
*/
* A [SceneStrategy] that creates a [DualPaneScene] when the window width is medium or larger
* and there are at least two entries in the back stack.
*/

Comment on lines +50 to +51
* Basic example with two screens that uses the entryProvider DSL and has a persistent back stack.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The KDoc for ThreePanesActivity appears to be copied from another example. It mentions "two screens", but this activity demonstrates a three-pane layout. Please update the documentation to be accurate.

Suggested change
* Basic example with two screens that uses the entryProvider DSL and has a persistent back stack.
*/
* Basic example that demonstrates a three-pane layout strategy.
*/

import androidx.navigation3.ui.SceneStrategy
import androidx.window.core.layout.WindowSizeClass
import androidx.window.core.layout.WindowSizeClass.Companion.WIDTH_DP_LARGE_LOWER_BOUND
import androidx.window.core.layout.WindowSizeClass.Companion.WIDTH_DP_MEDIUM_LOWER_BOUND

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The import androidx.window.core.layout.WindowSizeClass.Companion.WIDTH_DP_MEDIUM_LOWER_BOUND is unused in this file and can be removed to improve code cleanliness.

Comment on lines +65 to +73
private fun computeEntriesAndEmptyState() : Triple<NavEntry<T>, NavEntry<T>?, NavEntry<T>?> {
if(entries.size >= 3) {
return Triple(entries[entries.lastIndex - 2], entries[entries.lastIndex - 1], entries.last())
} else if(entries.size == 2) {
return Triple(entries[entries.lastIndex - 1], entries.last(), null)
} else {
return Triple(entries.last(), null, null)
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This if-else if-else chain can be replaced with a when expression, which is more idiomatic and generally more readable in Kotlin.

    private fun computeEntriesAndEmptyState() : Triple<NavEntry<T>, NavEntry<T>?, NavEntry<T>?> {
        return when {
            entries.size >= 3 -> Triple(entries[entries.lastIndex - 2], entries[entries.lastIndex - 1], entries.last())
            entries.size == 2 -> Triple(entries.first(), entries.last(), null)
            else -> Triple(entries.first(), null, null)
        }
    }

Comment on lines +78 to +80
* A [SceneStrategy] that always creates a 1-entry [Scene] simply displaying the last entry in the
* list.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The KDoc for ThreePaneSceneStrategy is inaccurate and seems to be copied from another class. It should describe that this strategy creates a ThreePaneScene for large-width windows.

 * A [SceneStrategy] that creates a [ThreePaneScene] when the window width is large. The
 * [ThreePaneScene] can display one, two, or three panes depending on the back stack depth.
 */

Comment on lines +94 to +101
/*
@Composable
internal fun <T : Any> SceneStrategy<T>.calculateSceneWithSinglePaneFallback(
entries: List<NavEntry<T>>,
onBack: (count: Int) -> Unit,
): Scene<T> =
calculateScene(entries, onBack) ?: ThreePaneSceneStrategy<T>().calculateScene(entries, onBack)
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out code should be removed before merging to keep the codebase clean and avoid confusion.

@@ -59,6 +60,8 @@ kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serializa
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationCore" }
androidx-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
androidx-material3-navigation3 = { group = "androidx.compose.material3.adaptive", name = "adaptive-navigation3", version.ref = "nav3Material" }
androidx-window = { group = "androidx.window", name = "window", version.ref = "window" }
androidx-window-core = { group = "androidx.window", name = "window-core", version.ref = "window" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The androidx-window-core library is a transitive dependency of androidx-window. It's good practice to only declare direct dependencies in your Gradle files. Since androidx.window.core is not needed directly, you can remove this line. Remember to also remove the corresponding implementation from app/build.gradle.kts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant