Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
add product menu dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
tinpham5614 committed Nov 29, 2023
1 parent a760f64 commit bebddd0
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.Card
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand All @@ -41,11 +43,13 @@ import com.example.belindas_closet.R
import com.example.belindas_closet.Routes
import com.example.belindas_closet.data.Datasource
import com.example.belindas_closet.model.Product
import com.example.belindas_closet.model.ProductType

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ProductDetailPage(navController: NavController) {
var drawerState by remember { mutableStateOf(DrawerValue.Closed) }
var expanded by remember { mutableStateOf(false) }

Scaffold(
modifier = Modifier
Expand Down Expand Up @@ -80,10 +84,14 @@ fun ProductDetailPage(navController: NavController) {
IconButton(
onClick = {
drawerState = DrawerValue.Open
expanded = true;
}
) {
Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu")
}
DropDownCategoryList(expanded, navController) {
expanded = false
}
}
)
},
Expand Down Expand Up @@ -158,5 +166,27 @@ fun ProductDetailList(products: List<Product>, navController: NavController) {
}
}
}
@Composable
fun DropDownCategoryList(expanded: Boolean, navController: NavController, onDismissRequest: () -> Unit = {}) {
DropdownMenu(
expanded = expanded,
onDismissRequest = onDismissRequest,
modifier = Modifier
.padding(8.dp)
) {
ProductType.values().forEach { productType ->
DropdownMenuItem(
text = { Text(productType.type) },
onClick = {
onDismissRequest()
// navigate to product type page
MainActivity.setProductType(productType.type)
navController.navigate(
Routes.ProductDetail.route)
}
)
}
}
}


0 comments on commit bebddd0

Please sign in to comment.