-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
belindas-android_4_167_edit-user-role (#234)
* new ind. page mockup * Initial commit. Added Route. * Storing 11.24 * Added datasource files and classes similar to products. Edit user role button leads to new screen. no data visible. * Placeholder users show on EditUserRole.kt * Edit Icon appears on user card. * Two user cards display for each userRole type. Edit icon visible. non-functioning. * Added scaffold & back arrow. EditUserRole.kt loads users each with edit icon. Added more users. --------- Co-authored-by: Nickolas <[email protected]>
- Loading branch information
1 parent
3df92a9
commit fea38e0
Showing
8 changed files
with
276 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,13 @@ import com.example.belindas_closet.model.ProductSizePantsWaist | |
import com.example.belindas_closet.model.ProductSizeShoes | ||
import com.example.belindas_closet.model.ProductSizes | ||
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( | ||
|
@@ -195,9 +199,72 @@ class Datasource { | |
"9" | ||
) | ||
) | ||
|
||
} | ||
init { | ||
|
||
// Adding Users to UserList | ||
userList.add( | ||
User( | ||
userFirstName = "John", | ||
userLastName = "Smith", | ||
userEmail = "[email protected]", | ||
UserRole.ADMIN, | ||
userId = "1" | ||
) | ||
) | ||
userList.add( | ||
User( | ||
userFirstName = "Alex", | ||
userLastName = "Brown", | ||
userEmail = "[email protected]", | ||
UserRole.STANDARD, | ||
userId = "2" | ||
) | ||
) | ||
userList.add( | ||
User( | ||
userFirstName = "Jason", | ||
userLastName = "Ni", | ||
userEmail = "[email protected]", | ||
UserRole.ADMIN, | ||
userId = "3" | ||
) | ||
) | ||
userList.add( | ||
User( | ||
userFirstName = "Kim", | ||
userLastName = "Johnson", | ||
userEmail = "[email protected]", | ||
UserRole.ADMIN, | ||
userId = "4" | ||
) | ||
) | ||
userList.add( | ||
User( | ||
userFirstName = "Ellen", | ||
userLastName = "Jones", | ||
userEmail = "[email protected]", | ||
UserRole.STANDARD, | ||
userId = "5" | ||
) | ||
) | ||
userList.add( | ||
User( | ||
userFirstName = "Taylor", | ||
userLastName = "Wright", | ||
userEmail = "[email protected]", | ||
UserRole.STANDARD, | ||
userId = "6" | ||
) | ||
) | ||
} | ||
|
||
fun loadProducts(): List<Product> { | ||
return productList | ||
} | ||
|
||
fun loadUsers(): List<User> { | ||
return userList | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/example/belindas_closet/model/User.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.example.belindas_closet.model | ||
|
||
import android.view.View | ||
import com.example.belindas_closet.R | ||
|
||
// saving template of product variables in case of editing user variables similarly | ||
enum class UserRole(val userType: String) { | ||
ADMIN("Admin"), STANDARD("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" | ||
) { | ||
companion object { | ||
const val userFirstName: String = "User First Name" | ||
const val userLastName: String = "User Last Name" | ||
const val userEmail: String = "[email protected]" | ||
val userRole: UserRole = UserRole.STANDARD | ||
val userId: String ="00" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
app/src/main/java/com/example/belindas_closet/screen/EditUserRole.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package com.example.belindas_closet.screen | ||
|
||
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.material.icons.Icons | ||
import androidx.compose.material.icons.filled.ArrowBack | ||
import androidx.compose.material.icons.filled.Edit | ||
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.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
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 | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun EditUserRole(navController: NavController) { | ||
|
||
Scaffold( | ||
modifier = Modifier | ||
.fillMaxSize(), | ||
topBar = { | ||
/* Back arrow that navigates back to login page */ | ||
TopAppBar( | ||
title = { Text("Back") }, | ||
navigationIcon = { | ||
IconButton( | ||
onClick = { | ||
navController.navigate(Routes.AdminView.route) | ||
} | ||
) { | ||
Icon( | ||
imageVector = Icons.Default.ArrowBack, | ||
contentDescription = "Back to Home page" | ||
) | ||
} | ||
} | ||
) | ||
} | ||
) { innerPadding -> | ||
val modifier = Modifier.padding(innerPadding) | ||
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 UserCard(user: User, navController: NavController) { | ||
Card( | ||
modifier = Modifier | ||
/** To Do: Make clickable **/ | ||
/** To Do: Make clickable **/ | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.Top, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text( | ||
text = user.userFirstName + " " + user.userLastName, | ||
style = TextStyle( | ||
fontSize = 15.sp, | ||
fontWeight = FontWeight.Bold, | ||
fontFamily = FontFamily.Default, | ||
), | ||
modifier = Modifier | ||
.wrapContentSize() | ||
) | ||
Text( | ||
text = "Current Role: " + user.userRole, | ||
style = TextStyle( | ||
fontSize = 15.sp, | ||
fontWeight = FontWeight.Bold, | ||
fontFamily = FontFamily.Default, | ||
), | ||
modifier = Modifier | ||
.wrapContentSize() | ||
) | ||
IconButton( | ||
onClick = { | ||
//TO DO: make icon functional and able to edit role. | ||
} | ||
) { | ||
Icon(imageVector = Icons.Default.Edit, contentDescription = "Edit") | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun UserList(users: List<User>, navController: NavController) { | ||
LazyColumn( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(20.dp), | ||
verticalArrangement = Arrangement.Top, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
items(users) { User -> | ||
UserCard(user = User, navController = navController) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters