Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

belinda-closet-android-product-menu-dropdown-01 #213

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
)
}
}
}