generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow modification of appearance settings
- Loading branch information
1 parent
6146e1d
commit 7fc1991
Showing
11 changed files
with
771 additions
and
92 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
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
90 changes: 90 additions & 0 deletions
90
...n/kotlin/com/x8bit/bitwarden/authenticator/ui/platform/components/row/BitwardenTextRow.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,90 @@ | ||
package com.x8bit.bitwarden.authenticator.ui.platform.components.row | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.defaultMinSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.ripple.rememberRipple | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.unit.dp | ||
|
||
/** | ||
* Represents a clickable row of text and can contains an optional [content] that appears to the | ||
* right of the [text]. | ||
* | ||
* @param text The label for the row as a [String]. | ||
* @param onClick The callback when the row is clicked. | ||
* @param modifier The modifier to be applied to the layout. | ||
* @param description An optional description label to be displayed below the [text]. | ||
* @param withDivider Indicates if a divider should be drawn on the bottom of the row, defaults | ||
* to `false`. | ||
* @param content The content of the [BitwardenTextRow]. | ||
*/ | ||
@Composable | ||
fun BitwardenTextRow( | ||
text: String, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
description: String? = null, | ||
withDivider: Boolean = false, | ||
content: (@Composable () -> Unit)? = null, | ||
) { | ||
Box( | ||
contentAlignment = Alignment.BottomCenter, | ||
modifier = modifier | ||
.clickable( | ||
interactionSource = remember { MutableInteractionSource() }, | ||
indication = rememberRipple(color = MaterialTheme.colorScheme.primary), | ||
onClick = onClick, | ||
) | ||
.semantics(mergeDescendants = true) { }, | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.defaultMinSize(minHeight = 56.dp) | ||
.padding(start = 16.dp, end = 24.dp, top = 8.dp, bottom = 8.dp) | ||
.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.padding(end = 16.dp) | ||
.weight(1f), | ||
) { | ||
Text( | ||
text = text, | ||
style = MaterialTheme.typography.bodyLarge, | ||
color = MaterialTheme.colorScheme.onSurface, | ||
) | ||
description?.let { | ||
Text( | ||
text = it, | ||
style = MaterialTheme.typography.bodyMedium, | ||
color = MaterialTheme.colorScheme.onSurfaceVariant, | ||
) | ||
} | ||
} | ||
content?.invoke() | ||
} | ||
if (withDivider) { | ||
HorizontalDivider( | ||
modifier = Modifier.padding(start = 16.dp), | ||
thickness = 1.dp, | ||
color = MaterialTheme.colorScheme.outlineVariant, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.