Ensure FAB is hidden for some Vault Screen states (#401)

This commit is contained in:
Brian Yencho
2023-12-15 12:14:01 -06:00
committed by Álison Fernandes
parent 1b7e01ea89
commit 5235310de5
3 changed files with 38 additions and 5 deletions

View File

@@ -265,7 +265,7 @@ private fun VaultScreenScaffold(
},
floatingActionButton = {
AnimatedVisibility(
visible = !accountMenuVisible,
visible = state.viewState.hasFab && !accountMenuVisible,
enter = scaleIn(),
exit = scaleOut(),
) {

View File

@@ -304,17 +304,27 @@ data class VaultState(
@Parcelize
sealed class ViewState : Parcelable {
/**
* Determines whether or not the Floating Action Button (FAB) should be shown for the
* given state.
*/
abstract val hasFab: Boolean
/**
* Loading state for the [VaultScreen], signifying that the content is being processed.
*/
@Parcelize
data object Loading : ViewState()
data object Loading : ViewState() {
override val hasFab: Boolean get() = false
}
/**
* Represents a state where the [VaultScreen] has no items to display.
*/
@Parcelize
data object NoItems : ViewState()
data object NoItems : ViewState() {
override val hasFab: Boolean get() = true
}
/**
* Represents a state where the [VaultScreen] is unable to display data due to an error
@@ -323,7 +333,9 @@ data class VaultState(
@Parcelize
data class Error(
val message: Text,
) : ViewState()
) : ViewState() {
override val hasFab: Boolean get() = false
}
/**
* Content state for the [VaultScreen] showing the actual content or items.
@@ -349,7 +361,9 @@ data class VaultState(
val noFolderItems: List<VaultItem>,
val collectionItems: List<CollectionItem>,
val trashItemsCount: Int,
) : ViewState()
) : ViewState() {
override val hasFab: Boolean get() = true
}
/**
* Represents a folder item with a name and item count.