Skip to content

Commit

Permalink
Merge pull request android#972 from tjmtic/now-update-888
Browse files Browse the repository at this point in the history
Update primitive mutable states to mutableState API where applicable
  • Loading branch information
tunjid authored Oct 14, 2023
2 parents ab66972 + 2b84faf commit 78573b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -318,7 +319,7 @@ fun NiaCatalog() {
}
item { Text("Tabs", Modifier.padding(top = 16.dp)) }
item {
var selectedTabIndex by rememberSaveable { mutableStateOf(0) }
var selectedTabIndex by rememberSaveable { mutableIntStateOf(0) }
val titles = listOf("Topics", "People")
NiaTabRow(selectedTabIndex = selectedTabIndex) {
titles.forEachIndexed { index, title ->
Expand All @@ -332,7 +333,7 @@ fun NiaCatalog() {
}
item { Text("Navigation", Modifier.padding(top = 16.dp)) }
item {
var selectedItem by rememberSaveable { mutableStateOf(0) }
var selectedItem by rememberSaveable { mutableIntStateOf(0) }
val items = listOf("For you", "Saved", "Interests")
val icons = listOf(
NiaIcons.UpcomingBorder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
Expand Down Expand Up @@ -205,7 +206,7 @@ fun Scrollbar(

// Used to immediately show drag feedback in the UI while the scrolling implementation
// catches up
var interactionThumbTravelPercent by remember { mutableStateOf(Float.NaN) }
var interactionThumbTravelPercent by remember { mutableFloatStateOf(Float.NaN) }

var track by remember { mutableStateOf(ScrollbarTrack(packedValue = 0)) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -74,7 +74,7 @@ private inline fun rememberDraggableScroller(
itemsAvailable: Int,
crossinline scroll: suspend (index: Int) -> Unit,
): (Float) -> Unit {
var percentage by remember { mutableStateOf(Float.NaN) }
var percentage by remember { mutableFloatStateOf(Float.NaN) }
val itemCount by rememberUpdatedState(itemsAvailable)

LaunchedEffect(percentage) {
Expand Down

0 comments on commit 78573b8

Please sign in to comment.