Feature: complete full task
This commit is contained in:
parent
2438628a56
commit
7d44afcf11
17
.idea/deploymentTargetDropDown.xml
Normal file
17
.idea/deploymentTargetDropDown.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\Admin\.android\avd\Pixel_7_Pro_API_30.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-10-12T15:08:00.916663800Z" />
|
||||
</component>
|
||||
</project>
|
@ -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")
|
||||
}
|
@ -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) }
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
@ -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
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
@ -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))
|
||||
}*/
|
@ -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)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
@ -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()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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))
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
)
|
||||
) : 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<SneakerItem> {
|
||||
override fun createFromParcel(parcel: Parcel): SneakerItem {
|
||||
return SneakerItem(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<SneakerItem?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getSneakers(): List<SneakerItem> {
|
||||
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),
|
||||
)
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable/change.png
Normal file
BIN
app/src/main/res/drawable/change.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 528 B |
BIN
app/src/main/res/drawable/trash.png
Normal file
BIN
app/src/main/res/drawable/trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 399 B |
@ -8,4 +8,5 @@
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="figma">#F4F4F4</color>
|
||||
<color name="figma_blue">#3660F6</color>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user