From 34656cfac37aaff4592360353d8b908621767068 Mon Sep 17 00:00:00 2001 From: CAPEL Maxime <83071634+fortyup@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:49:33 +0100 Subject: [PATCH] Add component for button --- src/main/kotlin/main/Home.kt | 23 +++---------------- src/main/kotlin/main/component/Button.kt | 29 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 src/main/kotlin/main/component/Button.kt diff --git a/src/main/kotlin/main/Home.kt b/src/main/kotlin/main/Home.kt index 175a993..7847817 100644 --- a/src/main/kotlin/main/Home.kt +++ b/src/main/kotlin/main/Home.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp +import main.component.buttonComponent var mostUsedWordList = mutableMapOf() @@ -60,27 +61,9 @@ fun homePage( Row( horizontalArrangement = Arrangement.spacedBy(16.dp) ) { - Button( - onClick = onProjectClick, - modifier = Modifier.width(200.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = customRedColor, - contentColor = Color.White - ) - ) { - Text(languageManager.getGlossaryText()) - } + buttonComponent(languageManager.getGlossaryText(), onProjectClick) - Button( - onClick = onCodeToVerifyClick, - modifier = Modifier.width(200.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = customRedColor, - contentColor = Color.White - ) - ) { - Text(languageManager.getCodeToVerifyText()) - } + buttonComponent(languageManager.getCodeToVerifyText(), onCodeToVerifyClick) Button( onClick = { diff --git a/src/main/kotlin/main/component/Button.kt b/src/main/kotlin/main/component/Button.kt new file mode 100644 index 0000000..b908428 --- /dev/null +++ b/src/main/kotlin/main/component/Button.kt @@ -0,0 +1,29 @@ +package main.component + +import androidx.compose.foundation.layout.width +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import main.customRedColor + +@Composable +fun buttonComponent( + text: String, + onClick: () -> Unit, + modifier: Modifier = Modifier, +) { + Button( + onClick = onClick, + modifier = modifier.width(200.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text(text) + } +} \ No newline at end of file