@Composable
fun DropDownMenu() {
var expanded by remember { mutableStateOf(false) }
val contextForToast = LocalContext.current.applicationContext
Column(
modifier = Modifier
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "DropdownMenu", Modifier.padding(top = 10.dp), fontSize = 20.sp)
Box(
modifier = Modifier
.fillMaxSize()
.padding(start = 15.dp)
.wrapContentSize(align = Alignment.TopStart),
contentAlignment = Alignment.Center
) {
IconButton(
onClick = {
expanded = true
}
) {
Icon(
imageVector = Icons.Default.MoreVert,
contentDescription = "Open Menu"
)
}
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false }
) {
DropdownMenuItem(
onClick = {
Toast.makeText(contextForToast, "¡Suscrito!", Toast.LENGTH_SHORT).show()
expanded = false
},
) {
Icon(
imageVector = Icons.Outlined.Favorite,
contentDescription = null,
tint = MaterialTheme.colors.primary
)
Text("¡Suscríbete!")
}
DropdownMenuItem(
onClick = {
Toast.makeText(contextForToast, "Suscribir", Toast.LENGTH_SHORT).show()
expanded = false
},
) {
Icon(
imageVector = Icons.Outlined.Check,
contentDescription = null,
tint = MaterialTheme.colors.primary
)
Text("¡Suscribirse!")
}
DropdownMenuItem(
onClick = {
Toast.makeText(contextForToast, "JetpackCompose.pro", Toast.LENGTH_SHORT)
.show()
expanded = false
},
) {
Icon(
imageVector = Icons.Outlined.Home,
contentDescription = null,
tint = MaterialTheme.colors.primary
)
Text("JetpackCompose.pro")
}
}
}
}
}