mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
Add reusable radio button (#3973)
This commit is contained in:
parent
9213b4843f
commit
21e1d8b5bc
2 changed files with 30 additions and 3 deletions
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.RadioButton
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
@ -14,6 +13,7 @@ import androidx.compose.ui.semantics.selected
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.Text
|
import com.x8bit.bitwarden.ui.platform.base.util.Text
|
||||||
|
import com.x8bit.bitwarden.ui.platform.components.radio.BitwardenRadioButton
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A clickable item that displays a radio button and text.
|
* A clickable item that displays a radio button and text.
|
||||||
|
@ -38,9 +38,9 @@ fun BitwardenSelectionRow(
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
RadioButton(
|
BitwardenRadioButton(
|
||||||
modifier = Modifier.padding(16.dp),
|
modifier = Modifier.padding(16.dp),
|
||||||
selected = isSelected,
|
isSelected = isSelected,
|
||||||
onClick = null,
|
onClick = null,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.x8bit.bitwarden.ui.platform.components.radio
|
||||||
|
|
||||||
|
import androidx.compose.material3.RadioButton
|
||||||
|
import androidx.compose.material3.RadioButtonDefaults
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom Bitwarden-themed radio button.
|
||||||
|
*
|
||||||
|
* @param isSelected Whether this radio button is selected or not.
|
||||||
|
* @param onClick The lambda to be invoked when the item is clicked.
|
||||||
|
* @param modifier The [Modifier] to be applied to this radio button.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun BitwardenRadioButton(
|
||||||
|
isSelected: Boolean,
|
||||||
|
onClick: (() -> Unit)?,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
|
modifier = modifier,
|
||||||
|
selected = isSelected,
|
||||||
|
onClick = onClick,
|
||||||
|
colors = RadioButtonDefaults.colors(),
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue