Skip to content

Commit

Permalink
Fix suggestion from alexvanyo
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Orgiu committed Apr 11, 2024
1 parent a6c8106 commit 1261217
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffold
import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffoldRole
import androidx.compose.material3.adaptive.layout.PaneAdaptedValue
import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -85,9 +86,12 @@ fun ListDetailSample() {
value = navigator.scaffoldValue,
listPane = {
val currentSelectedWordIndex = selectedWordIndex
val isDetailVisible =
navigator.scaffoldValue[ListDetailPaneScaffoldRole.Detail] == PaneAdaptedValue.Expanded

ListContent(
words = sampleWords.map(DefinedWord::word),
selectionState = if (currentSelectedWordIndex != null) {
selectionState = if (isDetailVisible && currentSelectedWordIndex != null) {
SelectionVisibilityState.ShowSelection(currentSelectedWordIndex)
} else {
SelectionVisibilityState.NoSelection
Expand Down Expand Up @@ -157,6 +161,7 @@ private fun ListContent(
onClick = { onIndexClick(index) }
)
}

is SelectionVisibilityState.ShowSelection -> {
Modifier.selectable(
selected = index == selectionState.selectedWordIndex,
Expand All @@ -179,6 +184,7 @@ private fun ListContent(
1.dp,
MaterialTheme.colorScheme.outline
)

is SelectionVisibilityState.ShowSelection ->
if (index == selectionState.selectedWordIndex) {
null
Expand Down
4 changes: 2 additions & 2 deletions CanonicalLayouts/list-detail-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
plugins {
id 'com.android.application' version '8.3.1' apply false
id 'com.android.library' version '8.3.1' apply false
id 'com.android.application' version '8.3.2' apply false
id 'com.android.library' version '8.3.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
}

0 comments on commit 1261217

Please sign in to comment.