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.graphics.Color
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import main.component.buttonComponent
var mostUsedWordList = mutableMapOf<String, Int>() var mostUsedWordList = mutableMapOf<String, Int>()
@ -60,27 +61,9 @@ fun homePage(
Row( Row(
horizontalArrangement = Arrangement.spacedBy(16.dp) horizontalArrangement = Arrangement.spacedBy(16.dp)
) { ) {
Button( buttonComponent(languageManager.getGlossaryText(), onProjectClick)
onClick = onProjectClick,
modifier = Modifier.width(200.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text(languageManager.getGlossaryText())
}
Button( buttonComponent(languageManager.getCodeToVerifyText(), onCodeToVerifyClick)
onClick = onCodeToVerifyClick,
modifier = Modifier.width(200.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text(languageManager.getCodeToVerifyText())
}
Button( Button(
onClick = { 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)
}
}