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 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
* a scrim via a [BitwardenAnimatedScrim] to all content below it (but not above it). Additional
@ -148,6 +154,7 @@ private fun AnimatedAccountSwitcher(
color = MaterialTheme.colorScheme.outlineVariant,
)
}
if (accountSummaries.size < MAXIMUM_ACCOUNT_LIMIT) {
item {
AddAccountItem(
onClick = onAddAccountClick,
@ -158,6 +165,7 @@ private fun AnimatedAccountSwitcher(
}
}
}
}
}
@Composable