Skip to content

Commit

Permalink
spotlessApply
Browse files Browse the repository at this point in the history
  • Loading branch information
chikoski committed Dec 5, 2024
1 parent 07f84a6 commit 018fb00
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fun FocusRestorationInListDetail(catalogData: List<CatalogItem>, modifier: Modif
detailPane = {
AnimatedPane {
val catalogItem = threePaneScaffoldNavigator.currentDestination?.content
if(catalogItem !=null){
if (catalogItem != null) {
DetailsPane(catalogItem)
}
}
Expand All @@ -147,7 +147,7 @@ fun FocusRestorationInListDetail(catalogData: List<CatalogItem>, modifier: Modif
LaunchedEffect(isListPaneVisible) {
if (isListPaneVisible) {
val catalogItemIndex = catalogData.indexOf(lastSelectedCatalogItem)
if(catalogItemIndex >= 0) {
if (catalogItemIndex >= 0) {
// Ensure the ListItem for the last selected item is visible
listState.animateScrollToItem(catalogItemIndex)
}
Expand All @@ -157,7 +157,6 @@ fun FocusRestorationInListDetail(catalogData: List<CatalogItem>, modifier: Modif
}
// [END android_compose_touchinput_focus_restoration_listdetail]


@OptIn(ExperimentalComposeUiApi::class)
@Composable
private fun ListPane(
Expand Down Expand Up @@ -213,7 +212,6 @@ private fun DetailsPane(
Text("Click me")
}
}

}

fun FocusRequester.tryRequestFocus(): Result<Unit> {
Expand All @@ -227,12 +225,12 @@ fun FocusRequester.tryRequestFocus(): Result<Unit> {

@Composable
fun Modifier.initialFocus(focusRequester: FocusRequester = remember { FocusRequester() }): Modifier {
var isSafe by remember{ mutableStateOf(false) }
var isSafe by remember { mutableStateOf(false) }

LaunchedEffect(isSafe) {
if (isSafe) {
focusRequester.tryRequestFocus()
}
}
return this.focusRequester(focusRequester).onPlaced { isSafe = true }
}
}

0 comments on commit 018fb00

Please sign in to comment.