Skip to content

Commit

Permalink
BIT-2207: Move Give Feedback form to About screen (#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-livefront authored and vvolkgang committed Jun 20, 2024
1 parent b7536b2 commit 365e3d2
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ fun AboutScreen(

AboutEvent.NavigateBack -> onNavigateBack.invoke()

AboutEvent.NavigateToFeedbackForm -> {
intentManager.launchUri("https://livefrontinc.typeform.com/to/irgrRu4a".toUri())
}

AboutEvent.NavigateToHelpCenter -> {
intentManager.launchUri("https://bitwarden.com/help".toUri())
}
Expand Down Expand Up @@ -126,6 +130,9 @@ fun AboutScreen(
onRateTheAppClick = remember(viewModel) {
{ viewModel.trySendAction(AboutAction.RateAppClick) }
},
onGiveFeedbackClick = remember(viewModel) {
{ viewModel.trySendAction(AboutAction.GiveFeedbackClick) }
},
onSubmitCrashLogsCheckedChange = remember(viewModel) {
{ viewModel.trySendAction(AboutAction.SubmitCrashLogsClick(it)) }
},
Expand All @@ -147,6 +154,7 @@ private fun ContentColumn(
onPrivacyPolicyClick: () -> Unit,
onLearnAboutOrgsClick: () -> Unit,
onRateTheAppClick: () -> Unit,
onGiveFeedbackClick: () -> Unit,
onSubmitCrashLogsCheckedChange: (Boolean) -> Unit,
onVersionClick: () -> Unit,
onWebVaultClick: () -> Unit,
Expand Down Expand Up @@ -208,6 +216,12 @@ private fun ContentColumn(
dialogTitle = stringResource(id = R.string.continue_to_app_store),
dialogMessage = stringResource(id = R.string.rate_app_description_long),
)
BitwardenExternalLinkRow(
text = stringResource(R.string.give_feedback),
onConfirmClick = onGiveFeedbackClick,
dialogTitle = stringResource(R.string.continue_to_give_feedback),
dialogMessage = stringResource(R.string.continue_to_provide_feedback),
)
CopyRow(
text = state.version,
onClick = onVersionClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AboutViewModel @Inject constructor(

override fun handleAction(action: AboutAction): Unit = when (action) {
AboutAction.BackClick -> handleBackClick()
AboutAction.GiveFeedbackClick -> handleGiveFeedbackClick()
AboutAction.HelpCenterClick -> handleHelpCenterClick()
AboutAction.PrivacyPolicyClick -> handlePrivacyPolicyClick()
AboutAction.LearnAboutOrganizationsClick -> handleLearnAboutOrganizationsClick()
Expand All @@ -66,6 +67,10 @@ class AboutViewModel @Inject constructor(
sendEvent(AboutEvent.NavigateToHelpCenter)
}

private fun handleGiveFeedbackClick() {
sendEvent(AboutEvent.NavigateToFeedbackForm)
}

private fun handlePrivacyPolicyClick() {
sendEvent(AboutEvent.NavigateToPrivacyPolicy)
}
Expand Down Expand Up @@ -139,6 +144,11 @@ sealed class AboutEvent {
*/
data object NavigateBack : AboutEvent()

/**
* Navigate to the feedback form.
*/
data object NavigateToFeedbackForm : AboutEvent()

/**
* Navigates to the help center.
*/
Expand Down Expand Up @@ -174,6 +184,11 @@ sealed class AboutAction {
*/
data object BackClick : AboutAction()

/**
* User clicked the give feedback row.
*/
data object GiveFeedbackClick : AboutAction()

/**
* User clicked the helper center row.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.hilt.navigation.compose.hiltViewModel
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.platform.repository.model.ClearClipboardFrequency
Expand All @@ -42,7 +41,6 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenSelectionDialo
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.row.BitwardenSelectionRow
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenExternalLinkRow
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
Expand All @@ -64,9 +62,6 @@ fun OtherScreen(
EventsEffect(viewModel = viewModel) { event ->
when (event) {
OtherEvent.NavigateBack -> onNavigateBack.invoke()
OtherEvent.NavigateToFeedbackForm -> {
intentManager.launchUri("https://livefrontinc.typeform.com/to/irgrRu4a".toUri())
}
}
}

Expand Down Expand Up @@ -166,16 +161,6 @@ fun OtherScreen(
.semantics { testTag = "AllowScreenCaptureSwitch" }
.padding(horizontal = 16.dp),
)

BitwardenExternalLinkRow(
text = stringResource(R.string.give_feedback),
onConfirmClick = remember(viewModel) {
{ viewModel.trySendAction(OtherAction.GiveFeedbackClick) }
},
dialogTitle = stringResource(R.string.continue_to_give_feedback),
dialogMessage = stringResource(R.string.continue_to_provide_feedback),
withDivider = false,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class OtherViewModel @Inject constructor(
is OtherAction.AllowSyncToggle -> handleAllowSyncToggled(action)
OtherAction.BackClick -> handleBackClicked()
is OtherAction.ClearClipboardFrequencyChange -> handleClearClipboardFrequencyChanged(action)
OtherAction.GiveFeedbackClick -> handleGiveFeedbackClicked()
OtherAction.SyncNowButtonClick -> handleSyncNowButtonClicked()
is OtherAction.Internal -> handleInternalAction(action)
}
Expand Down Expand Up @@ -88,10 +87,6 @@ class OtherViewModel @Inject constructor(
settingsRepo.clearClipboardFrequency = action.clearClipboardFrequency
}

private fun handleGiveFeedbackClicked() {
sendEvent(OtherEvent.NavigateToFeedbackForm)
}

private fun handleSyncNowButtonClicked() {
mutableStateFlow.update {
it.copy(dialogState = OtherState.DialogState.Loading(R.string.syncing.asText()))
Expand Down Expand Up @@ -151,11 +146,6 @@ sealed class OtherEvent {
* Navigate back.
*/
data object NavigateBack : OtherEvent()

/**
* Navigate to the feedback form.
*/
data object NavigateToFeedbackForm : OtherEvent()
}

/**
Expand Down Expand Up @@ -188,11 +178,6 @@ sealed class OtherAction {
val clearClipboardFrequency: ClearClipboardFrequency,
) : OtherAction()

/**
* Indicates that the user clicked the Give feedback button.
*/
data object GiveFeedbackClick : OtherAction()

/**
* Indicates that the user clicked the Sync Now button.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ class AboutScreenTest : BaseComposeTest() {
verify { viewModel.trySendAction(AboutAction.BackClick) }
}

@Suppress("MaxLineLength")
@Test
fun `on give feedback click should display confirmation dialog and confirm click should emit GiveFeedbackClick`() {
composeTestRule.onNode(isDialog()).assertDoesNotExist()
composeTestRule.onNodeWithText("Give Feedback").performScrollTo().performClick()
composeTestRule.onNode(isDialog()).assertExists()
composeTestRule
.onAllNodesWithText("Continue")
.filterToOne(hasAnyAncestor(isDialog()))
.performClick()
composeTestRule.onNode(isDialog()).assertDoesNotExist()
verify {
viewModel.trySendAction(AboutAction.GiveFeedbackClick)
}
}

@Suppress("MaxLineLength")
@Test
fun `on bitwarden help center click should display confirmation dialog and confirm click should emit HelpCenterClick`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ class AboutViewModelTest : BaseViewModelTest() {
}
}

@Test
fun `on GiveFeedbackClick should emit NavigateToFeedbackForm`() = runTest {
val viewModel = createViewModel()
viewModel.eventFlow.test {
viewModel.trySendAction(AboutAction.GiveFeedbackClick)
assertEquals(AboutEvent.NavigateToFeedbackForm, awaitItem())
}
}

@Test
fun `on HelpCenterClick should emit NavigateToHelpCenter`() = runTest {
val viewModel = createViewModel(DEFAULT_ABOUT_STATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ class OtherScreenTest : BaseComposeTest() {
.assertIsDisplayed()
.assert(hasAnyAncestor(isDialog()))
}

@Suppress("MaxLineLength")
@Test
fun `on give feedback click should display confirmation dialog and confirm click should emit GiveFeedbackClick`() {
composeTestRule.onNode(isDialog()).assertDoesNotExist()
composeTestRule.onNodeWithText("Give Feedback").performClick()
composeTestRule.onNode(isDialog()).assertExists()
composeTestRule
.onAllNodesWithText("Continue")
.filterToOne(hasAnyAncestor(isDialog()))
.performClick()
composeTestRule.onNode(isDialog()).assertDoesNotExist()
verify {
viewModel.trySendAction(OtherAction.GiveFeedbackClick)
}
}
}

private val DEFAULT_STATE = OtherState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ class OtherViewModelTest : BaseViewModelTest() {
}
}

@Test
fun `on GiveFeedbackClick should emit NavigateToFeedbackForm`() = runTest {
val viewModel = createViewModel()
viewModel.eventFlow.test {
viewModel.trySendAction(OtherAction.GiveFeedbackClick)
assertEquals(OtherEvent.NavigateToFeedbackForm, awaitItem())
}
}

@Test
fun `on ClearClipboardFrequencyChange should update state`() = runTest {
val viewModel = createViewModel()
Expand Down

0 comments on commit 365e3d2

Please sign in to comment.