Update Button structure

main
CAPEL Maxime 2023-12-21 15:19:06 +01:00
parent 8d46370f42
commit c3a9a8bbf9
3 changed files with 14 additions and 6 deletions

View File

@ -6,8 +6,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState 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.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
@ -35,7 +33,7 @@ fun glossaryDetailedPage(glossary: List<Word>, onBackClick: () -> Unit) {
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
buttonComponent(text = "Retour", onClick = { onBackClick() }) buttonComponent(text = "Retour", onClick = { onBackClick() }, icon = Icons.Filled.ArrowBack, width = 150)
} }
} }

View File

@ -203,7 +203,7 @@ fun glossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
modifier = Modifier.width(200.dp).fillMaxWidth(), modifier = Modifier.width(200.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween
) { ) {
buttonComponent(glossary.name, { onGlossarySelected(glossary) }) buttonComponent(glossary.name, { onGlossarySelected(glossary) }, width = 150)
} }
} }
} }
@ -257,7 +257,7 @@ fun projectList(projects: List<Project>, onProjectSelected: (Project) -> Unit, o
modifier = Modifier.width(200.dp).fillMaxWidth(), modifier = Modifier.width(200.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween
) { ) {
buttonComponent(project.name, { onProjectSelected(project) }) buttonComponent(project.name, { onProjectSelected(project) }, width = 150)
} }
} }
} }

View File

@ -8,6 +8,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp 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 import main.customRedColor
@Composable @Composable
@ -15,15 +19,21 @@ fun buttonComponent(
text: String, text: String,
onClick: () -> Unit, onClick: () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
icon: ImageVector? = null,
width: Int = 200
) { ) {
Button( Button(
onClick = onClick, onClick = onClick,
modifier = modifier.width(200.dp), modifier = modifier.width(width.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
) )
) { ) {
if (icon != null) {
Icon(imageVector = icon, contentDescription = null)
}
Text(text) Text(text)
} }
} }