mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2025-12-05 22:31:55 +00:00
Extract MyLocations Widget to a separate function
This commit is contained in:
parent
3dcefe6fed
commit
54e147242e
@ -66,8 +66,6 @@ private fun LeftColumn(
|
|||||||
myLocationsViewModelApi: MyLocationsViewModelApi,
|
myLocationsViewModelApi: MyLocationsViewModelApi,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val myLocations = myLocationsViewModelApi.myLocationsFlow.collectAsState(emptyList()).value
|
|
||||||
|
|
||||||
Column(modifier) {
|
Column(modifier) {
|
||||||
GroupHeader(
|
GroupHeader(
|
||||||
ComposeTemplateBundle.message("weather.app.my.locations.header.text"),
|
ComposeTemplateBundle.message("weather.app.my.locations.header.text"),
|
||||||
@ -78,8 +76,15 @@ private fun LeftColumn(
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
|
||||||
val listState = rememberSelectableLazyListState()
|
MyLocationsList(Modifier.fillMaxSize(), myLocationsViewModelApi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
internal fun MyLocationsList(modifier: Modifier = Modifier, myLocationsViewModelApi: MyLocationsViewModelApi) {
|
||||||
|
val myLocations = myLocationsViewModelApi.myLocationsFlow.collectAsState(emptyList()).value
|
||||||
|
|
||||||
|
val listState = rememberSelectableLazyListState()
|
||||||
// JEWEL-938 This will trigger on SelectableLazyColum's `onSelectedIndexesChange` callback
|
// JEWEL-938 This will trigger on SelectableLazyColum's `onSelectedIndexesChange` callback
|
||||||
LaunchedEffect(myLocations) {
|
LaunchedEffect(myLocations) {
|
||||||
var lastActiveItemIndex = -1
|
var lastActiveItemIndex = -1
|
||||||
@ -101,7 +106,7 @@ private fun LeftColumn(
|
|||||||
}
|
}
|
||||||
|
|
||||||
SelectableLazyColumn(
|
SelectableLazyColumn(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = modifier,
|
||||||
selectionMode = SelectionMode.Single,
|
selectionMode = SelectionMode.Single,
|
||||||
state = listState,
|
state = listState,
|
||||||
onSelectedIndexesChange = { indices ->
|
onSelectedIndexesChange = { indices ->
|
||||||
@ -120,7 +125,6 @@ private fun LeftColumn(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ContentItemRow(item: Location, isSelected: Boolean, isActive: Boolean) {
|
private fun ContentItemRow(item: Location, isSelected: Boolean, isActive: Boolean) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user