diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt index b42d74a76d7b..c9e7072e9956 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt @@ -285,15 +285,15 @@ class SelectLocationScreenTest { setContentWithTheme { SelectLocationScreen( uiState = - SelectLocationUiState.Content( - customLists = emptyList(), - filteredCustomLists = emptyList(), - countries = DUMMY_RELAY_COUNTRIES, - selectedItem = null, - selectedOwnership = null, - selectedProvidersCount = 0, - searchTerm = "" - ), + SelectLocationUiState.Content( + customLists = emptyList(), + filteredCustomLists = emptyList(), + countries = DUMMY_RELAY_COUNTRIES, + selectedItem = null, + selectedOwnership = null, + selectedProvidersCount = 0, + searchTerm = "" + ), onSelectRelay = mockedOnSelectRelay ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt index 970349231e8e..872680489879 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt @@ -278,11 +278,6 @@ fun ScaffoldWithSmallTopBar( actions = actions ) }, - content = { - content( - Modifier.fillMaxSize() - .padding(it) - ) - } + content = { content(Modifier.fillMaxSize().padding(it)) } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt index df0eab97a83f..6783334407ed 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt @@ -7,6 +7,8 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -99,6 +101,7 @@ fun CreateCustomListDialog( val focusRequester = remember { FocusRequester() } val keyboardController = LocalSoftwareKeyboardController.current val name = remember { mutableStateOf("") } + val isValidName by remember { derivedStateOf { name.value.isNotBlank() } } AlertDialog( title = { @@ -115,7 +118,7 @@ fun CreateCustomListDialog( onInputChanged() }, onSubmit = { - if (it.isNotBlank()) { + if (isValidName) { createCustomList(it) } }, @@ -152,7 +155,7 @@ fun CreateCustomListDialog( PrimaryButton( text = stringResource(id = R.string.create), onClick = { createCustomList(name.value) }, - isEnabled = name.value.isNotBlank() + isEnabled = isValidName ) }, dismissButton = { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt index 37f8ae63d74e..60f4b94ad727 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt @@ -7,6 +7,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -79,6 +80,7 @@ fun EditCustomListNameDialog( val focusRequester = remember { FocusRequester() } val keyboardController = LocalSoftwareKeyboardController.current val input = remember { mutableStateOf(uiState.name) } + val isValidName by remember { derivedStateOf { input.value.isNotBlank() } } AlertDialog( title = { Text( @@ -94,7 +96,7 @@ fun EditCustomListNameDialog( onInputChanged() }, onSubmit = { - if (it.isNotBlank()) { + if (isValidName) { updateName(it) } }, @@ -141,7 +143,7 @@ fun EditCustomListNameDialog( PrimaryButton( text = stringResource(id = R.string.save), onClick = { updateName(input.value) }, - isEnabled = input.value.isNotBlank() + isEnabled = isValidName ) }, dismissButton = { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Effects.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Effects.kt index 328e3c7a46a8..80e7d7c9ca6b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Effects.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Effects.kt @@ -10,9 +10,7 @@ import kotlinx.coroutines.launch fun RunOnKeyChange(key: Any, block: suspend CoroutineScope.() -> Unit) { val scope = rememberCoroutineScope() rememberSaveable(key) { - scope.launch { - block() - } + scope.launch { block() } key } }