Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package app.plugbrain.android.ui.designsystem.components.button

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand All @@ -20,14 +22,21 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.plugbrain.android.R
import app.plugbrain.android.ui.theme.MathlockAppTheme
import app.plugbrain.android.ui.theme.PrimaryGradient

val shape = RoundedCornerShape(50)
val buttonPadding = PaddingValues(
horizontal = 24.dp,
vertical = 15.dp,
)

// TODO add Primary button with the gradient
@Composable
fun PlugButtonPrimary(
text: String,
Expand All @@ -36,17 +45,26 @@ fun PlugButtonPrimary(
enabled: Boolean = true,
icon: ImageVector? = null,
) {
val shape = RoundedCornerShape(50)

Button(
onClick = onClick,
modifier = modifier,
enabled = enabled,
shape = shape,
elevation = ButtonDefaults.buttonElevation(
defaultElevation = 8.dp,
pressedElevation = 0.dp,
contentPadding = buttonPadding,
colors = ButtonDefaults.buttonColors(
containerColor = Color.Transparent,
disabledContainerColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.12f),
),
modifier = modifier
.then(
if (enabled) {
Modifier.background(
brush = PrimaryGradient,
shape = shape,
)
} else {
Modifier
},
),
) {
ButtonContent(
text = text,
Expand All @@ -63,13 +81,12 @@ fun PlugButtonSecondary(
enabled: Boolean = true,
icon: ImageVector? = null,
) {
val shape = RoundedCornerShape(50)

OutlinedButton(
onClick = onClick,
modifier = modifier,
enabled = enabled,
shape = shape,
contentPadding = buttonPadding,
) {
ButtonContent(
text = text,
Expand All @@ -86,13 +103,12 @@ fun PlugButtonTertiary(
enabled: Boolean = true,
icon: ImageVector? = null,
) {
val shape = RoundedCornerShape(50)

TextButton(
onClick = onClick,
modifier = modifier,
enabled = enabled,
shape = shape,
contentPadding = buttonPadding,
) {
ButtonContent(
text = text,
Expand Down Expand Up @@ -142,13 +158,19 @@ private fun PlugButtonPreview() {
MathlockAppTheme(dynamicColor = false) {
Column(
modifier = Modifier.background(MaterialTheme.colorScheme.background),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
PlugButtonPrimary(
text = "Primary Button with icon",
onClick = {},
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
PlugButtonPrimary(
text = "Primary Button without icon",
onClick = {},
modifier = Modifier.fillMaxWidth(),
)
PlugButtonPrimary(
text = "Primary Button disabled",
onClick = {},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading