Skip to content

Commit

Permalink
Remove the language change dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
david-livefront committed Jan 31, 2025
1 parent 9b3bb32 commit 50d4a93
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
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.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
Expand All @@ -30,7 +27,6 @@ import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectButton
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
Expand Down Expand Up @@ -128,7 +124,6 @@ private fun LanguageSelectionRow(
modifier: Modifier = Modifier,
resources: Resources = LocalContext.current.resources,
) {
var languageChangedDialogOption: String? by rememberSaveable { mutableStateOf(value = null) }
BitwardenMultiSelectButton(
label = stringResource(id = R.string.language),
options = AppLanguage.entries.map { it.text() }.toImmutableList(),
Expand All @@ -137,19 +132,10 @@ private fun LanguageSelectionRow(
onLanguageSelection(
AppLanguage.entries.first { selectedLanguage == it.text.toString(resources) },
)
languageChangedDialogOption = selectedLanguage
},
cardStyle = CardStyle.Full,
modifier = modifier,
)

languageChangedDialogOption?.let {
BitwardenBasicDialog(
title = stringResource(id = R.string.language),
message = stringResource(id = R.string.language_change_x_description, it),
onDismissRequest = { languageChangedDialogOption = null },
)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,7 @@ class AppearanceScreenTest : BaseComposeTest() {
}

@Test
fun `on language row click should display language selection dialog`() {
composeTestRule
.onNodeWithContentDescription(label = "Default (System). Language")
.performScrollTo()
.performClick()
composeTestRule
.onAllNodesWithText("Language")
.filterToOne(hasAnyAncestor(isDialog()))
.assertIsDisplayed()
}

@Test
fun `on language selection dialog item click should send LanguageChange and show dialog`() {
fun `on language selection dialog item click should send LanguageChange`() {
// Clicking the Language row shows the language selection dialog
composeTestRule
.onNodeWithContentDescription(label = "Default (System). Language")
Expand All @@ -80,17 +68,6 @@ class AppearanceScreenTest : BaseComposeTest() {
.filterToOne(hasAnyAncestor(isDialog()))
.assertIsNotDisplayed()

// Should show confirmation dialog
composeTestRule
.onAllNodesWithText("Ok")
.filterToOne(hasAnyAncestor(isDialog()))
.assertIsDisplayed()
// Clicking "Ok" should dismiss confirmation dialog
composeTestRule.onAllNodesWithText("Ok")
.filterToOne(hasAnyAncestor(isDialog()))
.performClick()
composeTestRule.assertNoDialogExists()

verify {
viewModel.trySendAction(
AppearanceAction.LanguageChange(
Expand All @@ -100,19 +77,6 @@ class AppearanceScreenTest : BaseComposeTest() {
}
}

@Test
fun `on language selection dialog cancel click should dismiss dialog`() {
composeTestRule
.onNodeWithContentDescription(label = "Default (System). Language")
.performScrollTo()
.performClick()
composeTestRule
.onAllNodesWithText("Cancel")
.filterToOne(hasAnyAncestor(isDialog()))
.performClick()
composeTestRule.assertNoDialogExists()
}

@Test
fun `on theme row click should display theme selection dialog`() {
composeTestRule.onRoot().printToLog("Brian")
Expand Down

0 comments on commit 50d4a93

Please sign in to comment.