Add menu button
parent
01fcd8690b
commit
bdf9492185
|
@ -125,6 +125,26 @@ fun homePage(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Example usage with text options
|
||||
dropdownButtonComponent(
|
||||
items = listOf("Glossaire", "Code à vérifier", "Comparer")
|
||||
) { selectedOption ->
|
||||
// Handle the selected option
|
||||
when (selectedOption) {
|
||||
"Glossaire" -> onProjectClick()
|
||||
"Code à vérifier" -> onCodeToVerifyClick()
|
||||
"Comparer" -> {
|
||||
if (mostUsedWordList.isEmpty()) {
|
||||
noFileSnackbarVisibleState.value = true
|
||||
println("Veuillez d'abord importer un fichier")
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var selectedProject by remember { mutableStateOf<Project?>(null) }
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun dropdownButtonComponent(
|
||||
modifier: Modifier = Modifier,
|
||||
items: List<String>,
|
||||
onItemSelected: (String) -> Unit
|
||||
) {
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
var selectedIndex by remember { mutableStateOf(0) }
|
||||
|
||||
Box(modifier = modifier) {
|
||||
Button(
|
||||
onClick = { expanded = true },
|
||||
modifier = Modifier
|
||||
.padding(16.dp),
|
||||
contentPadding = PaddingValues(8.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Menu, // Use Menu icon for hamburger
|
||||
contentDescription = "Menu",
|
||||
tint = Color.White
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(text = "Menu", color = Color.White)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
}
|
||||
DropdownMenu(
|
||||
modifier = Modifier.width(200.dp),
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
items.forEachIndexed { index, s ->
|
||||
DropdownMenuItem(onClick = {
|
||||
selectedIndex = index
|
||||
expanded = false
|
||||
onItemSelected(s)
|
||||
}) {
|
||||
Text(text = s)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue