-
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.
Added datasource files and classes similar to products. Edit user rol…
…e button leads to new screen. no data visible.
- Loading branch information
1 parent
43bf626
commit a43b9d2
Showing
8 changed files
with
136 additions
and
5 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.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( | ||
|
@@ -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
35
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,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" | ||
) | ||
|
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
78 changes: 77 additions & 1 deletion
78
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 |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
} |
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