Skip to content

Commit

Permalink
belinda-closet-android-product-menu-dropdown-01 (#213)
Browse files Browse the repository at this point in the history
* add product menu dropdown

* using drawerState instead of expand

---------

Co-authored-by: E. Brink <[email protected]>
  • Loading branch information
tinpham5614 and brinkbrink authored Nov 30, 2023
1 parent 2e32d1d commit e624783
Showing 1 changed file with 28 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,6 +43,7 @@ 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
Expand Down Expand Up @@ -84,6 +87,9 @@ fun ProductDetailPage(navController: NavController) {
) {
Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu")
}
DropDownCategoryList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
}
)
},
Expand Down Expand Up @@ -158,5 +164,27 @@ fun ProductDetailList(products: List<Product>, navController: NavController) {
}
}
}
@Composable
fun DropDownCategoryList(drawerState: DrawerValue, navController: NavController, onDismissRequest: () -> Unit = {}) {
DropdownMenu(
drawerState == DrawerValue.Open,
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 e624783

Please sign in to comment.