Added list of reusable button components
This commit is contained in:
parent
1b470cc7d9
commit
2b6bcbd2b8
1 changed files with 56 additions and 0 deletions
|
@ -0,0 +1,56 @@
|
||||||
|
package be.ugent.sel.studeez.common.composable
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.compose.material.*
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BasicTextButton(@StringRes text: Int, modifier: Modifier, action: () -> Unit) {
|
||||||
|
TextButton(onClick = action, modifier = modifier) { Text(text = stringResource(text)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BasicButton(@StringRes text: Int, modifier: Modifier, action: () -> Unit) {
|
||||||
|
Button(
|
||||||
|
onClick = action,
|
||||||
|
modifier = modifier,
|
||||||
|
colors =
|
||||||
|
ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = MaterialTheme.colors.primary,
|
||||||
|
contentColor = MaterialTheme.colors.onPrimary
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(text), fontSize = 16.sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DialogConfirmButton(@StringRes text: Int, action: () -> Unit) {
|
||||||
|
Button(
|
||||||
|
onClick = action,
|
||||||
|
colors =
|
||||||
|
ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = MaterialTheme.colors.primary,
|
||||||
|
contentColor = MaterialTheme.colors.onPrimary
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(text))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DialogCancelButton(@StringRes text: Int, action: () -> Unit) {
|
||||||
|
Button(
|
||||||
|
onClick = action,
|
||||||
|
colors =
|
||||||
|
ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = MaterialTheme.colors.onPrimary,
|
||||||
|
contentColor = MaterialTheme.colors.primary
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(text))
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue