Skip to content

Commit

Permalink
Added datasource files and classes similar to products. Edit user rol…
Browse files Browse the repository at this point in the history
…e button leads to new screen. no data visible.
  • Loading branch information
Annelisebx committed Nov 25, 2023
1 parent 43bf626 commit a43b9d2
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/belindas_closet/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ sealed class Routes (val route: String) {
object IndividualProduct: Routes("Individual_Product")
object IndividualProductUpdatePage: Routes("Individual_Product_Update")
object AdminView: Routes("Admin_View")
object EditUserRole: Routes("Edit_User_Role")
object EditUserRole: Routes("Edit User Role")

}
19 changes: 19 additions & 0 deletions app/src/main/java/com/example/belindas_closet/data/Datasource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import com.example.belindas_closet.model.ProductSizePantsInseam
import com.example.belindas_closet.model.ProductSizePantsWaist
import com.example.belindas_closet.model.ProductSizeShoes
import com.example.belindas_closet.model.ProductType
import com.example.belindas_closet.model.User
import com.example.belindas_closet.model.UserRole

class Datasource {
private val productList = mutableListOf<Product>()
private val userList = mutableListOf<User>()


init {
productList.add(
Expand Down Expand Up @@ -195,9 +199,24 @@ class Datasource {
"9"
)
)

// Adding Users to UserList
userList.add(
User(
userFirstName = "John",
userLastName = "Smith",
userEmail = "[email protected]",
UserRole.ADMIN,
userId = "1"
)
)
}

fun loadProducts(): List<Product> {
return productList
}

fun loadUsers(): List<User> {
return userList
}
}
35 changes: 35 additions & 0 deletions app/src/main/java/com/example/belindas_closet/model/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.belindas_closet.model

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.example.belindas_closet.R

// saving template of product variables in case of editing user variables similarly
enum class UserRole {
ADMIN, STANDARD
}
//
//// Shoes sizes
//enum class UserLastName(val size: Int?) {
// SELECT_SIZE(null), XS(5), S(6), M(7), L(8), XL(9), XXL(10), XXXL(11), XXXXL(12)
//}
//
//// General product sizes
//enum class UserEmail {
// SELECT_SIZE, XXS, XS, S, M, L, XL, XXL, XXXL, XXXXL
//}
//
//// productSizePantsWaist is nullable because not all products have a waist size
//enum class UserRole(val size: Int?) {
// SELECT_SIZE(null), XS(28), S(30), M(32), L(34), XL(36), XXL(38), XXXL(40), XXXXL(42)
//}


data class User(
val userFirstName: String,
val userLastName: String,
val userEmail: String,
val userRole: UserRole,
val userId: String = "0"
)

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fun AdminView(navController: NavHostController) {
}
Button(
onClick = {
/*TODO add navigation logic to page to edit user roles*/
navController.navigate(Routes.EditUserRole.route)
},
modifier = Modifier
.padding(4.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,80 @@
package com.example.belindas_closet.screen

class EditUserRole {
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
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.data.Datasource
import com.example.belindas_closet.model.Product
import com.example.belindas_closet.model.ProductType
import com.example.belindas_closet.model.User
import com.example.belindas_closet.model.UserRole

@Composable
fun EditUserRole(navController: NavController) {
Row(
modifier = Modifier
.size(125.dp)
.padding(top = 10.dp, start = 10.dp),
verticalAlignment = Alignment.Top,
horizontalArrangement = Arrangement.Start
) {
NSCLogo()
}
Row(
modifier = Modifier
.fillMaxSize(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
){
Column(
modifier = Modifier
.fillMaxSize(),
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.padding(50.dp))
UserList(users = Datasource().loadUsers(), navController = navController)
}
}
}

@Composable
fun UserList(users: List<User>, navController: NavController) {
val typeList = UserRole.values();
LazyColumn(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
) {
items(typeList) { UserRole ->
Spacer(modifier = Modifier.padding(16.dp))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fun ProductTypeList(products: List<Product>, navController: NavController) {
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
) {
items(typeList){productType ->
items(typeList){ productType ->
TypeCard(productType = productType, navController = navController)
Spacer(modifier = Modifier.padding(16.dp))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fun ScreenMain() {
AdminView(navController = navController)
}
composable(Routes.EditUserRole.route) {
AdminView(navController = navController)
EditUserRole(navController = navController)
}

composable(Routes.IndividualProduct.route+"/{productId}",
Expand Down

0 comments on commit a43b9d2

Please sign in to comment.