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

Mission Page plus dropdown #282

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/src/main/java/com/example/belindas_closet/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ sealed class Routes (val route: String) {
object CreatorView: Routes("Creator_View")
object EditUserRole: Routes("Edit User Role")
object DonationInfo: Routes("Donation_Info")
object Mission: Routes("Mission")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.belindas_closet.components

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.example.belindas_closet.MainActivity
import com.example.belindas_closet.Routes
import com.example.belindas_closet.model.ProductType

@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun DropdownNavList(drawerState: DrawerValue, navController: NavController, onDismissRequest: () -> Unit = {}) {
DropdownMenu(
drawerState == DrawerValue.Open,
onDismissRequest = onDismissRequest,
modifier = Modifier
.padding(8.dp)
) {
DropdownMenuItem(
text = { Text(text = "Mission") },
onClick = {
onDismissRequest()
navController.navigate(
Routes.Mission.route)
}
)
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)
}
)
}
}
}
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/belindas_closet/screen/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -41,11 +46,13 @@ 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
import com.example.belindas_closet.components.DropdownNavList

//TODO Add Product Catefories to Navbar
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomePage(navController: NavController) {
var drawerState by remember { mutableStateOf(DrawerValue.Closed) }
TopAppBar(
title = { Text("") },
actions = {
Expand All @@ -71,10 +78,14 @@ fun HomePage(navController: NavController) {
}
IconButton(
onClick = {
drawerState = DrawerValue.Open
}
) {
Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu")
}
DropdownNavList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
},
)
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.window.Popup
import com.example.belindas_closet.MainActivity
import com.example.belindas_closet.components.DropdownNavList
import com.example.belindas_closet.data.network.dto.auth_dto.Role

//TODO Add Product Categories to Navbar
Expand Down Expand Up @@ -89,7 +90,7 @@ fun IndividualProductPage(navController: NavController, productId: String) {
contentDescription = "Menu"
)
}
DropDownCategoryList(drawerState, navController) {
DropdownNavList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import androidx.navigation.NavController
import com.example.belindas_closet.MainActivity
import com.example.belindas_closet.R
import com.example.belindas_closet.Routes
import com.example.belindas_closet.components.DropdownNavList
import com.example.belindas_closet.data.Datasource
import com.example.belindas_closet.data.network.product.ArchiveService
import com.example.belindas_closet.data.network.product.DeleteService
Expand Down Expand Up @@ -118,7 +119,7 @@ fun IndividualProductUpdatePage(navController: NavController, productId: String)
contentDescription = "Menu"
)
}
DropDownCategoryList(drawerState, navController) {
DropdownNavList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
}
Expand Down
94 changes: 94 additions & 0 deletions app/src/main/java/com/example/belindas_closet/screen/Mission.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.example.belindas_closet.screen

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
import com.example.belindas_closet.MainActivity
import com.example.belindas_closet.Routes
import com.example.belindas_closet.data.network.dto.auth_dto.Role
import com.example.belindas_closet.components.DropdownNavList

@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun MissionPage(navController: NavController) {
var drawerState by remember { mutableStateOf(DrawerValue.Closed) }

Scaffold(
modifier = Modifier
.fillMaxSize(),
topBar = {
/* Back arrow that navigates back to login page */
TopAppBar(
title = { Text("Home") },
navigationIcon = {
IconButton(
onClick = {
navController.navigate(Routes.Home.route)
}
) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "Back to Home page"
)
}
},
actions = {
/* Edit option visibility */
val userRole = MainActivity.getPref().getString("userRole", Role.USER.name)?.let {
Role.valueOf(it)
} ?: Role.USER
if (userRole == Role.ADMIN || userRole == Role.CREATOR) {
IconButton(
onClick = {
navController.navigate(Routes.Update.route)
}
) {
Icon(imageVector = Icons.Default.Edit, contentDescription = "Edit")
}
}
IconButton(
onClick = {
drawerState = DrawerValue.Open
}
) {
Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu")
}
DropdownNavList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
}
)
},
) { innerPadding ->
val modifier = Modifier.padding(innerPadding)
Column(
modifier = modifier
.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
CustomTextField(text = "Mission Statement Placeholder")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.example.belindas_closet.data.Datasource
import com.example.belindas_closet.data.network.dto.auth_dto.Role
import com.example.belindas_closet.model.Product
import com.example.belindas_closet.model.ProductType
import com.example.belindas_closet.components.DropdownNavList

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -91,7 +92,7 @@ fun ProductDetailPage(navController: NavController) {
) {
Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu")
}
DropDownCategoryList(drawerState, navController) {
DropdownNavList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
}
Expand Down Expand Up @@ -168,26 +169,3 @@ 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)
}
)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ fun ScreenMain() {
CreatorView(navController = navController)
}

composable(Routes.Mission.route) {
MissionPage(navController = navController)
}

composable(Routes.IndividualProduct.route+"/{productId}",
arguments = listOf(navArgument("productId") { type = NavType.StringType })
) { backStackEntry ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import androidx.navigation.NavController
import com.example.belindas_closet.MainActivity
import com.example.belindas_closet.R
import com.example.belindas_closet.Routes
import com.example.belindas_closet.components.DropdownNavList
import com.example.belindas_closet.data.Datasource
import com.example.belindas_closet.data.network.dto.auth_dto.Role
import com.example.belindas_closet.model.Product
Expand Down Expand Up @@ -103,7 +104,7 @@ fun UpdatePage(navController: NavController) {
contentDescription = "Menu"
)
}
DropDownCategoryList(drawerState, navController) {
DropdownNavList(drawerState, navController) {
drawerState = DrawerValue.Closed
}
}
Expand Down
Loading