From c3a9a8bbf9abc39dc1840194bfa7d1ff86359616 Mon Sep 17 00:00:00 2001 From: CAPEL Maxime <83071634+fortyup@users.noreply.github.com> Date: Thu, 21 Dec 2023 15:19:06 +0100 Subject: [PATCH] Update Button structure --- src/main/kotlin/main/Detail.kt | 4 +--- src/main/kotlin/main/Home.kt | 4 ++-- src/main/kotlin/main/component/Button.kt | 12 +++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/main/Detail.kt b/src/main/kotlin/main/Detail.kt index 5bdd2d2..873ba7b 100644 --- a/src/main/kotlin/main/Detail.kt +++ b/src/main/kotlin/main/Detail.kt @@ -6,8 +6,6 @@ import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Button -import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.icons.Icons @@ -35,7 +33,7 @@ fun glossaryDetailedPage(glossary: List, onBackClick: () -> Unit) { Spacer(modifier = Modifier.height(16.dp)) - buttonComponent(text = "Retour", onClick = { onBackClick() }) + buttonComponent(text = "Retour", onClick = { onBackClick() }, icon = Icons.Filled.ArrowBack, width = 150) } } diff --git a/src/main/kotlin/main/Home.kt b/src/main/kotlin/main/Home.kt index 8928e1a..5132219 100644 --- a/src/main/kotlin/main/Home.kt +++ b/src/main/kotlin/main/Home.kt @@ -203,7 +203,7 @@ fun glossaryList(glossaries: List, onGlossarySelected: (Glossary) -> U modifier = Modifier.width(200.dp).fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { - buttonComponent(glossary.name, { onGlossarySelected(glossary) }) + buttonComponent(glossary.name, { onGlossarySelected(glossary) }, width = 150) } } } @@ -257,7 +257,7 @@ fun projectList(projects: List, onProjectSelected: (Project) -> Unit, o modifier = Modifier.width(200.dp).fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { - buttonComponent(project.name, { onProjectSelected(project) }) + buttonComponent(project.name, { onProjectSelected(project) }, width = 150) } } } diff --git a/src/main/kotlin/main/component/Button.kt b/src/main/kotlin/main/component/Button.kt index b908428..5dfa9af 100644 --- a/src/main/kotlin/main/component/Button.kt +++ b/src/main/kotlin/main/component/Button.kt @@ -8,6 +8,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp +import androidx.compose.material.Icon +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.ui.graphics.vector.ImageVector import main.customRedColor @Composable @@ -15,15 +19,21 @@ fun buttonComponent( text: String, onClick: () -> Unit, modifier: Modifier = Modifier, + icon: ImageVector? = null, + width: Int = 200 + ) { Button( onClick = onClick, - modifier = modifier.width(200.dp), + modifier = modifier.width(width.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White ) ) { + if (icon != null) { + Icon(imageVector = icon, contentDescription = null) + } Text(text) } } \ No newline at end of file