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.
BIT-544: Apply reskin to LandingScreen (#71)
- Loading branch information
1 parent
a1096d2
commit a223e2f
Showing
7 changed files
with
324 additions
and
70 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
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenFilledButton.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,62 @@ | ||
package com.x8bit.bitwarden.ui.platform.components | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
/** | ||
* Represents a Bitwarden-styled filled [Button]. | ||
* | ||
* @param label The label for the button. | ||
* @param onClick The callback when the button is clicked. | ||
* @param modifier The [Modifier] to be applied to the button. | ||
* @param isEnabled Whether or not the button is enabled. | ||
*/ | ||
@Composable | ||
fun BitwardenFilledButton( | ||
label: String, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
isEnabled: Boolean = true, | ||
) { | ||
Button( | ||
onClick = onClick, | ||
modifier = modifier, | ||
enabled = isEnabled, | ||
) { | ||
Text( | ||
text = label, | ||
color = MaterialTheme.colorScheme.onPrimary, | ||
style = MaterialTheme.typography.bodyMedium, | ||
modifier = Modifier.padding( | ||
vertical = 10.dp, | ||
horizontal = 24.dp, | ||
), | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun BitwardenFilledButton_preview_isEnabled() { | ||
BitwardenFilledButton( | ||
label = "Label", | ||
onClick = {}, | ||
isEnabled = true, | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun BitwardenFilledButton_preview_isNotEnabled() { | ||
BitwardenFilledButton( | ||
label = "Label", | ||
onClick = {}, | ||
isEnabled = false, | ||
) | ||
} |
76 changes: 76 additions & 0 deletions
76
app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenSwitch.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,76 @@ | ||
package com.x8bit.bitwarden.ui.platform.components | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.layout.wrapContentHeight | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Switch | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
/** | ||
* Represents a Bitwarden-styled [Switch]. | ||
* | ||
* @param label The label for the switch. | ||
* @param isChecked Whether or not the switch is currently checked. | ||
* @param onCheckedChange A callback for when the checked state changes. | ||
* @param modifier The [Modifier] to be applied to the button. | ||
*/ | ||
@Composable | ||
fun BitwardenSwitch( | ||
label: String, | ||
isChecked: Boolean, | ||
onCheckedChange: ((Boolean) -> Unit)?, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Row( | ||
horizontalArrangement = Arrangement.Start, | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = modifier | ||
.semantics(mergeDescendants = true) { } | ||
.wrapContentHeight(), | ||
) { | ||
Switch( | ||
modifier = Modifier | ||
.height(32.dp) | ||
.width(52.dp), | ||
checked = isChecked, | ||
onCheckedChange = onCheckedChange, | ||
) | ||
|
||
Text( | ||
text = label, | ||
style = MaterialTheme.typography.bodyLarge, | ||
color = MaterialTheme.colorScheme.onSurface, | ||
modifier = Modifier.padding(start = 16.dp), | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun BitwardenSwitch_preview_isChecked() { | ||
BitwardenSwitch( | ||
label = "Label", | ||
isChecked = true, | ||
onCheckedChange = {}, | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun BitwardenSwitch_preview_isNotChecked() { | ||
BitwardenSwitch( | ||
label = "Label", | ||
isChecked = false, | ||
onCheckedChange = {}, | ||
) | ||
} |
Oops, something went wrong.