mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
Add enum for better control of TopAppBar divider (#4073)
This commit is contained in:
parent
ba8e3a6c51
commit
cdb03f5649
3 changed files with 30 additions and 7 deletions
|
@ -17,6 +17,7 @@ import com.x8bit.bitwarden.ui.platform.base.util.bottomDivider
|
|||
import com.x8bit.bitwarden.ui.platform.base.util.scrolledContainerBottomDivider
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.color.bitwardenTopAppBarColors
|
||||
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
|
||||
import com.x8bit.bitwarden.ui.platform.components.model.TopAppBarDividerStyle
|
||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||
|
||||
/**
|
||||
|
@ -30,8 +31,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
|||
* @param title The text to be displayed as the title of the app bar.
|
||||
* @param scrollBehavior Defines the scrolling behavior of the app bar. It controls how the app bar
|
||||
* behaves in conjunction with scrolling content.
|
||||
* @param isBottomDividerEnabled Determines if the bottom divider should be displayed on scroll or
|
||||
* not.
|
||||
* @param dividerStyle Determines how the bottom divider should be displayed.
|
||||
* @param actions A lambda containing the set of actions (usually icons or similar) to display
|
||||
* in the app bar's trailing side. This lambda extends [RowScope], allowing flexibility in
|
||||
* defining the layout of the actions.
|
||||
|
@ -42,7 +42,7 @@ fun BitwardenMediumTopAppBar(
|
|||
title: String,
|
||||
scrollBehavior: TopAppBarScrollBehavior,
|
||||
modifier: Modifier = Modifier,
|
||||
isBottomDividerEnabled: Boolean = true,
|
||||
dividerStyle: TopAppBarDividerStyle = TopAppBarDividerStyle.ON_SCROLL,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
) {
|
||||
MediumTopAppBar(
|
||||
|
@ -59,11 +59,18 @@ fun BitwardenMediumTopAppBar(
|
|||
.testTag(tag = "HeaderBarComponent")
|
||||
.scrolledContainerBottomDivider(
|
||||
topAppBarScrollBehavior = scrollBehavior,
|
||||
enabled = isBottomDividerEnabled,
|
||||
enabled = when (dividerStyle) {
|
||||
TopAppBarDividerStyle.NONE -> false
|
||||
TopAppBarDividerStyle.STATIC -> false
|
||||
TopAppBarDividerStyle.ON_SCROLL -> true
|
||||
},
|
||||
)
|
||||
// When the scrolling divider is disabled, we show the static divider
|
||||
.bottomDivider(
|
||||
enabled = !isBottomDividerEnabled,
|
||||
enabled = when (dividerStyle) {
|
||||
TopAppBarDividerStyle.NONE -> false
|
||||
TopAppBarDividerStyle.STATIC -> true
|
||||
TopAppBarDividerStyle.ON_SCROLL -> false
|
||||
},
|
||||
thickness = (0.5).dp,
|
||||
),
|
||||
actions = actions,
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package com.x8bit.bitwarden.ui.platform.components.model
|
||||
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
|
||||
|
||||
/**
|
||||
* Defines the possible display options for a bottom divider on a [BitwardenMediumTopAppBar].
|
||||
*/
|
||||
enum class TopAppBarDividerStyle {
|
||||
NONE,
|
||||
STATIC,
|
||||
ON_SCROLL,
|
||||
}
|
|
@ -51,6 +51,7 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenMasterPassword
|
|||
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.fab.BitwardenFloatingActionButton
|
||||
import com.x8bit.bitwarden.ui.platform.components.model.TopAppBarDividerStyle
|
||||
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenPullToRefreshState
|
||||
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
|
||||
import com.x8bit.bitwarden.ui.platform.components.scaffold.rememberBitwardenPullToRefreshState
|
||||
|
@ -222,7 +223,10 @@ private fun VaultScreenScaffold(
|
|||
BitwardenMediumTopAppBar(
|
||||
title = state.appBarTitle(),
|
||||
scrollBehavior = scrollBehavior,
|
||||
isBottomDividerEnabled = state.vaultFilterDataWithFilter == null,
|
||||
dividerStyle = state
|
||||
.vaultFilterDataWithFilter
|
||||
?.let { TopAppBarDividerStyle.STATIC }
|
||||
?: TopAppBarDividerStyle.ON_SCROLL,
|
||||
actions = {
|
||||
BitwardenAccountActionItem(
|
||||
initials = state.initials,
|
||||
|
|
Loading…
Reference in a new issue