BIT-1151: Enforce maximum account limit in account switcher (#310)

This commit is contained in:
Brian Yencho 2023-12-04 10:26:28 -06:00 committed by Álison Fernandes
parent bd2cd54d47
commit d3a813b647

View file

@ -44,6 +44,12 @@ import com.x8bit.bitwarden.ui.vault.feature.vault.util.initials
import com.x8bit.bitwarden.ui.vault.feature.vault.util.supportingTextResOrNull import com.x8bit.bitwarden.ui.vault.feature.vault.util.supportingTextResOrNull
import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableList
/**
* The maximum number of accounts before the "Add account" button will be hidden to prevent the user
* from adding any more.
*/
private const val MAXIMUM_ACCOUNT_LIMIT = 5
/** /**
* An account switcher that will slide down inside whatever parent is it placed in and add a * An account switcher that will slide down inside whatever parent is it placed in and add a
* a scrim via a [BitwardenAnimatedScrim] to all content below it (but not above it). Additional * a scrim via a [BitwardenAnimatedScrim] to all content below it (but not above it). Additional
@ -148,13 +154,15 @@ private fun AnimatedAccountSwitcher(
color = MaterialTheme.colorScheme.outlineVariant, color = MaterialTheme.colorScheme.outlineVariant,
) )
} }
item { if (accountSummaries.size < MAXIMUM_ACCOUNT_LIMIT) {
AddAccountItem( item {
onClick = onAddAccountClick, AddAccountItem(
modifier = Modifier onClick = onAddAccountClick,
.fillMaxWidth() modifier = Modifier
.padding(horizontal = 16.dp), .fillMaxWidth()
) .padding(horizontal = 16.dp),
)
}
} }
} }
} }