From 7d44afcf1166d759797624e4f2af25bcf420666c Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Fri, 13 Oct 2023 21:48:17 +0400 Subject: [PATCH] Feature: complete full task --- .idea/deploymentTargetDropDown.xml | 17 ++ app/build.gradle.kts | 8 +- .../Navigation/NavController.kt | 28 ++- .../android_programming/Navigation/NavItem.kt | 6 + .../Navigation/Navigate.kt | 5 +- .../Screens/AdminPanel/AddPanel.kt | 187 ++++++++++++++++++ .../Screens/AdminPanel/AdminPanel.kt | 48 +++++ .../Screens/AdminPanel/Button.kt | 45 +++++ .../AdminPanel/CardSneakerForChange.kt | 92 +++++++++ .../Screens/AdminPanel/ChangePanel.kt | 41 ++++ .../Screens/AdminPanel/ChangeSneaker.kt | 176 +++++++++++++++++ .../Screens/HomeScreen/AboutSneaker.kt | 41 ++++ .../Screens/HomeScreen/HomeScreen.kt | 40 +--- .../SneakerRecyclerView/CardSneaker.kt | 16 +- .../Screens/LikeScreen/CardSneaker.kt | 2 +- .../Screens/LikeScreen/LikeScreen.kt | 4 - .../Screens/OrderScreen/OrderScreen.kt | 5 - .../android_programming/SneakerItem.kt | 58 +++++- app/src/main/res/drawable/change.png | Bin 0 -> 528 bytes app/src/main/res/drawable/trash.png | Bin 0 -> 399 bytes app/src/main/res/values/colors.xml | 1 + 21 files changed, 761 insertions(+), 59 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 app/src/main/java/com/example/android_programming/Screens/AdminPanel/AddPanel.kt create mode 100644 app/src/main/java/com/example/android_programming/Screens/AdminPanel/AdminPanel.kt create mode 100644 app/src/main/java/com/example/android_programming/Screens/AdminPanel/Button.kt create mode 100644 app/src/main/java/com/example/android_programming/Screens/AdminPanel/CardSneakerForChange.kt create mode 100644 app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangePanel.kt create mode 100644 app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangeSneaker.kt create mode 100644 app/src/main/java/com/example/android_programming/Screens/HomeScreen/AboutSneaker.kt create mode 100644 app/src/main/res/drawable/change.png create mode 100644 app/src/main/res/drawable/trash.png diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..26e1ab7 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f7a329b..f734b81 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -53,7 +53,7 @@ dependencies { implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") - implementation("androidx.activity:activity-compose:1.7.2") + implementation("androidx.activity:activity-compose:1.8.0") implementation(platform("androidx.compose:compose-bom:2023.03.00")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") @@ -67,6 +67,10 @@ dependencies { androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") + implementation ("androidx.activity:activity-ktx:1.8.0") + implementation ("androidx.fragment:fragment-ktx:1.6.1") + implementation ("io.coil-kt:coil-compose:1.4.0") + implementation ("com.google.code.gson:gson:2.8.8") - implementation("androidx.navigation:navigation-compose:2.7.3") + implementation("androidx.navigation:navigation-compose:2.7.4") } \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Navigation/NavController.kt b/app/src/main/java/com/example/android_programming/Navigation/NavController.kt index 4189853..b6a3410 100644 --- a/app/src/main/java/com/example/android_programming/Navigation/NavController.kt +++ b/app/src/main/java/com/example/android_programming/Navigation/NavController.kt @@ -4,6 +4,11 @@ import androidx.compose.runtime.Composable import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable +import com.example.android_programming.Screens.AdminPanel.AddPanel +import com.example.android_programming.Screens.AdminPanel.AdminPanel +import com.example.android_programming.Screens.AdminPanel.ChangePanel +import com.example.android_programming.Screens.AdminPanel.ChangeSneaker +import com.example.android_programming.Screens.HomeScreen.AboutSneaker import com.example.android_programming.Screens.HomeScreen.HomeScreen import com.example.android_programming.Screens.LikeScreen.LikeScreen import com.example.android_programming.Screens.OrderScreen.OrderScreen @@ -11,6 +16,8 @@ import com.example.android_programming.Screens.ProfileScreen.Profile.Person import com.example.android_programming.Screens.ProfileScreen.Profile.ProfileScreen import com.example.android_programming.Screens.ProfileScreen.SignIn.LoginScreen import com.example.android_programming.Screens.ProfileScreen.SignUp.SignUpScreen +import com.example.android_programming.SneakerItem +import com.google.gson.Gson @Composable fun NavController(navController: NavHostController){ @@ -19,7 +26,7 @@ fun NavController(navController: NavHostController){ startDestination = NavItem.Home.route ){ composable(NavItem.Home.route){ - HomeScreen() + HomeScreen(navController) } composable(NavItem.Like.route){ LikeScreen() @@ -39,5 +46,24 @@ fun NavController(navController: NavHostController){ composable(NavItem.Person.route){ Person() } + composable(NavItem.AdminPanel.route){ + AdminPanel(navController) + } + composable(NavItem.AddPanel.route){ + AddPanel() + } + composable(NavItem.ChangePanel.route){ + ChangePanel(navController) + } + composable(NavItem.AboutSneaker.route) { backStackEntry -> + val sneakerItemString = backStackEntry.arguments?.getString("sneakerItem") + val sneakerItem = Gson().fromJson(sneakerItemString, SneakerItem::class.java) + sneakerItem?.let { AboutSneaker(it) } + } + composable(NavItem.ChangeSneaker.route) { backStackEntry -> + val sneakerItemString = backStackEntry.arguments?.getString("sneakerItem") + val sneakerItem = Gson().fromJson(sneakerItemString, SneakerItem::class.java) + sneakerItem?.let { ChangeSneaker(it) } + } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt b/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt index 7486284..72d03b2 100644 --- a/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt +++ b/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt @@ -1,6 +1,7 @@ package com.example.android_programming.Navigation import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Build import androidx.compose.material.icons.filled.Favorite import androidx.compose.material.icons.filled.Home import androidx.compose.material.icons.filled.Person @@ -15,4 +16,9 @@ sealed class NavItem(val route: String, val icon: ImageVector?){ object SignIn : NavItem("login", null) object SignUp : NavItem("signup", null) object Person : NavItem("person", null) + object AdminPanel : NavItem("admin", Icons.Default.Build) + object AddPanel : NavItem("add", null) + object ChangePanel : NavItem("change", null) + object AboutSneaker : NavItem("aboutSneaker/{sneakerItem}", null) + object ChangeSneaker : NavItem("changeSneaker/{sneakerItem}", null) } \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt b/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt index c5025eb..f6eb0db 100644 --- a/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt +++ b/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt @@ -12,10 +12,12 @@ import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.colorResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController +import com.example.android_programming.R @SuppressLint("UnusedMaterialScaffoldPaddingParameter") @Composable @@ -26,6 +28,7 @@ fun Navigate(){ NavItem.Like, NavItem.Order, NavItem.Profile, + NavItem.AdminPanel, ) Scaffold(bottomBar = { @@ -55,7 +58,7 @@ fun Navigate(){ icon = { val iconModifier = if (isSelected) { Modifier - .background(color = Color.LightGray, shape = CircleShape) + .background(color = colorResource(id = R.color.figma_blue), shape = CircleShape) .padding(8.dp) } else { Modifier diff --git a/app/src/main/java/com/example/android_programming/Screens/AdminPanel/AddPanel.kt b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/AddPanel.kt new file mode 100644 index 0000000..eabed79 --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/AddPanel.kt @@ -0,0 +1,187 @@ +package com.example.android_programming.Screens.AdminPanel + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material.Button +import androidx.compose.material.Text +import androidx.compose.material.TextField +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.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.input.ImeAction +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +@Preview +fun AddPanel(){ + var brand by remember { mutableStateOf("") } + var model by remember { mutableStateOf("") } + var description by remember { mutableStateOf("") } + var price by remember { mutableStateOf("") } + + Column( + modifier = Modifier + .fillMaxSize() + .background(Color.White) + .padding(16.dp) + ){ + Box( + modifier = Modifier + .fillMaxWidth() + .height(150.dp) + .background(Color.Gray) + ) { + } + Button( + onClick = { + }, + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(20.dp)) + .padding(16.dp) + ) { + Text("Add image") + } + + TextField( + value = brand, + onValueChange = { brand = it }, + modifier = Modifier + .fillMaxWidth() + .height(50.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + singleLine = true, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ), + placeholder = { + Text( + text = "Brand", + style = TextStyle(fontSize = 12.sp) + ) + } + ) + + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = model, + onValueChange = { model = it }, + modifier = Modifier + .fillMaxWidth() + .height(50.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + singleLine = true, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ), + placeholder = { + Text( + text = "Model", + style = TextStyle(fontSize = 12.sp) + ) + } + ) + + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = description, + onValueChange = { description = it }, + modifier = Modifier + .fillMaxWidth() + .height(100.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ), + placeholder = { + Text( + text = "Description", + style = TextStyle(fontSize = 12.sp) + ) + } + ) + + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = price, + onValueChange = { price = it }, + modifier = Modifier + .fillMaxWidth() + .height(50.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + singleLine = true, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ), + placeholder = { + Text( + text = "Price", + style = TextStyle(fontSize = 12.sp) + ) + } + ) + + Button( + onClick = { + + }, + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(20.dp)) + .padding(16.dp) + ) { + Text("Add sneaker") + } + } + +} diff --git a/app/src/main/java/com/example/android_programming/Screens/AdminPanel/AdminPanel.kt b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/AdminPanel.kt new file mode 100644 index 0000000..e6adcd6 --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/AdminPanel.kt @@ -0,0 +1,48 @@ +package com.example.android_programming.Screens.AdminPanel + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Text +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.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController + +@Composable +fun AdminPanel(navHostController: NavHostController) { + var isAddPanelVisible by remember { mutableStateOf(false) } + var isChangePanelVisible by remember { mutableStateOf(false) } + + Column( + modifier = Modifier + .fillMaxSize() + .background(Color.White) + .padding(16.dp) + ) { + ButtonAdmin( + onAddClick = { + isAddPanelVisible = true + isChangePanelVisible = false + }, + onChangeClick = { + isChangePanelVisible = true + isAddPanelVisible = false + } + ) + + if (isAddPanelVisible) { + AddPanel() + } + + if (isChangePanelVisible) { + ChangePanel(navHostController) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Screens/AdminPanel/Button.kt b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/Button.kt new file mode 100644 index 0000000..3d65b70 --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/Button.kt @@ -0,0 +1,45 @@ +package com.example.android_programming.Screens.AdminPanel + +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button +import androidx.compose.material.Text +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.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController + +@Composable +fun ButtonAdmin(onAddClick: () -> Unit, onChangeClick: () -> Unit) { + Row(){ + Button( + onClick = { + onAddClick() + }, + modifier = Modifier + .clip(RoundedCornerShape(20.dp)) + .fillMaxWidth(0.5f) + .padding(16.dp) + ) { + Text("Add") + } + Button( + onClick = { + onChangeClick() + }, + modifier = Modifier + .clip(RoundedCornerShape(20.dp)) + .fillMaxWidth() + .padding(16.dp) + ) { + Text("Change/Del") + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Screens/AdminPanel/CardSneakerForChange.kt b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/CardSneakerForChange.kt new file mode 100644 index 0000000..3303456 --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/CardSneakerForChange.kt @@ -0,0 +1,92 @@ +package com.example.android_programming.Screens.AdminPanel + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +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.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavHostController +import com.example.android_programming.R +import com.example.android_programming.SneakerItem +import com.google.gson.Gson + +@Composable +fun CardSneakerForChange(item: SneakerItem, navController: NavHostController) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(10.dp) + .clip(RoundedCornerShape(10.dp)) + .background(colorResource(id = R.color.figma)), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + Image( + painter = painterResource(id = item.imageId), + contentDescription = "image", + contentScale = ContentScale.FillWidth, + modifier = Modifier + .size(70.dp) + .padding(10.dp) + .clip(RoundedCornerShape(10.dp)) + ) + + Column( + modifier = Modifier + .weight(1f) + .padding(start = 16.dp) + ) { + item.name?.let { Text(text = it, fontSize = 20.sp) } + Text(text = "${item.price} USD", color = Color.Red, fontSize = 16.sp) + } + + Image( + painter = painterResource(id = R.drawable.change), + contentDescription = "image", + modifier = Modifier + .size(40.dp) + .padding(10.dp) + .clickable { + val sneakerItemString = Gson().toJson(item) + navController.navigate("changeSneaker/${sneakerItemString}") + } + ) + + Image( + painter = painterResource(id = R.drawable.trash), + contentDescription = "image", + modifier = Modifier + .size(40.dp) + .padding(10.dp) + .clickable { + + } + ) + } +} + + + +/* +@Composable +@Preview +fun CardSneakerLikePreview(){ + CardSneakerForChange(SneakerItem(R.drawable.sneaker, "Jordan", 159.99)) +}*/ diff --git a/app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangePanel.kt b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangePanel.kt new file mode 100644 index 0000000..c01ab6f --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangePanel.kt @@ -0,0 +1,41 @@ +package com.example.android_programming.Screens.AdminPanel + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.navigation.NavHostController +import com.example.android_programming.R +import com.example.android_programming.SneakerItem + +@Composable +fun ChangePanel(navHostController: NavHostController) { + Column( + modifier = Modifier + .fillMaxSize() + .background(Color.White) + ){ + Row { + LazyColumn( + modifier = Modifier + .fillMaxSize() + ) { + itemsIndexed( + listOf( + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.trash, "Nike", 179.99), + ) + ){_, item-> + CardSneakerForChange(item = item, navHostController) + + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangeSneaker.kt b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangeSneaker.kt new file mode 100644 index 0000000..0fc3053 --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/AdminPanel/ChangeSneaker.kt @@ -0,0 +1,176 @@ +package com.example.android_programming.Screens.AdminPanel + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material.Button +import androidx.compose.material.Text +import androidx.compose.material.TextField +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.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.input.ImeAction +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.example.android_programming.SneakerItem +@Composable +fun ChangeSneaker(sneaker: SneakerItem) { + var brand by remember { mutableStateOf("") } + var model by remember { mutableStateOf("") } + var description by remember { mutableStateOf("") } + var price by remember { mutableStateOf("") } + + Column( + modifier = Modifier + .fillMaxSize() + .background(Color.White) + .padding(16.dp) + ){ + Image( + painter = painterResource(id = sneaker.imageId), + contentDescription = "image", + contentScale = ContentScale.FillWidth, + modifier = Modifier + .fillMaxWidth() + .height(200.dp) + ) + Button( + onClick = { + }, + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(20.dp)) + .padding(16.dp) + ) { + Text("Change image") + } + + TextField( + value = sneaker.name.toString(), + onValueChange = { brand = it }, + modifier = Modifier + .fillMaxWidth() + .height(50.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + singleLine = true, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ) + ) + + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = model, + onValueChange = { model = it }, + modifier = Modifier + .fillMaxWidth() + .height(50.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + singleLine = true, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ), + placeholder = { + Text( + text = "Model", + style = TextStyle(fontSize = 12.sp) + ) + } + ) + + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = description, + onValueChange = { description = it }, + modifier = Modifier + .fillMaxWidth() + .height(100.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ), + placeholder = { + Text( + text = "Description", + style = TextStyle(fontSize = 12.sp) + ) + } + ) + + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = sneaker.price.toString(), + onValueChange = { price = it }, + modifier = Modifier + .fillMaxWidth() + .height(50.dp) + .border(1.dp, Color.Gray, RoundedCornerShape(4.dp)) + .padding(0.dp), + singleLine = true, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Text, + imeAction = ImeAction.Next + ), + keyboardActions = KeyboardActions( + onNext = { + + } + ) + ) + + Button( + onClick = { + + }, + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(20.dp)) + .padding(16.dp) + ) { + Text("Save") + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Screens/HomeScreen/AboutSneaker.kt b/app/src/main/java/com/example/android_programming/Screens/HomeScreen/AboutSneaker.kt new file mode 100644 index 0000000..c9b57bc --- /dev/null +++ b/app/src/main/java/com/example/android_programming/Screens/HomeScreen/AboutSneaker.kt @@ -0,0 +1,41 @@ +package com.example.android_programming.Screens.HomeScreen + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavBackStackEntry +import androidx.navigation.NavController +import com.example.android_programming.SneakerItem + +@Composable +fun AboutSneaker(sneaker: SneakerItem) { + Column( + modifier = Modifier.fillMaxSize() + ) { + Image( + painter = painterResource(id = sneaker.imageId), + contentDescription = "image", + contentScale = ContentScale.FillWidth, + modifier = Modifier + .fillMaxWidth() + .height(200.dp) + ) + + Column( + modifier = Modifier.padding(16.dp) + ) { + Text(text = "Name: ${sneaker.name}", fontSize = 18.sp) + Text(text = "Price: $${sneaker.price}", fontSize = 16.sp) + } + } +} diff --git a/app/src/main/java/com/example/android_programming/Screens/HomeScreen/HomeScreen.kt b/app/src/main/java/com/example/android_programming/Screens/HomeScreen/HomeScreen.kt index 700e93f..abf20ab 100644 --- a/app/src/main/java/com/example/android_programming/Screens/HomeScreen/HomeScreen.kt +++ b/app/src/main/java/com/example/android_programming/Screens/HomeScreen/HomeScreen.kt @@ -15,20 +15,18 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController -import androidx.navigation.compose.rememberNavController import com.example.android_programming.Screens.HomeScreen.BrandScrollBar.ItemFilterByBrand import com.example.android_programming.Screens.HomeScreen.BrandScrollBar.ItemRow import com.example.android_programming.Screens.HomeScreen.SearchField.SearchField import com.example.android_programming.Screens.HomeScreen.SneakerRecyclerView.CardSneaker import com.example.android_programming.SneakerItem import com.example.android_programming.R +import com.example.android_programming.getSneakers @Composable -fun HomeScreen() { - val navController = rememberNavController() +fun HomeScreen(navHostController: NavHostController) { Column( modifier = Modifier .fillMaxSize() @@ -72,31 +70,8 @@ fun HomeScreen() { modifier = Modifier .fillMaxSize() ) { - val list = listOf( - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - SneakerItem(R.drawable.sneaker, "Jordan", 159.99), - ) - - // Определите количество столбцов + val list = getSneakers() val numColumns = 2 - - // Разделите список на группы по numColumns элементов val chunkedList = list.chunked(numColumns) itemsIndexed(chunkedList) { _, chunkedListItem -> @@ -106,8 +81,7 @@ fun HomeScreen() { .fillMaxWidth() ) { for (item in chunkedListItem) { - // Создайте карточку для каждого элемента - CardSneaker(item = item, navController = navController) + CardSneaker(item, navHostController) } } } @@ -117,11 +91,5 @@ fun HomeScreen() { } } -@Composable -@Preview -fun HomeScreenPreview(){ - HomeScreen() -} - diff --git a/app/src/main/java/com/example/android_programming/Screens/HomeScreen/SneakerRecyclerView/CardSneaker.kt b/app/src/main/java/com/example/android_programming/Screens/HomeScreen/SneakerRecyclerView/CardSneaker.kt index 2279753..a531075 100644 --- a/app/src/main/java/com/example/android_programming/Screens/HomeScreen/SneakerRecyclerView/CardSneaker.kt +++ b/app/src/main/java/com/example/android_programming/Screens/HomeScreen/SneakerRecyclerView/CardSneaker.kt @@ -13,6 +13,8 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Button +import androidx.compose.material.ButtonColors +import androidx.compose.material.ButtonDefaults import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -26,9 +28,13 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.core.os.bundleOf import androidx.navigation.NavHostController +import androidx.navigation.compose.rememberNavController import com.example.android_programming.R +import com.example.android_programming.Screens.HomeScreen.AboutSneaker import com.example.android_programming.SneakerItem +import com.google.gson.Gson @Composable fun CardSneaker(item: SneakerItem, navController: NavHostController) { @@ -39,7 +45,8 @@ fun CardSneaker(item: SneakerItem, navController: NavHostController) { .padding(4.dp) .widthIn(maxWidth) .clickable { - navController.navigate("signup") + val sneakerItemString = Gson().toJson(item) + navController.navigate("aboutSneaker/${sneakerItemString}") } ) { Column( @@ -68,7 +75,7 @@ fun CardSneaker(item: SneakerItem, navController: NavHostController) { modifier = Modifier .padding(10.dp, 0.dp) ) { - Text(text = item.name) + item.name?.let { Text(text = it) } Text(text = item.price.toString(), color = Color.Red) } Column( @@ -88,8 +95,3 @@ fun CardSneaker(item: SneakerItem, navController: NavHostController) { } } } -@Composable -@Preview -fun CardSneakerPreview(){ -// CardSneaker(SneakerItem(R.drawable.sneaker, "Air Jordan 1", 159.99)) -} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Screens/LikeScreen/CardSneaker.kt b/app/src/main/java/com/example/android_programming/Screens/LikeScreen/CardSneaker.kt index 10b1ecc..10e2faf 100644 --- a/app/src/main/java/com/example/android_programming/Screens/LikeScreen/CardSneaker.kt +++ b/app/src/main/java/com/example/android_programming/Screens/LikeScreen/CardSneaker.kt @@ -51,7 +51,7 @@ fun CardSneakerLike(item: SneakerItem) { .weight(1f) .padding(start = 16.dp) ) { - Text(text = item.name, fontSize = 20.sp) + item.name?.let { Text(text = it, fontSize = 20.sp) } Text(text = "${item.price} USD", color = Color.Red, fontSize = 16.sp) } diff --git a/app/src/main/java/com/example/android_programming/Screens/LikeScreen/LikeScreen.kt b/app/src/main/java/com/example/android_programming/Screens/LikeScreen/LikeScreen.kt index 8ffa206..6bd9d11 100644 --- a/app/src/main/java/com/example/android_programming/Screens/LikeScreen/LikeScreen.kt +++ b/app/src/main/java/com/example/android_programming/Screens/LikeScreen/LikeScreen.kt @@ -1,19 +1,15 @@ package com.example.android_programming.Screens.LikeScreen; import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable; -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight diff --git a/app/src/main/java/com/example/android_programming/Screens/OrderScreen/OrderScreen.kt b/app/src/main/java/com/example/android_programming/Screens/OrderScreen/OrderScreen.kt index 10f711e..cabd3f8 100644 --- a/app/src/main/java/com/example/android_programming/Screens/OrderScreen/OrderScreen.kt +++ b/app/src/main/java/com/example/android_programming/Screens/OrderScreen/OrderScreen.kt @@ -1,15 +1,11 @@ package com.example.android_programming.Screens.OrderScreen -import android.widget.ScrollView import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -20,7 +16,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.Button -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.TextField import androidx.compose.runtime.Composable diff --git a/app/src/main/java/com/example/android_programming/SneakerItem.kt b/app/src/main/java/com/example/android_programming/SneakerItem.kt index 908fff8..f5aa84c 100644 --- a/app/src/main/java/com/example/android_programming/SneakerItem.kt +++ b/app/src/main/java/com/example/android_programming/SneakerItem.kt @@ -1,7 +1,61 @@ package com.example.android_programming +import android.os.Parcel +import android.os.Parcelable + + data class SneakerItem( val imageId: Int, - val name: String, + val name: String?, val price: Double -) \ No newline at end of file +) : Parcelable { + constructor(parcel: Parcel) : this( + parcel.readInt(), + parcel.readString(), + parcel.readDouble() + ) { + } + + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeInt(imageId) + parcel.writeString(name) + parcel.writeDouble(price) + } + + override fun describeContents(): Int { + return 0 + } + + companion object CREATOR : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): SneakerItem { + return SneakerItem(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } +} + +fun getSneakers(): List { + return listOf( + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.trash, "Nike", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + SneakerItem(R.drawable.sneaker, "Jordan", 159.99), + ) +} diff --git a/app/src/main/res/drawable/change.png b/app/src/main/res/drawable/change.png new file mode 100644 index 0000000000000000000000000000000000000000..452b6502de2a8041c8e348674fd9de3ce1e30b63 GIT binary patch literal 528 zcmV+r0`L8aP)%^!?%z}J{k{GyyBgPAlh$S81a!5rEK+qDJ)vk6fHrqT#awj{lV!^i9Rl9#X ze23n|#eVVzsxjCW`|rdO^y8I{eN_<3PHY#s=fJ@e}M^;-n&#_=|F3na|ee`zJI;iV6IzmPaNRm8aO%%V|bfoZ)-4uR@b| z^d5e3K5QfORW|23bQmde@x~%Ee+9Qre-r$I+~thzALuDa(FvWq++zqGXYd0phu-qZ S$j)T|0000f2n)ZH zB8QVAi<1I}lf)H)Qws!`4kik4v;}ai6}c+ueyiAO>g0E4e%~y&>i??#(oXU0lxL^U z+%~;=GBUT)wmrM5HSq1hs%0knpBq`Lw?@vIaadVrn(@k*`N;v*%jV5!UhH*Kx#QP* z{;T_UeLZ4w{&#@dpN{^>9ENYKGhNwlh^L6jCd5yOENQ59eA_gqx#-D;DfA}w^jTy6 zOuV|!f9m!NVsAq1OzylowEL9N{>rME^7#uti8q}x`X4D`zvtb@S#FF000000 #FFFFFFFF #F4F4F4 + #3660F6 \ No newline at end of file