Created
December 12, 2022 14:11
-
-
Save MrNtlu/277782020ab7d10fc095c4d9f438c4e3 to your computer and use it in GitHub Desktop.
This file contains 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
@Composable | |
fun ExampleScreen( | |
sharedViewModel: SharedViewModel, | |
) { | |
val context = LocalContext.current | |
val listState = rememberLazyListState() | |
val expandedFabState = remember { | |
derivedStateOf { | |
listState.firstVisibleItemIndex == 0 | |
} | |
} | |
LaunchedEffect(key1 = expandedFabState.value) { | |
sharedViewModel.expandedFab.value = expandedFabState.value | |
} | |
LaunchedEffect(key1 = Unit) { | |
sharedViewModel.fabOnClick.value = { | |
Toast.makeText(context, "Settings FAB Clicked", Toast.LENGTH_SHORT).show() | |
} | |
sharedViewModel.smallFabOnClick.value = { | |
Toast.makeText(context, "Settings Small FAB Clicked", Toast.LENGTH_SHORT).show() | |
} | |
} | |
LazyColumn(state = listState, modifier = Modifier.fillMaxSize()) { | |
for (index in 0 until 100) { | |
item { | |
Text( | |
text = "List item - $index", | |
modifier = Modifier.padding(24.dp) | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment