mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 17:05:44 +03:00
PM-14352 Dismiss Snackbar when user clicks it as a default unless the specific dismiss action is present. (#4291)
This commit is contained in:
parent
c6beaec102
commit
9a5aa217e6
3 changed files with 35 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.x8bit.bitwarden.ui.platform.components.snackbar
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
|
@ -28,6 +29,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
|||
* Custom snackbar for Bitwarden.
|
||||
* Shows a message with an optional actions and title.
|
||||
*/
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
fun BitwardenSnackbar(
|
||||
bitwardenSnackbarData: BitwardenSnackbarData,
|
||||
|
@ -45,6 +47,12 @@ fun BitwardenSnackbar(
|
|||
color = BitwardenTheme.colorScheme.background.alert,
|
||||
shape = BitwardenTheme.shapes.snackbar,
|
||||
)
|
||||
// I there is no explicit dismiss action, the Snackbar can be dismissed by clicking
|
||||
// anywhere on the Snackbar.
|
||||
.clickable(
|
||||
enabled = !bitwardenSnackbarData.withDismissAction,
|
||||
onClick = onDismiss,
|
||||
)
|
||||
.padding(16.dp),
|
||||
) {
|
||||
Column {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.x8bit.bitwarden.ui.platform.feature.settings.vault
|
|||
|
||||
import androidx.compose.ui.test.assert
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.assertIsNotDisplayed
|
||||
import androidx.compose.ui.test.hasAnyAncestor
|
||||
import androidx.compose.ui.test.isDialog
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
|
@ -227,4 +228,17 @@ class VaultSettingsScreenTest : BaseComposeTest() {
|
|||
mutableEventFlow.tryEmit(VaultSettingsEvent.ShowSnackbar(data))
|
||||
composeTestRule.onNodeWithText("message").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when snackbar is displayed clicking on it should dismiss`() {
|
||||
val data = BitwardenSnackbarData("message".asText())
|
||||
mutableEventFlow.tryEmit(VaultSettingsEvent.ShowSnackbar(data))
|
||||
composeTestRule
|
||||
.onNodeWithText("message")
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
composeTestRule
|
||||
.onNodeWithText("message")
|
||||
.assertIsNotDisplayed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1206,6 +1206,19 @@ class VaultScreenTest : BaseComposeTest() {
|
|||
composeTestRule.onNodeWithText("message").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when snackbar is displayed clicking on it should dismiss`() {
|
||||
val data = BitwardenSnackbarData("message".asText())
|
||||
mutableEventFlow.tryEmit(VaultEvent.ShowSnackbar(data))
|
||||
composeTestRule
|
||||
.onNodeWithText("message")
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
composeTestRule
|
||||
.onNodeWithText("message")
|
||||
.assertIsNotDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `SSH key group header should display correctly based on state`() {
|
||||
val count = 1
|
||||
|
|
Loading…
Reference in a new issue