BIT-748: Settings about, rate app (#765)

This commit is contained in:
Joshua Queen
2024-01-24 21:24:24 -05:00
committed by GitHub
parent aa4b7e7d03
commit f6494ccfbc
4 changed files with 20 additions and 11 deletions

View File

@@ -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(),
)
}
}
}

View File

@@ -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()
}
/**

View File

@@ -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`() {

View File

@@ -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())
}
}