mirror of
https://github.com/bitwarden/android.git
synced 2026-05-10 16:45:43 -05:00
BIT-748: Settings about, rate app (#765)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.x8bit.bitwarden.ui.platform.feature.settings.about
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -81,8 +80,11 @@ fun AboutScreen(
|
||||
intentManager.launchUri("https://vault.bitwarden.com".toUri())
|
||||
}
|
||||
|
||||
is AboutEvent.ShowToast -> {
|
||||
Toast.makeText(context, event.text(resources), Toast.LENGTH_SHORT).show()
|
||||
AboutEvent.NavigateToRateApp -> {
|
||||
intentManager.launchUri(
|
||||
uri =
|
||||
"https://play.google.com/store/apps/details?id=com.x8bit.bitwarden".toUri(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ class AboutViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun handleRateAppClick() {
|
||||
// TODO: BIT-748 Launch the rate your app UI.
|
||||
sendEvent(AboutEvent.ShowToast(text = "Navigate to rate the app.".asText()))
|
||||
sendEvent(AboutEvent.NavigateToRateApp)
|
||||
}
|
||||
|
||||
private fun handleSubmitCrashLogsClick(action: AboutAction.SubmitCrashLogsClick) {
|
||||
@@ -120,11 +119,9 @@ sealed class AboutEvent {
|
||||
data object NavigateToWebVault : AboutEvent()
|
||||
|
||||
/**
|
||||
* Displays a toast with the given [Text].
|
||||
* Navigates to rate the app.
|
||||
*/
|
||||
data class ShowToast(
|
||||
val text: Text,
|
||||
) : AboutEvent()
|
||||
data object NavigateToRateApp : AboutEvent()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,6 +142,16 @@ class AboutScreenTest : BaseComposeTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on NavigateToAboutSend should call launchUri on intentManager`() {
|
||||
mutableEventFlow.tryEmit(AboutEvent.NavigateToRateApp)
|
||||
verify {
|
||||
intentManager.launchUri(
|
||||
"https://play.google.com/store/apps/details?id=com.x8bit.bitwarden".toUri(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on rate the app click should display confirmation dialog and confirm click should emit RateAppClick`() {
|
||||
|
||||
@@ -49,11 +49,11 @@ class AboutViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on RateAppClick should emit ShowToast`() = runTest {
|
||||
fun `on RateAppClick should emit NavigateToRateApp`() = runTest {
|
||||
val viewModel = createViewModel(DEFAULT_ABOUT_STATE)
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(AboutAction.RateAppClick)
|
||||
assertEquals(AboutEvent.ShowToast("Navigate to rate the app.".asText()), awaitItem())
|
||||
assertEquals(AboutEvent.NavigateToRateApp, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user