Merge pull request #966 from tjmtic/main

Update remember to rememberSaveable
pull/974/head
Adetunji Dahunsi 1 year ago committed by GitHub
commit d3deb91942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,7 +33,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -170,13 +170,13 @@ fun NiaCatalog() {
item { Text("Chips", Modifier.padding(top = 16.dp)) } item { Text("Chips", Modifier.padding(top = 16.dp)) }
item { item {
FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) { FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
var firstChecked by remember { mutableStateOf(false) } var firstChecked by rememberSaveable { mutableStateOf(false) }
NiaFilterChip( NiaFilterChip(
selected = firstChecked, selected = firstChecked,
onSelectedChange = { checked -> firstChecked = checked }, onSelectedChange = { checked -> firstChecked = checked },
label = { Text(text = "Enabled") }, label = { Text(text = "Enabled") },
) )
var secondChecked by remember { mutableStateOf(true) } var secondChecked by rememberSaveable { mutableStateOf(true) }
NiaFilterChip( NiaFilterChip(
selected = secondChecked, selected = secondChecked,
onSelectedChange = { checked -> secondChecked = checked }, onSelectedChange = { checked -> secondChecked = checked },
@ -199,7 +199,7 @@ fun NiaCatalog() {
item { Text("Icon buttons", Modifier.padding(top = 16.dp)) } item { Text("Icon buttons", Modifier.padding(top = 16.dp)) }
item { item {
FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) { FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
var firstChecked by remember { mutableStateOf(false) } var firstChecked by rememberSaveable { mutableStateOf(false) }
NiaIconToggleButton( NiaIconToggleButton(
checked = firstChecked, checked = firstChecked,
onCheckedChange = { checked -> firstChecked = checked }, onCheckedChange = { checked -> firstChecked = checked },
@ -216,7 +216,7 @@ fun NiaCatalog() {
) )
}, },
) )
var secondChecked by remember { mutableStateOf(true) } var secondChecked by rememberSaveable { mutableStateOf(true) }
NiaIconToggleButton( NiaIconToggleButton(
checked = secondChecked, checked = secondChecked,
onCheckedChange = { checked -> secondChecked = checked }, onCheckedChange = { checked -> secondChecked = checked },
@ -272,14 +272,14 @@ fun NiaCatalog() {
item { Text("View toggle", Modifier.padding(top = 16.dp)) } item { Text("View toggle", Modifier.padding(top = 16.dp)) }
item { item {
FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) { FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
var firstExpanded by remember { mutableStateOf(false) } var firstExpanded by rememberSaveable { mutableStateOf(false) }
NiaViewToggleButton( NiaViewToggleButton(
expanded = firstExpanded, expanded = firstExpanded,
onExpandedChange = { expanded -> firstExpanded = expanded }, onExpandedChange = { expanded -> firstExpanded = expanded },
compactText = { Text(text = "Compact view") }, compactText = { Text(text = "Compact view") },
expandedText = { Text(text = "Expanded view") }, expandedText = { Text(text = "Expanded view") },
) )
var secondExpanded by remember { mutableStateOf(true) } var secondExpanded by rememberSaveable { mutableStateOf(true) }
NiaViewToggleButton( NiaViewToggleButton(
expanded = secondExpanded, expanded = secondExpanded,
onExpandedChange = { expanded -> secondExpanded = expanded }, onExpandedChange = { expanded -> secondExpanded = expanded },
@ -318,7 +318,7 @@ fun NiaCatalog() {
} }
item { Text("Tabs", Modifier.padding(top = 16.dp)) } item { Text("Tabs", Modifier.padding(top = 16.dp)) }
item { item {
var selectedTabIndex by remember { mutableStateOf(0) } var selectedTabIndex by rememberSaveable { mutableStateOf(0) }
val titles = listOf("Topics", "People") val titles = listOf("Topics", "People")
NiaTabRow(selectedTabIndex = selectedTabIndex) { NiaTabRow(selectedTabIndex = selectedTabIndex) {
titles.forEachIndexed { index, title -> titles.forEachIndexed { index, title ->
@ -332,7 +332,7 @@ fun NiaCatalog() {
} }
item { Text("Navigation", Modifier.padding(top = 16.dp)) } item { Text("Navigation", Modifier.padding(top = 16.dp)) }
item { item {
var selectedItem by remember { mutableStateOf(0) } var selectedItem by rememberSaveable { mutableStateOf(0) }
val items = listOf("For you", "Saved", "Interests") val items = listOf("For you", "Saved", "Interests")
val icons = listOf( val icons = listOf(
NiaIcons.UpcomingBorder, NiaIcons.UpcomingBorder,

Loading…
Cancel
Save