Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -108,10 +108,10 @@ fun CurrencyPicker(
val currencyValues = currencyPickerData.currencyValues

val defaultCurrencyEntry = currencyNames[currencyValues.indexOf(defaultCurrencyValue)]
val (selectedCurrencyOption, onCurrencyOptionSelected) = remember {
val (selectedCurrencyOption, onCurrencyOptionSelected) = rememberSaveable {
mutableStateOf(defaultCurrencyEntry)
}
val (searchText, onSearchTextChanged) = remember { mutableStateOf("") }
val (searchText, onSearchTextChanged) = rememberSaveable { mutableStateOf("") }
val filteredCurrencies = currencyNames.filter { it.contains(searchText, ignoreCase = true) }

val coroutineScope = rememberCoroutineScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import androidx.compose.animation.slideOutVertically
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import kotlinx.coroutines.delay

Expand All @@ -44,7 +44,7 @@ fun SlideInAnimatedContainer(
initialDelay: Long, content:
@Composable () -> Unit
) {
val showContent = remember { mutableStateOf(false) }
val showContent = rememberSaveable { mutableStateOf(false) }
LaunchedEffect(key1 = true) {
delay(initialDelay)
showContent.value = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -337,20 +338,20 @@ private fun LocaleSettings(viewModel: SettingsViewModel) {
val context = LocalContext.current
// Date related values.
val dateValue = dateStyleToDisplayFormat(viewModel.dateStyle.observeAsState().value!!)
val dateDialog = remember { mutableStateOf(false) }
val dateDialog = rememberSaveable { mutableStateOf(false) }
val dateRadioOptions = DateStyle.entries.map { dateStyleToDisplayFormat(it) }
val (selectedDateOption, onDateOptionSelected) = remember {
val (selectedDateOption, onDateOptionSelected) = rememberSaveable {
mutableStateOf(dateValue)
}

// Currency related values.
val currencyDialog = remember { mutableStateOf(false) }
val currencyDialog = rememberSaveable { mutableStateOf(false) }
val currencyNames =
context.applicationContext.resources.getStringArray(R.array.currency_names)
val currencyValues =
context.applicationContext.resources.getStringArray(R.array.currency_values)

val selectedCurrencyName = remember {
val selectedCurrencyName = rememberSaveable {
mutableStateOf(currencyNames[currencyValues.indexOf(viewModel.getDefaultCurrencyValue())])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -81,14 +81,14 @@ fun WelcomeScreen(navController: NavController) {
val context = LocalContext.current
val viewModel: WelcomeViewModel = hiltViewModel()

val currencyDialog = remember { mutableStateOf(false) }
val currencyDialog = rememberSaveable { mutableStateOf(false) }
val currencyNames =
context.applicationContext.resources.getStringArray(R.array.currency_names)
val currencyValues =
context.applicationContext.resources.getStringArray(R.array.currency_values)


val selectedCurrencyName = remember {
val selectedCurrencyName = rememberSaveable {
mutableStateOf(currencyNames[currencyValues.indexOf(viewModel.getDefaultCurrencyValue())])
}

Expand Down
Loading