Add component for button

main
CAPEL Maxime 2023-12-21 14:49:33 +01:00
parent ab24995360
commit 34656cfac3
2 changed files with 32 additions and 20 deletions

View File

@ -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<String, Int>()
@ -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 = {

View File

@ -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)
}
}