-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-11187 show import success bottom sheet after success import sync (#…
- Loading branch information
1 parent
6f535c0
commit 1c10a94
Showing
21 changed files
with
701 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../java/com/x8bit/bitwarden/ui/platform/components/bottomsheet/BitwardenModalBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.x8bit.bitwarden.ui.platform.components.bottomsheet | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.ModalBottomSheet | ||
import androidx.compose.material3.SheetState | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.rememberModalBottomSheetState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.x8bit.bitwarden.R | ||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar | ||
import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon | ||
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold | ||
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter | ||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme | ||
|
||
/** | ||
* A reusable modal bottom sheet that applies provides a bottom sheet layout with the | ||
* standard [BitwardenScaffold] and [BitwardenTopAppBar] and expected scrolling behavior with | ||
* passed in [sheetContent] | ||
* | ||
* @param sheetTitle The title to display in the [BitwardenTopAppBar] | ||
* @param onDismiss The action to perform when the bottom sheet is dismissed will also be performed | ||
* when the "close" icon is clicked, caller must handle any desired animation or hiding of the | ||
* bottom sheet. | ||
* @param showBottomSheet Whether or not to show the bottom sheet, by default this is true assuming | ||
* the showing/hiding will be handled by the caller. | ||
* @param sheetContent Content to display in the bottom sheet. The content is passed the padding | ||
* from the containing [BitwardenScaffold]. | ||
*/ | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun BitwardenModalBottomSheet( | ||
sheetTitle: String, | ||
onDismiss: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
showBottomSheet: Boolean = true, | ||
sheetState: SheetState = rememberModalBottomSheetState(), | ||
sheetContent: @Composable (PaddingValues) -> Unit, | ||
) { | ||
if (!showBottomSheet) return | ||
ModalBottomSheet( | ||
onDismissRequest = onDismiss, | ||
modifier = modifier, | ||
dragHandle = null, | ||
sheetState = sheetState, | ||
contentWindowInsets = { | ||
WindowInsets(left = 0, top = 0, right = 0, bottom = 0) | ||
}, | ||
shape = BitwardenTheme.shapes.bottomSheet, | ||
) { | ||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() | ||
BitwardenScaffold( | ||
topBar = { | ||
BitwardenTopAppBar( | ||
title = sheetTitle, | ||
navigationIcon = NavigationIcon( | ||
navigationIcon = rememberVectorPainter(R.drawable.ic_close), | ||
onNavigationIconClick = onDismiss, | ||
navigationIconContentDescription = stringResource(R.string.close), | ||
), | ||
scrollBehavior = scrollBehavior, | ||
minimunHeight = 64.dp, | ||
) | ||
}, | ||
modifier = Modifier | ||
.nestedScroll(scrollBehavior.nestedScrollConnection) | ||
.fillMaxSize(), | ||
) { paddingValues -> | ||
sheetContent(paddingValues) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/x8bit/bitwarden/ui/platform/components/model/ContentBlockData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.x8bit.bitwarden.ui.platform.components.model | ||
|
||
import androidx.annotation.DrawableRes | ||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.ui.text.AnnotatedString | ||
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenContentBlock | ||
|
||
/** | ||
* Wrapper class for data to display in a | ||
* [BitwardenContentBlock] | ||
*/ | ||
@Immutable | ||
data class ContentBlockData( | ||
val headerText: AnnotatedString, | ||
val subtitleText: String? = null, | ||
@DrawableRes val iconVectorResource: Int? = null, | ||
) { | ||
/** | ||
* Overloaded constructor for [ContentBlockData] that takes a [String] for the | ||
* header text. | ||
*/ | ||
constructor( | ||
headerText: String, | ||
subtitleText: String? = null, | ||
@DrawableRes iconVectorResource: Int? = null, | ||
) : this( | ||
headerText = AnnotatedString(headerText), | ||
subtitleText = subtitleText, | ||
iconVectorResource = iconVectorResource, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.