Skip to content

Commit

Permalink
feat: show Guest label for personal users after migration in conversa…
Browse files Browse the repository at this point in the history
…tions screen - cherrypick (WPB-14871) 🍒 (#3783)

Co-authored-by: Oussama Hassine <[email protected]>
  • Loading branch information
github-actions[bot] and ohassine authored Jan 6, 2025
1 parent 73cf82e commit 4883d0e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.wire.kalium.logic.feature.user.migration.MigrateFromPersonalToTeamFai
data class TeamMigrationState(
val teamNameTextState: TextFieldState = TextFieldState(),
val shouldShowMigrationLeaveDialog: Boolean = false,
val isMigrating: Boolean = false,
val currentStep: Int = 0,
val username: String = "",
val teamUrl: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class TeamMigrationViewModel @Inject constructor(
)
}

fun setIsMigratingState(isMigrating: Boolean) {
teamMigrationState = teamMigrationState.copy(isMigrating = isMigrating)
}

fun migrateFromPersonalToTeamAccount(onSuccess: () -> Unit) {
viewModelScope.launch {
migrateFromPersonalToTeam.invoke(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import com.wire.android.ui.theme.WireTheme
fun BottomLineButtons(
isContinueButtonEnabled: Boolean,
modifier: Modifier = Modifier,
isMigrating: Boolean = false,
isBackButtonVisible: Boolean = true,
backButtonContentDescription: String = stringResource(R.string.personal_to_team_migration_back_button_label),
onBack: () -> Unit = { },
Expand All @@ -67,7 +68,12 @@ fun BottomLineButtons(
.fillMaxWidth()
.semantics(true) { contentDescription = backButtonContentDescription },
text = stringResource(R.string.personal_to_team_migration_back_button_label),
onClick = onBack
onClick = onBack,
state = if (isMigrating) {
WireButtonState.Disabled
} else {
WireButtonState.Default
}
)
}

Expand All @@ -77,7 +83,8 @@ fun BottomLineButtons(
.padding(top = dimensions().spacing6x),
text = stringResource(R.string.label_continue),
onClick = onContinue,
state = if (isContinueButtonEnabled) {
loading = isMigrating,
state = if (isContinueButtonEnabled && !isMigrating) {
WireButtonState.Default
} else {
WireButtonState.Disabled
Expand All @@ -91,6 +98,7 @@ fun BottomLineButtons(
private fun BottomLineButtonsPreview() {
WireTheme {
BottomLineButtons(
isMigrating = false,
isContinueButtonEnabled = true
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ fun TeamMigrationConfirmationStepScreen(
val state = teamMigrationViewModel.teamMigrationState

TeamMigrationConfirmationStepScreenContent(
isMigrating = state.isMigrating,
onContinueButtonClicked = {
teamMigrationViewModel.setIsMigratingState(true)
teamMigrationViewModel.migrateFromPersonalToTeamAccount(
onSuccess = {
teamMigrationViewModel.setIsMigratingState(false)
navigator.navigate(TeamMigrationDoneStepScreenDestination)
},
}
)
},
onBackPressed = {
Expand Down Expand Up @@ -179,6 +182,7 @@ private fun ErrorDialog(
@Composable
private fun TeamMigrationConfirmationStepScreenContent(
modifier: Modifier = Modifier,
isMigrating: Boolean = false,
onContinueButtonClicked: () -> Unit = { },
onBackPressed: () -> Unit = { }
) {
Expand Down Expand Up @@ -254,6 +258,7 @@ private fun TeamMigrationConfirmationStepScreenContent(
}
val isContinueButtonEnabled = agreedToMigrationTerms.value && acceptedWireTermsOfUse.value
BottomLineButtons(
isMigrating = isMigrating,
isContinueButtonEnabled = isContinueButtonEnabled,
onContinue = onContinueButtonClicked,
backButtonContentDescription = stringResource(R.string.personal_to_team_migration_back_button_confirmation_content_description),
Expand Down

0 comments on commit 4883d0e

Please sign in to comment.