Merge 74007b5979dc09f882603bda27e1edcd9af29a8f into 7d44afcf1166d759797624e4f2af25bcf420666c
2
.idea/compiler.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="17" />
|
<bytecodeTargetLevel target="19" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/gradle.xml
generated
@ -8,7 +8,7 @@
|
|||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleHome" value="$PROJECT_DIR$/../../../../Gradle/gradle-8.3" />
|
<option name="gradleHome" value="$PROJECT_DIR$/../../../../Gradle/gradle-8.3" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="19" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
2
.idea/misc.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
|
id ("kotlin-kapt")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@ -30,11 +31,11 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_19
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_19
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "19"
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
@ -48,7 +49,7 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
apply(plugin = "kotlin-kapt")
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation("androidx.core:core-ktx:1.12.0")
|
implementation("androidx.core:core-ktx:1.12.0")
|
||||||
@ -71,6 +72,15 @@ dependencies {
|
|||||||
implementation ("androidx.fragment:fragment-ktx:1.6.1")
|
implementation ("androidx.fragment:fragment-ktx:1.6.1")
|
||||||
implementation ("io.coil-kt:coil-compose:1.4.0")
|
implementation ("io.coil-kt:coil-compose:1.4.0")
|
||||||
implementation ("com.google.code.gson:gson:2.8.8")
|
implementation ("com.google.code.gson:gson:2.8.8")
|
||||||
|
|
||||||
implementation("androidx.navigation:navigation-compose:2.7.4")
|
implementation("androidx.navigation:navigation-compose:2.7.4")
|
||||||
|
implementation ("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0-alpha02")
|
||||||
|
|
||||||
|
|
||||||
|
//ROOM
|
||||||
|
val room_version = "2.5.2"
|
||||||
|
implementation("androidx.room:room-runtime:$room_version")
|
||||||
|
annotationProcessor("androidx.room:room-compiler:$room_version")
|
||||||
|
kapt("androidx.room:room-compiler:$room_version")
|
||||||
|
implementation("androidx.room:room-ktx:$room_version")
|
||||||
|
implementation("androidx.room:room-paging:$room_version")
|
||||||
}
|
}
|
@ -3,6 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
android:name=".App"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
19
app/src/main/java/com/example/android_programming/App.kt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.example.android_programming
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import com.example.android_programming.database.AppDatabase
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class App : Application() {
|
||||||
|
val database by lazy { AppDatabase.getInstance(this)}
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
// this.deleteDatabase("my-db")
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
AppDatabase.populateDatabase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,8 +7,9 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import com.example.android_programming.Header.Header
|
import com.example.android_programming.composeui.Header.Header
|
||||||
import com.example.android_programming.Navigation.Navigate
|
import com.example.android_programming.composeui.Navigation.Navigate
|
||||||
|
import com.example.android_programming.model.User
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -22,10 +23,32 @@ class MainActivity : ComponentActivity() {
|
|||||||
@Composable
|
@Composable
|
||||||
fun MainContent() {
|
fun MainContent() {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxSize()
|
||||||
.fillMaxSize()
|
|
||||||
) {
|
) {
|
||||||
Header()
|
Header()
|
||||||
Navigate()
|
Navigate()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GlobalUser private constructor() {
|
||||||
|
private var user: User? = null
|
||||||
|
|
||||||
|
fun setUser(user: User?) {
|
||||||
|
this.user = user
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getUser(): User? {
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var instance: GlobalUser? = null
|
||||||
|
|
||||||
|
fun getInstance(): GlobalUser {
|
||||||
|
return instance ?: synchronized(this) {
|
||||||
|
instance ?: GlobalUser().also { instance = it }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,69 +0,0 @@
|
|||||||
package com.example.android_programming.Navigation
|
|
||||||
|
|
||||||
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
|
|
||||||
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){
|
|
||||||
NavHost(
|
|
||||||
navController = navController,
|
|
||||||
startDestination = NavItem.Home.route
|
|
||||||
){
|
|
||||||
composable(NavItem.Home.route){
|
|
||||||
HomeScreen(navController)
|
|
||||||
}
|
|
||||||
composable(NavItem.Like.route){
|
|
||||||
LikeScreen()
|
|
||||||
}
|
|
||||||
composable(NavItem.Order.route){
|
|
||||||
OrderScreen()
|
|
||||||
}
|
|
||||||
composable(NavItem.Profile.route){
|
|
||||||
ProfileScreen(navController)
|
|
||||||
}
|
|
||||||
composable(NavItem.SignIn.route){
|
|
||||||
LoginScreen()
|
|
||||||
}
|
|
||||||
composable(NavItem.SignUp.route){
|
|
||||||
SignUpScreen()
|
|
||||||
}
|
|
||||||
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,187 +0,0 @@
|
|||||||
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
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))
|
|
||||||
}*/
|
|
@ -1,176 +0,0 @@
|
|||||||
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.HomeScreen.BrandScrollBar
|
|
||||||
|
|
||||||
data class ItemFilterByBrand(
|
|
||||||
val imageId: Int,
|
|
||||||
)
|
|
@ -1,95 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.HomeScreen
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
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.LazyRow
|
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
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.unit.dp
|
|
||||||
import androidx.navigation.NavHostController
|
|
||||||
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(navHostController: NavHostController) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(Color.White)
|
|
||||||
) {
|
|
||||||
Row {
|
|
||||||
// Поле для поиска
|
|
||||||
SearchField(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(20.dp)
|
|
||||||
.clip(RoundedCornerShape(10.dp))
|
|
||||||
) { searchText ->
|
|
||||||
// Обработка введенного текста поиска
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
LazyRow(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(0.dp, 0.dp, 0.dp, 5.dp),
|
|
||||||
|
|
||||||
horizontalArrangement = Arrangement.SpaceEvenly
|
|
||||||
){
|
|
||||||
itemsIndexed(
|
|
||||||
listOf(
|
|
||||||
ItemFilterByBrand(R.drawable.jordan),
|
|
||||||
ItemFilterByBrand(R.drawable.jordan),
|
|
||||||
ItemFilterByBrand(R.drawable.jordan),
|
|
||||||
ItemFilterByBrand(R.drawable.jordan)
|
|
||||||
)
|
|
||||||
){ _, item->
|
|
||||||
ItemRow(item = item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
LazyColumn(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
) {
|
|
||||||
val list = getSneakers()
|
|
||||||
val numColumns = 2
|
|
||||||
val chunkedList = list.chunked(numColumns)
|
|
||||||
|
|
||||||
itemsIndexed(chunkedList) { _, chunkedListItem ->
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.Center,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
) {
|
|
||||||
for (item in chunkedListItem) {
|
|
||||||
CardSneaker(item, navHostController)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.LikeScreen;
|
|
||||||
|
|
||||||
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.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.Modifier
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.example.android_programming.R
|
|
||||||
import com.example.android_programming.SneakerItem
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun LikeScreen() {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(Color.White)
|
|
||||||
){
|
|
||||||
Text(
|
|
||||||
text = "Favorites",
|
|
||||||
style = MaterialTheme.typography.h5,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(10.dp, 10.dp)
|
|
||||||
)
|
|
||||||
Row {
|
|
||||||
LazyColumn(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
) {
|
|
||||||
itemsIndexed(
|
|
||||||
listOf(
|
|
||||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
|
||||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
|
||||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
|
||||||
)
|
|
||||||
){_, item->
|
|
||||||
CardSneakerLike(item = item)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun LikeScreenPreview(){
|
|
||||||
LikeScreen()
|
|
||||||
}
|
|
@ -1,240 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.OrderScreen
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.border
|
|
||||||
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.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
|
||||||
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.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.draw.clip
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.res.colorResource
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
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
|
|
||||||
import com.example.android_programming.R
|
|
||||||
import com.example.android_programming.Screens.LikeScreen.CardSneakerLike
|
|
||||||
import com.example.android_programming.SneakerItem
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun OrderScreen() {
|
|
||||||
|
|
||||||
var address by remember { mutableStateOf("") }
|
|
||||||
var city by remember { mutableStateOf("") }
|
|
||||||
var number by remember { mutableStateOf("") }
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(Color.White)
|
|
||||||
.padding(16.dp),
|
|
||||||
){
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(colorResource(id = R.color.figma)),
|
|
||||||
horizontalArrangement = Arrangement.Center
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(16.dp),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
|
|
||||||
) {
|
|
||||||
Text(text = "Delivery Address", fontSize = 24.sp, fontWeight = FontWeight.Bold)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = address,
|
|
||||||
onValueChange = { address = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
|
||||||
singleLine = true,
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = "Address",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = city,
|
|
||||||
onValueChange = { city = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
|
||||||
singleLine = true,
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = "City",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = number,
|
|
||||||
onValueChange = { number = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
|
||||||
singleLine = true,
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = "Number",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row {
|
|
||||||
LazyColumn {
|
|
||||||
itemsIndexed(
|
|
||||||
listOf(
|
|
||||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
|
||||||
)
|
|
||||||
){_, item->
|
|
||||||
CardSneakerLike(item = item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(colorResource(id = R.color.figma)),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
){
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
horizontalArrangement = Arrangement.Start
|
|
||||||
){
|
|
||||||
Text(text = "Sub total", fontSize = 15.sp)
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
horizontalArrangement = Arrangement.End
|
|
||||||
){
|
|
||||||
Text(text = "319.99 $", fontSize = 15.sp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(colorResource(id = R.color.figma)),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
){
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
horizontalArrangement = Arrangement.Start
|
|
||||||
){
|
|
||||||
Text(text = "Taxes", fontSize = 15.sp)
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
horizontalArrangement = Arrangement.End
|
|
||||||
){
|
|
||||||
Text(text = "180 $", fontSize = 15.sp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(colorResource(id = R.color.figma)),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
){
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
horizontalArrangement = Arrangement.Start
|
|
||||||
){
|
|
||||||
Text(text = "Total", fontSize = 15.sp)
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
horizontalArrangement = Arrangement.End
|
|
||||||
){
|
|
||||||
Text(text = "1900 $", fontSize = 15.sp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
) {
|
|
||||||
Text("Confirm order")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun OrderScreenPreview(){
|
|
||||||
OrderScreen()
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.ProfileScreen.Profile
|
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Spacer
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
|
||||||
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.painterResource
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import com.example.android_programming.R
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun Person() {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.background(Color.White)
|
|
||||||
.fillMaxSize()
|
|
||||||
.padding(16.dp),
|
|
||||||
verticalArrangement = Arrangement.Top,
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
Image(
|
|
||||||
contentScale = ContentScale.FillBounds,
|
|
||||||
painter = painterResource(id = R.drawable.shailushai),
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.size(120.dp)
|
|
||||||
.clip(CircleShape)
|
|
||||||
.border(2.dp, Color.Gray, CircleShape)
|
|
||||||
.background(Color.Gray)
|
|
||||||
.padding(8.dp)
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = "Шайлушай",
|
|
||||||
fontSize = 18.sp,
|
|
||||||
fontWeight = FontWeight.Bold
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = "shailushai@example.com",
|
|
||||||
fontSize = 16.sp,
|
|
||||||
color = Color.Gray
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Preview
|
|
||||||
@Composable
|
|
||||||
fun PersonPreview(){
|
|
||||||
Person()
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.ProfileScreen.Profile;
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
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.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.requiredSize
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.material.Button
|
|
||||||
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.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.navigation.NavHostController
|
|
||||||
import androidx.navigation.compose.rememberNavController
|
|
||||||
import com.example.android_programming.Navigation.NavController
|
|
||||||
import com.example.android_programming.Screens.ProfileScreen.SignIn.LoginScreen
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun ProfileScreen(navController: NavHostController) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(Color.White),
|
|
||||||
verticalArrangement = Arrangement.Center,
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
){
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
){
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
navController.navigate("person")
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.requiredSize(300.dp, 40.dp)
|
|
||||||
) {
|
|
||||||
Text(text = "Profile")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
){
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
navController.navigate("login")
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.requiredSize(300.dp, 40.dp)
|
|
||||||
) {
|
|
||||||
Text(text = "Sign In")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
){
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
navController.navigate("signup")
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.requiredSize(300.dp, 40.dp)
|
|
||||||
) {
|
|
||||||
Text(text = "Sign Up")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun ProfileScreenPreview(){
|
|
||||||
val navController = rememberNavController()
|
|
||||||
ProfileScreen(navController = navController)
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.ProfileScreen.SignIn
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.layout.*
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.foundation.text.BasicTextField
|
|
||||||
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.runtime.*
|
|
||||||
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.input.pointer.PointerIcon.Companion.Text
|
|
||||||
import androidx.compose.ui.res.colorResource
|
|
||||||
import androidx.compose.ui.semantics.SemanticsProperties.Text
|
|
||||||
import androidx.compose.ui.text.Placeholder
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import androidx.navigation.NavController
|
|
||||||
import androidx.navigation.NavHostController
|
|
||||||
import com.example.android_programming.R
|
|
||||||
import androidx.compose.material.Text as Text1
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun LoginScreen() {
|
|
||||||
var username by remember { mutableStateOf("") }
|
|
||||||
var password by remember { mutableStateOf("") }
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.clip(RoundedCornerShape(25.dp))
|
|
||||||
.background(colorResource(id = R.color.figma))
|
|
||||||
.padding(15.dp, 0.dp)
|
|
||||||
,
|
|
||||||
verticalArrangement = Arrangement.Center,
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
Text1(text = "Sign In", fontSize = 24.sp, fontWeight = FontWeight.Bold)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
BasicTextField(
|
|
||||||
value = username,
|
|
||||||
onValueChange = { username = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.padding(8.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp))
|
|
||||||
.padding(8.dp),
|
|
||||||
singleLine = true,
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
BasicTextField(
|
|
||||||
value = password,
|
|
||||||
onValueChange = { password = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.padding(8.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp))
|
|
||||||
.padding(8.dp),
|
|
||||||
singleLine = true,
|
|
||||||
visualTransformation = PasswordVisualTransformation(),
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(8.dp, 0.dp, 8.dp, 0.dp)
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
) {
|
|
||||||
Text1("Sign In")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun performLogin(username: String, password: String) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun SignInScreen(){
|
|
||||||
LoginScreen()
|
|
||||||
}
|
|
@ -1,222 +0,0 @@
|
|||||||
package com.example.android_programming.Screens.ProfileScreen.SignUp
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
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.BasicTextField
|
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
|
||||||
import androidx.compose.material.Button
|
|
||||||
import androidx.compose.material.DropdownMenu
|
|
||||||
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.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.draw.clip
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.res.colorResource
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import com.example.android_programming.Screens.ProfileScreen.SignIn.LoginScreen
|
|
||||||
import com.example.android_programming.R
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun SignUpScreen() {
|
|
||||||
var username by remember { mutableStateOf("") }
|
|
||||||
var password by remember { mutableStateOf("") }
|
|
||||||
var sex by remember { mutableStateOf("") }
|
|
||||||
var name by remember { mutableStateOf("") }
|
|
||||||
var surname by remember { mutableStateOf("") }
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.clip(RoundedCornerShape(25.dp))
|
|
||||||
.background(colorResource(id = R.color.figma))
|
|
||||||
.padding(15.dp, 0.dp)
|
|
||||||
,
|
|
||||||
verticalArrangement = Arrangement.Center,
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
Text(text = "Sign Up", fontSize = 24.sp, fontWeight = FontWeight.Bold)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = username,
|
|
||||||
onValueChange = { username = 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 = "Username",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = name,
|
|
||||||
onValueChange = { name = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
|
||||||
singleLine = true,
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = "Name",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = surname,
|
|
||||||
onValueChange = { surname = 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 = "Surname",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = sex,
|
|
||||||
onValueChange = { sex = 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 = "Sex",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
value = password,
|
|
||||||
onValueChange = { password = it },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(50.dp)
|
|
||||||
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp))
|
|
||||||
.padding(0.dp),
|
|
||||||
singleLine = true,
|
|
||||||
visualTransformation = PasswordVisualTransformation(),
|
|
||||||
keyboardOptions = KeyboardOptions(
|
|
||||||
keyboardType = KeyboardType.Text,
|
|
||||||
imeAction = ImeAction.Next
|
|
||||||
),
|
|
||||||
|
|
||||||
keyboardActions = KeyboardActions(
|
|
||||||
onNext = {
|
|
||||||
|
|
||||||
}
|
|
||||||
),
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = "Password",
|
|
||||||
style = TextStyle(fontSize = 12.sp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
) {
|
|
||||||
Text("Sign Up")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun SignUpScreenPreview(){
|
|
||||||
SignUpScreen()
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package com.example.android_programming
|
|
||||||
|
|
||||||
import android.os.Parcel
|
|
||||||
import android.os.Parcelable
|
|
||||||
|
|
||||||
|
|
||||||
data class SneakerItem(
|
|
||||||
val imageId: Int,
|
|
||||||
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),
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.android_programming.Header
|
package com.example.android_programming.composeui.Header
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.example.android_programming.composeui.Navigation
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.navigation.compose.NavHost
|
||||||
|
import androidx.navigation.compose.composable
|
||||||
|
import com.example.android_programming.composeui.Screens.AdminPanel.AddPanel
|
||||||
|
import com.example.android_programming.composeui.Screens.AdminPanel.AdminPanel
|
||||||
|
import com.example.android_programming.composeui.Screens.AdminPanel.ChangePanel
|
||||||
|
import com.example.android_programming.composeui.Screens.AdminPanel.ChangeSneaker
|
||||||
|
import com.example.android_programming.composeui.Screens.HomeScreen.AboutSneaker
|
||||||
|
import com.example.android_programming.composeui.Screens.HomeScreen.HomeScreen
|
||||||
|
import com.example.android_programming.composeui.Screens.MyOrderScreen.MyOrderScreen
|
||||||
|
import com.example.android_programming.composeui.Screens.OrderScreen.OrderScreen
|
||||||
|
import com.example.android_programming.composeui.Screens.ProfileScreen.Profile.Person
|
||||||
|
import com.example.android_programming.composeui.Screens.ProfileScreen.Profile.ProfileScreen
|
||||||
|
import com.example.android_programming.composeui.Screens.ProfileScreen.SignIn.LoginScreen
|
||||||
|
import com.example.android_programming.composeui.Screens.ProfileScreen.SignUp.SignUpScreen
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
import com.google.gson.Gson
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun NavController(navController: NavHostController){
|
||||||
|
var orderViewModel: OrderViewModel = viewModel(factory = OrderViewModel.factory)
|
||||||
|
NavHost(
|
||||||
|
navController = navController,
|
||||||
|
startDestination = NavItem.Home.route
|
||||||
|
){
|
||||||
|
composable(NavItem.Home.route){
|
||||||
|
HomeScreen(navController, orderViewModel)
|
||||||
|
}
|
||||||
|
composable(NavItem.MyOrder.route){
|
||||||
|
MyOrderScreen(orderViewModel)
|
||||||
|
}
|
||||||
|
composable(NavItem.Order.route){
|
||||||
|
OrderScreen(orderViewModel, navController)
|
||||||
|
}
|
||||||
|
composable(NavItem.Profile.route){
|
||||||
|
ProfileScreen(navController)
|
||||||
|
}
|
||||||
|
composable(NavItem.SignIn.route){
|
||||||
|
LoginScreen(navController)
|
||||||
|
}
|
||||||
|
composable(NavItem.SignUp.route){
|
||||||
|
SignUpScreen(navController)
|
||||||
|
}
|
||||||
|
composable(NavItem.Person.route){
|
||||||
|
Person(navController)
|
||||||
|
}
|
||||||
|
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, Sneaker::class.java)
|
||||||
|
sneakerItem?.let { AboutSneaker(it, onBackClick = {
|
||||||
|
navController.navigateUp() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
composable(NavItem.ChangeSneaker.route) { backStackEntry ->
|
||||||
|
val sneakerItemString = backStackEntry.arguments?.getString("sneakerItem")
|
||||||
|
val sneakerItem = Gson().fromJson(sneakerItemString, Sneaker::class.java)
|
||||||
|
sneakerItem?.let { ChangeSneaker(it, onBackClick = {
|
||||||
|
navController.navigateUp() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
package com.example.android_programming.Navigation
|
package com.example.android_programming.composeui.Navigation
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Build
|
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.Home
|
||||||
import androidx.compose.material.icons.filled.Person
|
import androidx.compose.material.icons.filled.Person
|
||||||
import androidx.compose.material.icons.filled.ShoppingCart
|
import androidx.compose.material.icons.filled.ShoppingCart
|
||||||
@ -10,7 +9,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
|||||||
|
|
||||||
sealed class NavItem(val route: String, val icon: ImageVector?){
|
sealed class NavItem(val route: String, val icon: ImageVector?){
|
||||||
object Home : NavItem("home", Icons.Default.Home)
|
object Home : NavItem("home", Icons.Default.Home)
|
||||||
object Like : NavItem("like", Icons.Default.Favorite)
|
object MyOrder : NavItem("myorder", null)
|
||||||
object Order : NavItem("order", Icons.Default.ShoppingCart)
|
object Order : NavItem("order", Icons.Default.ShoppingCart)
|
||||||
object Profile : NavItem("profile", Icons.Default.Person)
|
object Profile : NavItem("profile", Icons.Default.Person)
|
||||||
object SignIn : NavItem("login", null)
|
object SignIn : NavItem("login", null)
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.android_programming.Navigation
|
package com.example.android_programming.composeui.Navigation
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@ -13,7 +13,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
@ -21,39 +20,39 @@ import com.example.android_programming.R
|
|||||||
|
|
||||||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
||||||
@Composable
|
@Composable
|
||||||
fun Navigate(){
|
fun Navigate() {
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
val listItem = listOf(
|
|
||||||
|
val Items = listOf(
|
||||||
NavItem.Home,
|
NavItem.Home,
|
||||||
NavItem.Like,
|
|
||||||
NavItem.Order,
|
NavItem.Order,
|
||||||
NavItem.Profile,
|
NavItem.Profile,
|
||||||
NavItem.AdminPanel,
|
NavItem.AdminPanel,
|
||||||
)
|
)
|
||||||
|
|
||||||
Scaffold(bottomBar = {
|
Scaffold(bottomBar = {
|
||||||
|
// Оставьте код навигационного бара без изменений
|
||||||
BottomNavigation(
|
BottomNavigation(
|
||||||
backgroundColor = Color.White
|
backgroundColor = Color.White
|
||||||
) {
|
) {
|
||||||
val navBackStackEntry = navController.currentBackStackEntryAsState()
|
val navBackStackEntry = navController.currentBackStackEntryAsState()
|
||||||
val currentState = navBackStackEntry.value
|
val currentState = navBackStackEntry.value
|
||||||
|
|
||||||
listItem.forEach { it ->
|
Items.forEach { it ->
|
||||||
val isSelected = currentState?.destination?.route == it.route
|
val isSelected = currentState?.destination?.route == it.route
|
||||||
|
|
||||||
BottomNavigationItem(
|
BottomNavigationItem(
|
||||||
selected = isSelected,
|
selected = isSelected,
|
||||||
onClick = {
|
onClick = {
|
||||||
if(!isSelected){
|
if (!isSelected) {
|
||||||
navController.graph.startDestinationRoute?.let {
|
navController.graph.startDestinationRoute?.let {
|
||||||
navController.popBackStack(it, inclusive = true)
|
navController.popBackStack(it, inclusive = true)
|
||||||
}
|
}
|
||||||
navController.navigate(it.route){
|
navController.navigate(it.route) {
|
||||||
launchSingleTop
|
launchSingleTop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
navController.navigate(it.route)
|
navController.navigate(it.route)
|
||||||
|
|
||||||
},
|
},
|
||||||
icon = {
|
icon = {
|
||||||
val iconModifier = if (isSelected) {
|
val iconModifier = if (isSelected) {
|
||||||
@ -68,6 +67,7 @@ fun Navigate(){
|
|||||||
Icon(
|
Icon(
|
||||||
imageVector = it1,
|
imageVector = it1,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
|
tint = if (isSelected) Color.White else Color.Unspecified,
|
||||||
modifier = iconModifier.then(Modifier.size(24.dp))
|
modifier = iconModifier.then(Modifier.size(24.dp))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -79,9 +79,3 @@ fun Navigate(){
|
|||||||
NavController(navController = navController)
|
NavController(navController = navController)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun NavigatePreview(){
|
|
||||||
Navigate()
|
|
||||||
}
|
|
@ -0,0 +1,205 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.AdminPanel
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextField
|
||||||
|
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.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 androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.model.PhotoManager
|
||||||
|
import com.example.android_programming.vmodel.SneakerViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddPanel(sneakerViewModel: SneakerViewModel = viewModel(factory = SneakerViewModel.factory)){
|
||||||
|
val photoManager = PhotoManager()
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(id = sneakerViewModel.photo.value),
|
||||||
|
contentDescription = "image",
|
||||||
|
contentScale = ContentScale.FillHeight,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.height(200.dp)
|
||||||
|
)
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
sneakerViewModel.photo.value = photoManager.changePhoto(sneakerViewModel.photo.value)
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 0.dp, 16.dp, 16.dp)
|
||||||
|
) {
|
||||||
|
Text("Add image")
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = sneakerViewModel.brand.value,
|
||||||
|
onValueChange = { sneakerViewModel.brand.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.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 = sneakerViewModel.model.value,
|
||||||
|
onValueChange = { sneakerViewModel.model.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.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 = sneakerViewModel.description.value,
|
||||||
|
onValueChange = { sneakerViewModel.description.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(150.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.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 = sneakerViewModel.price.value,
|
||||||
|
onValueChange = { sneakerViewModel.price.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Price",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
sneakerViewModel.insertSneaker()
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text("Add sneaker")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.example.android_programming.composeui.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.AlertDialog
|
||||||
|
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.graphics.Color
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.model.RoleEnum
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AdminPanel(navHostController: NavHostController) {
|
||||||
|
var isAddPanelVisible by remember { mutableStateOf(false) }
|
||||||
|
var isChangePanelVisible by remember { mutableStateOf(false) }
|
||||||
|
var showDialog by remember { mutableStateOf(GlobalUser.getInstance().getUser()?.role == RoleEnum.User || GlobalUser.getInstance().getUser()?.role == null) }
|
||||||
|
if (!showDialog) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White)
|
||||||
|
.padding(bottom = 50.dp)
|
||||||
|
) {
|
||||||
|
ButtonAdmin(
|
||||||
|
onAddClick = {
|
||||||
|
isAddPanelVisible = true
|
||||||
|
isChangePanelVisible = false
|
||||||
|
},
|
||||||
|
onChangeClick = {
|
||||||
|
isChangePanelVisible = true
|
||||||
|
isAddPanelVisible = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAddPanelVisible) {
|
||||||
|
AddPanel()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isChangePanelVisible) {
|
||||||
|
ChangePanel(navHostController)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (showDialog) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = { showDialog = false },
|
||||||
|
title = {
|
||||||
|
Text("Access denied")
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text("You are not admin")
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
Button(
|
||||||
|
onClick = { navHostController.navigate("home") }
|
||||||
|
) {
|
||||||
|
Text("OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +1,35 @@
|
|||||||
package com.example.android_programming.Screens.AdminPanel
|
package com.example.android_programming.composeui.Screens.AdminPanel
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
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.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.navigation.NavHostController
|
import com.example.android_programming.R
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ButtonAdmin(onAddClick: () -> Unit, onChangeClick: () -> Unit) {
|
fun ButtonAdmin(onAddClick: () -> Unit, onChangeClick: () -> Unit) {
|
||||||
Row(){
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 16.dp, 16.dp, 0.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
){
|
||||||
Button(
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
onClick = {
|
onClick = {
|
||||||
onAddClick()
|
onAddClick()
|
||||||
},
|
},
|
||||||
@ -31,6 +41,10 @@ fun ButtonAdmin(onAddClick: () -> Unit, onChangeClick: () -> Unit) {
|
|||||||
Text("Add")
|
Text("Add")
|
||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
onClick = {
|
onClick = {
|
||||||
onChangeClick()
|
onChangeClick()
|
||||||
},
|
},
|
||||||
@ -42,4 +56,5 @@ fun ButtonAdmin(onAddClick: () -> Unit, onChangeClick: () -> Unit) {
|
|||||||
Text("Change/Del")
|
Text("Change/Del")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.AdminPanel
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
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.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Create
|
||||||
|
import androidx.compose.material.icons.filled.Delete
|
||||||
|
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.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.SneakerViewModel
|
||||||
|
import com.google.gson.Gson
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CardSneakerForChange(item: Sneaker, navController: NavHostController, sneakerViewModel: SneakerViewModel = viewModel(factory = SneakerViewModel.factory)) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(0.dp, 0.dp, 0.dp, 16.dp)
|
||||||
|
.clip(RoundedCornerShape(10.dp))
|
||||||
|
.background(colorResource(id = R.color.figma)),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(id = item.photo),
|
||||||
|
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.brand?.let { Text(text = it, fontSize = 20.sp) }
|
||||||
|
Text(text = "${item.price} $", color = Color.Red, fontSize = 16.sp)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
sneakerViewModel.brand.value = item.brand ?: ""
|
||||||
|
sneakerViewModel.model.value = item.model ?: ""
|
||||||
|
sneakerViewModel.description.value = item.description ?: ""
|
||||||
|
sneakerViewModel.price.value = item.price.toString()
|
||||||
|
val sneakerItemString = Gson().toJson(item)
|
||||||
|
navController.navigate("changeSneaker/${sneakerItemString}") },
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(end = 16.dp)
|
||||||
|
) {
|
||||||
|
Icon(imageVector = Icons.Default.Create, contentDescription = "change")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
sneakerViewModel.deleteSneaker(item)
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(end = 16.dp)
|
||||||
|
) {
|
||||||
|
Icon(imageVector = Icons.Default.Delete, contentDescription = "delete")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +1,38 @@
|
|||||||
package com.example.android_programming.Screens.AdminPanel
|
package com.example.android_programming.composeui.Screens.AdminPanel
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import com.example.android_programming.R
|
import com.example.android_programming.vmodel.SneakerViewModel
|
||||||
import com.example.android_programming.SneakerItem
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChangePanel(navHostController: NavHostController) {
|
fun ChangePanel(navHostController: NavHostController, sneakerViewModel: SneakerViewModel = viewModel(factory = SneakerViewModel.factory)) {
|
||||||
|
val list = sneakerViewModel.SneakerList.collectAsState(initial = emptyList()).value
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(Color.White)
|
.background(Color.White)
|
||||||
|
.padding(16.dp)
|
||||||
){
|
){
|
||||||
Row {
|
Row {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
itemsIndexed(
|
itemsIndexed(list
|
||||||
listOf(
|
|
||||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
|
||||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
|
||||||
SneakerItem(R.drawable.trash, "Nike", 179.99),
|
|
||||||
)
|
|
||||||
){_, item->
|
){_, item->
|
||||||
CardSneakerForChange(item = item, navHostController)
|
CardSneakerForChange(item = item, navHostController)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,241 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.AdminPanel
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextField
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
|
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.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.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 androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.model.PhotoManager
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.SneakerViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ChangeSneaker(sneaker: Sneaker, onBackClick: () -> Unit, sneakerViewModel: SneakerViewModel = viewModel(factory = SneakerViewModel.factory)) {
|
||||||
|
val brand = remember {mutableStateOf(sneaker.brand)}
|
||||||
|
val model = remember{mutableStateOf(sneaker.model)}
|
||||||
|
val description = remember{mutableStateOf(sneaker.description)}
|
||||||
|
val price = remember{mutableStateOf(sneaker.price.toString())}
|
||||||
|
var photo by remember { mutableStateOf(sneaker.photo) }
|
||||||
|
val photoManager = PhotoManager()
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 16.dp, 16.dp, 50.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick = onBackClick,
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.white),
|
||||||
|
contentColor = Color.Black
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.ArrowBack,
|
||||||
|
contentDescription = "Back",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Image(
|
||||||
|
painter = painterResource(id = photo),
|
||||||
|
contentDescription = "image",
|
||||||
|
contentScale = ContentScale.FillHeight,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.height(200.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
photo = photoManager.changePhoto(photo)
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 0.dp, 16.dp, 16.dp)
|
||||||
|
) {
|
||||||
|
Text("Change image")
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = brand.value,
|
||||||
|
onValueChange = { newValue -> brand.value = newValue },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.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.value,
|
||||||
|
onValueChange = { model.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.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.value,
|
||||||
|
onValueChange = { description.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(150.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.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.value,
|
||||||
|
onValueChange = { price.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Price",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
sneakerViewModel.UpdateSneaker(
|
||||||
|
Sneaker(
|
||||||
|
sneakerId = sneaker.sneakerId,
|
||||||
|
brand = brand.value,
|
||||||
|
model = model.value,
|
||||||
|
description = description.value,
|
||||||
|
photo = photo,
|
||||||
|
price = price.value.toDouble()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
onBackClick()
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text("Save")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.HomeScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
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.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
|
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.layout.ContentScale
|
||||||
|
import androidx.compose.ui.res.colorResource
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AboutSneaker(sneaker: Sneaker, onBackClick: () -> Unit) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White)
|
||||||
|
.padding(20.dp)
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick = onBackClick,
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.white),
|
||||||
|
contentColor = Color.Black
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.ArrowBack,
|
||||||
|
contentDescription = "Back",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Image(
|
||||||
|
painter = painterResource(id = sneaker.photo),
|
||||||
|
contentDescription = "image",
|
||||||
|
contentScale = ContentScale.FillWidth,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(300.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "${sneaker.brand}",
|
||||||
|
fontSize = 25.sp,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "${sneaker.model}",
|
||||||
|
fontSize = 25.sp,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
Text(text = "Price: $${sneaker.price}", fontSize = 16.sp)
|
||||||
|
Text(text = "Description: ${sneaker.description}", fontSize = 16.sp)
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clip(RoundedCornerShape(20.dp))
|
||||||
|
) {
|
||||||
|
Text("Add to cart")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.HomeScreen.FilterByBrand
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.lazy.LazyRow
|
||||||
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.example.android_programming.R
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun FilterByBrand() {
|
||||||
|
Row {
|
||||||
|
LazyRow(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(0.dp, 10.dp, 0.dp, 5.dp),
|
||||||
|
|
||||||
|
horizontalArrangement = Arrangement.SpaceEvenly
|
||||||
|
){
|
||||||
|
itemsIndexed(
|
||||||
|
listOf(
|
||||||
|
ItemFilterByBrand(R.drawable.jordan),
|
||||||
|
ItemFilterByBrand(R.drawable.jordan),
|
||||||
|
ItemFilterByBrand(R.drawable.jordan),
|
||||||
|
ItemFilterByBrand(R.drawable.jordan)
|
||||||
|
)
|
||||||
|
){ _, item->
|
||||||
|
ItemRow(item = item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.HomeScreen.FilterByBrand
|
||||||
|
|
||||||
|
data class ItemFilterByBrand(
|
||||||
|
val imageId: Int,
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.android_programming.Screens.HomeScreen.BrandScrollBar
|
package com.example.android_programming.composeui.Screens.HomeScreen.FilterByBrand
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@ -10,7 +10,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.HomeScreen
|
||||||
|
|
||||||
|
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.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.composeui.Screens.HomeScreen.FilterByBrand.FilterByBrand
|
||||||
|
import com.example.android_programming.composeui.Screens.HomeScreen.SearchField.SearchField
|
||||||
|
import com.example.android_programming.composeui.Screens.HomeScreen.SneakerRecyclerView.RecyclerView
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HomeScreen(navHostController: NavHostController, orderViewModel: OrderViewModel) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val sneakers = remember { mutableStateListOf<Sneaker>() }
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White)
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
) {
|
||||||
|
Row {
|
||||||
|
// Поле для поиска
|
||||||
|
SearchField(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(20.dp, 20.dp, 20.dp, 10.dp)
|
||||||
|
.clip(RoundedCornerShape(10.dp))
|
||||||
|
) { searchText ->
|
||||||
|
// Обработка введенного текста поиска
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sales()
|
||||||
|
FilterByBrand()
|
||||||
|
RecyclerView(navHostController = navHostController, orderViewModel)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.HomeScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
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.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.example.android_programming.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@Preview
|
||||||
|
fun Sales() {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
){
|
||||||
|
Image(
|
||||||
|
painter = painterResource(id = R.drawable.sales),
|
||||||
|
contentDescription = "image",
|
||||||
|
contentScale = ContentScale.FillWidth,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.android_programming.Screens.HomeScreen.SearchField;
|
package com.example.android_programming.composeui.Screens.HomeScreen.SearchField;
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@ -10,7 +10,7 @@ import androidx.compose.foundation.text.BasicTextField
|
|||||||
import androidx.compose.material.Icon
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Search
|
import androidx.compose.material.icons.filled.Search
|
||||||
import androidx.compose.runtime.Composable;
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.android_programming.Screens.HomeScreen.SneakerRecyclerView
|
package com.example.android_programming.composeui.Screens.HomeScreen.SneakerRecyclerView
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@ -7,15 +7,16 @@ import androidx.compose.foundation.layout.Arrangement
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
import androidx.compose.material.ButtonColors
|
|
||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ShoppingCart
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -25,19 +26,14 @@ import androidx.compose.ui.layout.ContentScale
|
|||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.rememberNavController
|
|
||||||
import com.example.android_programming.R
|
import com.example.android_programming.R
|
||||||
import com.example.android_programming.Screens.HomeScreen.AboutSneaker
|
import com.example.android_programming.model.Sneaker
|
||||||
import com.example.android_programming.SneakerItem
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CardSneaker(item: SneakerItem, navController: NavHostController) {
|
fun CardSneaker(item: Sneaker, navController: NavHostController, selectedItems: List<Sneaker>, onItemSelected: (Sneaker) -> Unit) {
|
||||||
val maxWidth = (LocalConfiguration.current.screenWidthDp / 2).dp
|
val maxWidth = (LocalConfiguration.current.screenWidthDp / 2).dp
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
@ -57,7 +53,7 @@ fun CardSneaker(item: SneakerItem, navController: NavHostController) {
|
|||||||
.widthIn(maxWidth)
|
.widthIn(maxWidth)
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(id = item.imageId),
|
painter = painterResource(id = item.photo),
|
||||||
contentDescription = "image",
|
contentDescription = "image",
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = ContentScale.FillWidth,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -75,7 +71,10 @@ fun CardSneaker(item: SneakerItem, navController: NavHostController) {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(10.dp, 0.dp)
|
.padding(10.dp, 0.dp)
|
||||||
) {
|
) {
|
||||||
item.name?.let { Text(text = it) }
|
Row {
|
||||||
|
item.brand?.let { Text(text = "$it ") }
|
||||||
|
item.model?.let { Text(text = it) }
|
||||||
|
}
|
||||||
Text(text = item.price.toString(), color = Color.Red)
|
Text(text = item.price.toString(), color = Color.Red)
|
||||||
}
|
}
|
||||||
Column(
|
Column(
|
||||||
@ -83,11 +82,21 @@ fun CardSneaker(item: SneakerItem, navController: NavHostController) {
|
|||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
onClick = { /*TODO*/ },
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
onItemSelected(item)
|
||||||
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(40.dp, 20.dp)
|
.size(50.dp, 30.dp)
|
||||||
|
.clip(RoundedCornerShape(10.dp))
|
||||||
) {
|
) {
|
||||||
Text(text = "+", fontSize = 4.sp)
|
Icon(
|
||||||
|
imageVector = Icons.Default.ShoppingCart,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.HomeScreen.SneakerRecyclerView
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
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.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
import com.example.android_programming.vmodel.SneakerViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RecyclerView(navHostController : NavHostController, orderViewModel: OrderViewModel, sneakerViewModel: SneakerViewModel = viewModel(factory = SneakerViewModel.factory)) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(bottom = 60.dp)
|
||||||
|
) {
|
||||||
|
val list = sneakerViewModel.SneakerList.collectAsState(initial = emptyList()).value
|
||||||
|
val numColumns = 2
|
||||||
|
val chunkedList = list.chunked(numColumns)
|
||||||
|
|
||||||
|
for (chunkedListItem in chunkedList) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
for (item in chunkedListItem) {
|
||||||
|
CardSneaker(item, navHostController, orderViewModel.selectedItems) { selectedItem ->
|
||||||
|
orderViewModel.addSelectedItem(selectedItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.MyOrderScreen
|
||||||
|
|
||||||
|
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.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.MaterialTheme
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.model.Order
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun MyOrderScreen(orderViewModel: OrderViewModel) {
|
||||||
|
val userWithOrder by orderViewModel.database.userDao().getUserOrders(GlobalUser.getInstance().getUser()?.userId!!).collectAsState(null)
|
||||||
|
|
||||||
|
val orderList: List<Order>? = userWithOrder?.orders
|
||||||
|
println()
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(bottom = 50.dp)
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White)
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
|
||||||
|
){
|
||||||
|
Text(
|
||||||
|
text = "My order",
|
||||||
|
style = MaterialTheme.typography.h5,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp, 10.dp)
|
||||||
|
)
|
||||||
|
Row {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
) {
|
||||||
|
if (orderList != null) {
|
||||||
|
for (item in orderList) {
|
||||||
|
OrderCard(item, orderViewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.MyOrderScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
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.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
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.unit.dp
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.model.Order
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OrderCard(order: Order, orderViewModel: OrderViewModel){
|
||||||
|
|
||||||
|
val SneakerList = order.orderId?.let {
|
||||||
|
orderViewModel.database.orderDao().getOrderWithSneakers(
|
||||||
|
it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val sneakerWithOrder by SneakerList!!.collectAsState(null)
|
||||||
|
|
||||||
|
val sneakerList: List<Sneaker>? = sneakerWithOrder?.sneakers
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 16.dp, 16.dp, 0.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
){
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
){
|
||||||
|
Text("№ ${order.orderId}")
|
||||||
|
Text("${Date(order.date)}")
|
||||||
|
Row(){
|
||||||
|
if (sneakerList != null) {
|
||||||
|
for(sneaker in sneakerList){
|
||||||
|
Image(
|
||||||
|
contentScale = ContentScale.FillBounds,
|
||||||
|
painter = painterResource(id = sneaker.photo),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(70.dp)
|
||||||
|
.padding(0.dp, 10.dp, 10.dp, 10.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
orderViewModel.deleteOrder(order)
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 16.dp, 16.dp, 0.dp)
|
||||||
|
) {
|
||||||
|
Text("Cancel")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.android_programming.Screens.LikeScreen
|
package com.example.android_programming.composeui.Screens.OrderScreen
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@ -10,7 +10,11 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Delete
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -19,25 +23,25 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.example.android_programming.R
|
import com.example.android_programming.R
|
||||||
import com.example.android_programming.SneakerItem
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CardSneakerLike(item: SneakerItem) {
|
fun CardSneakerLike(item: Sneaker, orderViewModel: OrderViewModel) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(10.dp)
|
.padding(16.dp, 5.dp)
|
||||||
.clip(RoundedCornerShape(10.dp))
|
.clip(RoundedCornerShape(10.dp))
|
||||||
.background(colorResource(id = R.color.figma)),
|
.background(colorResource(id = R.color.figma)),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(id = item.imageId),
|
painter = painterResource(id = item.photo),
|
||||||
contentDescription = "image",
|
contentDescription = "image",
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = ContentScale.FillWidth,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -51,25 +55,22 @@ fun CardSneakerLike(item: SneakerItem) {
|
|||||||
.weight(1f)
|
.weight(1f)
|
||||||
.padding(start = 16.dp)
|
.padding(start = 16.dp)
|
||||||
) {
|
) {
|
||||||
item.name?.let { Text(text = it, fontSize = 20.sp) }
|
item.brand?.let { Text(text = it, fontSize = 20.sp) }
|
||||||
Text(text = "${item.price} USD", color = Color.Red, fontSize = 16.sp)
|
Text(text = "${item.price} USD", color = Color.Red, fontSize = 16.sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
onClick = { /*TODO*/ },
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
orderViewModel.removeSelectedItem(item)
|
||||||
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(40.dp, 20.dp)
|
|
||||||
.padding(end = 16.dp)
|
.padding(end = 16.dp)
|
||||||
) {
|
) {
|
||||||
Text(text = "+", fontSize = 4.sp)
|
Icon(imageVector = Icons.Default.Delete, contentDescription = "delete")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun CardSneakerLikePreview(){
|
|
||||||
CardSneakerLike(SneakerItem(R.drawable.sneaker, "Jordan", 159.99))
|
|
||||||
}
|
|
@ -0,0 +1,132 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.OrderScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.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.Text
|
||||||
|
import androidx.compose.material.TextField
|
||||||
|
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.res.colorResource
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
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.R
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DeliveryAddress(orderViewModel: OrderViewModel) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma)),
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
|
||||||
|
) {
|
||||||
|
Text(text = "Delivery Address", fontSize = 24.sp, fontWeight = FontWeight.Bold)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = orderViewModel.city.value,
|
||||||
|
onValueChange = { orderViewModel.city.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "City",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = orderViewModel.street.value,
|
||||||
|
onValueChange = { orderViewModel.street.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Street",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = orderViewModel.house.value,
|
||||||
|
onValueChange = { orderViewModel.house.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "House",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.OrderScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
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.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OrderScreen(orderViewModel: OrderViewModel, navHostController: NavHostController) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White)
|
||||||
|
.padding(bottom = 60.dp)
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
){
|
||||||
|
DeliveryAddress(orderViewModel)
|
||||||
|
ShoppingList(orderViewModel.selectedItems, orderViewModel)
|
||||||
|
SubTotal(orderViewModel)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
if(GlobalUser.getInstance().getUser() != null){
|
||||||
|
orderViewModel.createOrder()
|
||||||
|
navHostController.navigate("home")
|
||||||
|
}else{
|
||||||
|
navHostController.navigate("login")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 0.dp, 16.dp, 16.dp)
|
||||||
|
) {
|
||||||
|
Text("Confirm order")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.OrderScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ShoppingList(list : List<Sneaker>, orderViewModel: OrderViewModel) {
|
||||||
|
Row {
|
||||||
|
Column {
|
||||||
|
for(item in list){
|
||||||
|
CardSneakerLike(item = item, orderViewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.OrderScreen
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
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.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.res.colorResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.vmodel.OrderViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SubTotal(orderViewModel: OrderViewModel) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
){
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp, 5.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
){
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
){
|
||||||
|
Text(text = "Sub total", fontSize = 15.sp)
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.End
|
||||||
|
){
|
||||||
|
Text(text = "${orderViewModel.getSubTotal()} $", fontSize = 15.sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp, 5.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
){
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
){
|
||||||
|
Text(text = "Taxes", fontSize = 15.sp)
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.End
|
||||||
|
){
|
||||||
|
Text(text = "${"%.2f".format(orderViewModel.getSubTotal() * 0.05)} $", fontSize = 15.sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp, 5.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
){
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
){
|
||||||
|
Text(text = "Total", fontSize = 15.sp)
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.End
|
||||||
|
){
|
||||||
|
Text(text = "${"%.2f".format(orderViewModel.getSubTotal() + orderViewModel.getSubTotal() * 0.05)} $", fontSize = 15.sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.Profile
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
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.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Person(navHostController: NavHostController) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(Color.White)
|
||||||
|
.fillMaxSize(),
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
GlobalUser.getInstance().setUser(null)
|
||||||
|
navHostController.navigate("profile")
|
||||||
|
},
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.white),
|
||||||
|
contentColor = Color.Black
|
||||||
|
),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
) {
|
||||||
|
Text("Exit")
|
||||||
|
}
|
||||||
|
ProfileCard(navHostController)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.Profile
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.CircleShape
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
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.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ProfileCard(navHostController: NavHostController) {
|
||||||
|
val globalUser = GlobalUser.getInstance().getUser()
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
){
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
){
|
||||||
|
Image(
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
painter = painterResource(id = R.drawable.shailushai),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(150.dp)
|
||||||
|
.border(2.dp, Color.White, CircleShape)
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(CircleShape)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (globalUser != null) {
|
||||||
|
Text(
|
||||||
|
text = "${globalUser.name} ${globalUser.surname}",
|
||||||
|
fontSize = 18.sp,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = globalUser.email,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
color = Color.Gray
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
navHostController.navigate("myorder")
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 16.dp, 16.dp, 0.dp)
|
||||||
|
) {
|
||||||
|
Text("My order")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.Profile;
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.composeui.Screens.ProfileScreen.SignIn.LoginScreen
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ProfileScreen(navController: NavHostController) {
|
||||||
|
val globalUser: GlobalUser = GlobalUser.getInstance()
|
||||||
|
if(globalUser.getUser() != null){
|
||||||
|
Person(navController)
|
||||||
|
}else{
|
||||||
|
LoginScreen(navController = navController)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@Preview
|
||||||
|
fun ProfileScreenPreview(){
|
||||||
|
val navController = rememberNavController()
|
||||||
|
ProfileScreen(navController = navController)
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.SignIn
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.text.ClickableText
|
||||||
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
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.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.colorResource
|
||||||
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.vmodel.UserViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SignInCard(navController: NavHostController, userViewModel: UserViewModel = viewModel(factory = UserViewModel.factory)) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
){
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
){
|
||||||
|
var isEmailValid by remember { mutableStateOf(true) }
|
||||||
|
var isPasswordValid by remember { mutableStateOf(true) }
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "Sign In",
|
||||||
|
fontSize = 24.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = userViewModel.email.value,
|
||||||
|
onValueChange = {
|
||||||
|
userViewModel.email.value = it
|
||||||
|
isEmailValid = userViewModel.isValidEmail(it)},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Email",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!isEmailValid) {
|
||||||
|
Text(
|
||||||
|
text = "Invalid email format",
|
||||||
|
color = Color.Red,
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = userViewModel.password.value,
|
||||||
|
onValueChange = {
|
||||||
|
userViewModel.password.value = it
|
||||||
|
isPasswordValid = it.isNotEmpty()
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
visualTransformation = PasswordVisualTransformation(),
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Password",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!isPasswordValid) {
|
||||||
|
Text(
|
||||||
|
text = "Password is required",
|
||||||
|
color = Color.Red,
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
userViewModel.authUser()
|
||||||
|
navController.navigate("profile")
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp, 16.dp, 16.dp, 0.dp)
|
||||||
|
) {
|
||||||
|
Text("Sign In")
|
||||||
|
}
|
||||||
|
ClickableText(
|
||||||
|
text = AnnotatedString("You do not have an account? Register!"),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(0.dp, 0.dp, 0.dp, 16.dp),
|
||||||
|
onClick = {
|
||||||
|
navController.navigate("signup")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.SignIn
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LoginScreen(navController: NavHostController) {
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White),
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
SignInCard(navController)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,190 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.SignUp
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.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.ButtonDefaults
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextField
|
||||||
|
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.res.colorResource
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.vmodel.UserViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SignUpCard(navHostController: NavHostController, userViewModel: UserViewModel = viewModel(factory = UserViewModel.factory)) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.background(colorResource(id = R.color.figma))
|
||||||
|
){
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
){
|
||||||
|
Text(
|
||||||
|
text = "Sign Up",
|
||||||
|
fontSize = 24.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = userViewModel.name.value,
|
||||||
|
onValueChange = { userViewModel.name.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Name",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = userViewModel.surname.value,
|
||||||
|
onValueChange = { userViewModel.surname.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Surname",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = userViewModel.email.value,
|
||||||
|
onValueChange = { userViewModel.email.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Email",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = userViewModel.password.value,
|
||||||
|
onValueChange = { userViewModel.password.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(16.dp, 0.dp)
|
||||||
|
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp)),
|
||||||
|
singleLine = true,
|
||||||
|
visualTransformation = PasswordVisualTransformation(),
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
keyboardType = KeyboardType.Text,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onNext = {
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = "Password",
|
||||||
|
style = TextStyle(fontSize = 12.sp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = colorResource(id = R.color.figma_blue),
|
||||||
|
contentColor = Color.White
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
userViewModel.createUser()
|
||||||
|
navHostController.navigate("login")
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text("Sign Up")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.example.android_programming.composeui.Screens.ProfileScreen.SignUp
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SignUpScreen(navHostController: NavHostController) {
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White),
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
SignUpCard(navHostController)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.example.android_programming.dao
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Delete
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import com.example.android_programming.model.Order
|
||||||
|
import com.example.android_programming.model.OrderSneaker
|
||||||
|
import com.example.android_programming.model.OrderWithSneakers
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface OrderDao {
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
suspend fun createOrder(order: Order): Long
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
suspend fun insertOrderSneaker(orderSneaker: OrderSneaker)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM 'Order' WHERE orderId = :id")
|
||||||
|
fun getOrderWithSneakers(id: Int): Flow<OrderWithSneakers>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM `Order`")
|
||||||
|
fun getAllOrder(): Flow<List<Order>>
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
suspend fun delete(order: Order)
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.android_programming.dao
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Delete
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Update
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface SneakerDao {
|
||||||
|
@Insert
|
||||||
|
suspend fun insert(sneaker: Sneaker)
|
||||||
|
|
||||||
|
@Update
|
||||||
|
suspend fun update(sneaker: Sneaker)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
suspend fun delete(sneaker: Sneaker)
|
||||||
|
|
||||||
|
@Query("SELECT*FROM Sneaker")
|
||||||
|
fun getAllSneakers(): Flow<List<Sneaker>>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM Sneaker WHERE sneakerId = :id")
|
||||||
|
suspend fun getSneakerById(id: Int): Sneaker
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.example.android_programming.dao
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Delete
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Update
|
||||||
|
import com.example.android_programming.model.User
|
||||||
|
import com.example.android_programming.model.UserWithOrder
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface UserDao {
|
||||||
|
@Insert
|
||||||
|
suspend fun createUser(user: User)
|
||||||
|
|
||||||
|
@Update
|
||||||
|
suspend fun updateUser(user: User)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
suspend fun deleteUser(user: User)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM users WHERE userId = :id")
|
||||||
|
suspend fun getUserById(id: Int): User
|
||||||
|
|
||||||
|
@Query("SELECT * FROM users WHERE email = :email")
|
||||||
|
suspend fun getUserByEmail(email: String): User
|
||||||
|
|
||||||
|
@Query("SELECT * FROM users WHERE userId =:id")
|
||||||
|
fun getUserOrders(id: Int) : Flow<UserWithOrder>
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package com.example.android_programming.database
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.Room
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.dao.OrderDao
|
||||||
|
import com.example.android_programming.dao.SneakerDao
|
||||||
|
import com.example.android_programming.dao.UserDao
|
||||||
|
import com.example.android_programming.model.Order
|
||||||
|
import com.example.android_programming.model.OrderSneaker
|
||||||
|
import com.example.android_programming.model.RoleEnum
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import com.example.android_programming.model.User
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
@Database(entities = [Sneaker::class, User::class, Order::class, OrderSneaker::class], version = 5)
|
||||||
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
abstract fun sneakerDao(): SneakerDao
|
||||||
|
abstract fun userDao(): UserDao
|
||||||
|
abstract fun orderDao(): OrderDao
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val DB_NAME: String = "my-db"
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var INSTANCE: AppDatabase? = null
|
||||||
|
|
||||||
|
suspend fun populateDatabase() {
|
||||||
|
INSTANCE?.let { database ->
|
||||||
|
// User
|
||||||
|
val userDao = database.userDao()
|
||||||
|
val user1 = User(null, "Artem", "Emelyanov", "artem@mail.ru", "123", RoleEnum.Admin)
|
||||||
|
val user2 = User(null, "Danil", "Markov", "danil@mail.ru", "123", RoleEnum.User)
|
||||||
|
val user3 = User(null, "Viktoria", "Presnyakova", "vika@mail.ru", "123", RoleEnum.User)
|
||||||
|
userDao.createUser(user1)
|
||||||
|
userDao.createUser(user2)
|
||||||
|
userDao.createUser(user3)
|
||||||
|
// Sneaker
|
||||||
|
val sneakerDao = database.sneakerDao()
|
||||||
|
val sneaker1 = Sneaker(null, "Nike", "Air Force 1", "nice", 159.99, R.drawable.img_1)
|
||||||
|
val sneaker2 = Sneaker(null, "Adidas", "ZX 750", "beautiful", 169.99, R.drawable.img_2)
|
||||||
|
val sneaker3 = Sneaker(null, "Reebok", "Classic", "amazing", 179.99, R.drawable.img_3)
|
||||||
|
val sneaker4 = Sneaker(null, "Puma", "Classic", "normal", 189.99, R.drawable.img_4)
|
||||||
|
sneakerDao.insert(sneaker1)
|
||||||
|
sneakerDao.insert(sneaker2)
|
||||||
|
sneakerDao.insert(sneaker3)
|
||||||
|
sneakerDao.insert(sneaker4)
|
||||||
|
// Order
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getInstance(appContext: Context): AppDatabase {
|
||||||
|
return INSTANCE ?: synchronized(this) {
|
||||||
|
Room.databaseBuilder(
|
||||||
|
appContext,
|
||||||
|
AppDatabase::class.java,
|
||||||
|
DB_NAME
|
||||||
|
)
|
||||||
|
.addCallback(object : Callback() {
|
||||||
|
override fun onCreate(db: SupportSQLiteDatabase) {
|
||||||
|
super.onCreate(db)
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
populateDatabase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fallbackToDestructiveMigration()
|
||||||
|
.build()
|
||||||
|
.also { INSTANCE = it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
data class Order(
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
val orderId: Int? = null,
|
||||||
|
@ColumnInfo(name = "Date")
|
||||||
|
val date: Long,
|
||||||
|
@ColumnInfo(name = "City")
|
||||||
|
val city: String,
|
||||||
|
@ColumnInfo(name = "Street")
|
||||||
|
val street: String,
|
||||||
|
@ColumnInfo(name = "House")
|
||||||
|
val house: String,
|
||||||
|
@ColumnInfo(name = "Sub Total")
|
||||||
|
val subtotal: Double,
|
||||||
|
@ColumnInfo(name = "Taxes")
|
||||||
|
val taxes: Double,
|
||||||
|
@ColumnInfo(name = "Total")
|
||||||
|
val total: Double,
|
||||||
|
@ColumnInfo(name = "CreatorUserId")
|
||||||
|
val creatorUserId: Int
|
||||||
|
)
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
|
||||||
|
@Entity(primaryKeys = ["orderId", "sneakerId"])
|
||||||
|
data class OrderSneaker(
|
||||||
|
val orderId: Int,
|
||||||
|
val sneakerId: Int
|
||||||
|
)
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import androidx.room.Embedded
|
||||||
|
import androidx.room.Junction
|
||||||
|
import androidx.room.Relation
|
||||||
|
|
||||||
|
data class OrderWithSneakers(
|
||||||
|
@Embedded val order: Order,
|
||||||
|
@Relation(
|
||||||
|
parentColumn = "orderId",
|
||||||
|
entityColumn = "sneakerId",
|
||||||
|
associateBy = Junction(OrderSneaker::class)
|
||||||
|
)
|
||||||
|
val sneakers: List<Sneaker>
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import com.example.android_programming.R
|
||||||
|
|
||||||
|
class PhotoManager {
|
||||||
|
private val photos = listOf(
|
||||||
|
R.drawable.img,
|
||||||
|
R.drawable.img_1,
|
||||||
|
R.drawable.img_2,
|
||||||
|
R.drawable.img_3,
|
||||||
|
R.drawable.img_4,
|
||||||
|
R.drawable.img_5,
|
||||||
|
)
|
||||||
|
|
||||||
|
private var currentIndex = 0
|
||||||
|
|
||||||
|
fun changePhoto(int: Int): Int {
|
||||||
|
currentIndex = photos.indexOf(int)
|
||||||
|
if (photos.isNotEmpty()) {
|
||||||
|
if(currentIndex + 1 >= photos.size){
|
||||||
|
currentIndex = 0
|
||||||
|
}else{
|
||||||
|
currentIndex += 1
|
||||||
|
}
|
||||||
|
return photos[currentIndex]
|
||||||
|
} else {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
enum class RoleEnum {
|
||||||
|
Admin,
|
||||||
|
User
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
data class Sneaker(
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
val sneakerId: Int? = null,
|
||||||
|
@ColumnInfo(name = "Brand")
|
||||||
|
val brand: String,
|
||||||
|
@ColumnInfo(name = "Model")
|
||||||
|
val model: String,
|
||||||
|
@ColumnInfo(name = "Description")
|
||||||
|
val description: String,
|
||||||
|
@ColumnInfo(name = "Price")
|
||||||
|
val price: Double,
|
||||||
|
@ColumnInfo(name = "Photo")
|
||||||
|
val photo: Int
|
||||||
|
)
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(tableName = "users")
|
||||||
|
data class User(
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
val userId: Int? = null,
|
||||||
|
@ColumnInfo(name = "Name")
|
||||||
|
val name: String,
|
||||||
|
@ColumnInfo(name = "Surname")
|
||||||
|
val surname: String,
|
||||||
|
@ColumnInfo(name = "Email")
|
||||||
|
val email: String,
|
||||||
|
@ColumnInfo(name = "Password")
|
||||||
|
val password: String,
|
||||||
|
@ColumnInfo(name = "Role")
|
||||||
|
val role: RoleEnum,
|
||||||
|
@ColumnInfo(name = "Photo")
|
||||||
|
val photo: Int? = null,
|
||||||
|
)
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.example.android_programming.model
|
||||||
|
|
||||||
|
import androidx.room.Embedded
|
||||||
|
import androidx.room.Relation
|
||||||
|
|
||||||
|
data class UserWithOrder(
|
||||||
|
@Embedded val user: User,
|
||||||
|
@Relation(
|
||||||
|
parentColumn = "userId",
|
||||||
|
entityColumn = "CreatorUserId"
|
||||||
|
)
|
||||||
|
val orders: List<Order>
|
||||||
|
)
|
@ -1,68 +1,64 @@
|
|||||||
/*
|
//package com.example.android_programming.ui.theme
|
||||||
package com.example.android_programming.ui.theme
|
//
|
||||||
|
//import android.app.Activity
|
||||||
import android.app.Activity
|
//import android.os.Build
|
||||||
import android.os.Build
|
//import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
//import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
//import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.SideEffect
|
//import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.ui.graphics.toArgb
|
//import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
//import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.compose.ui.platform.LocalView
|
//import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.core.view.WindowCompat
|
//import androidx.compose.ui.platform.LocalView
|
||||||
|
//import androidx.core.view.WindowCompat
|
||||||
private val DarkColorScheme = darkColorScheme(
|
//
|
||||||
primary = Purple80,
|
//private val DarkColorScheme = darkColorScheme(
|
||||||
secondary = PurpleGrey80,
|
// primary = Purple80,
|
||||||
tertiary = Pink80
|
// secondary = PurpleGrey80,
|
||||||
)
|
// tertiary = Pink80
|
||||||
|
//)
|
||||||
private val LightColorScheme = lightColorScheme(
|
//
|
||||||
primary = Purple40,
|
//private val LightColorScheme = lightColorScheme(
|
||||||
secondary = PurpleGrey40,
|
// primary = Purple40,
|
||||||
tertiary = Pink40
|
// secondary = PurpleGrey40,
|
||||||
|
// tertiary = Pink40,
|
||||||
*/
|
// background = Color(0xFFFFFBFE),
|
||||||
/* Other default colors to override
|
// surface = Color(0xFFFFFBFE),
|
||||||
background = Color(0xFFFFFBFE),
|
// onPrimary = Color.White,
|
||||||
surface = Color(0xFFFFFBFE),
|
// onSecondary = Color.White,
|
||||||
onPrimary = Color.White,
|
// onTertiary = Color.White,
|
||||||
onSecondary = Color.White,
|
// onBackground = Color(0xFF1C1B1F),
|
||||||
onTertiary = Color.White,
|
// onSurface = Color(0xFF1C1B1F),
|
||||||
onBackground = Color(0xFF1C1B1F),
|
//)
|
||||||
onSurface = Color(0xFF1C1B1F),
|
//
|
||||||
*//*
|
//@Composable
|
||||||
|
//fun AndroidProgrammingTheme(
|
||||||
)
|
// darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
// // Dynamic color is available on Android 12+
|
||||||
@Composable
|
// dynamicColor: Boolean = true,
|
||||||
fun AndroidProgrammingTheme(
|
// content: @Composable () -> Unit
|
||||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
//) {
|
||||||
// Dynamic color is available on Android 12+
|
// val colorScheme = when {
|
||||||
dynamicColor: Boolean = true,
|
// dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
content: @Composable () -> Unit
|
// val context = LocalContext.current
|
||||||
) {
|
// if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||||
val colorScheme = when {
|
// }
|
||||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
//
|
||||||
val context = LocalContext.current
|
// darkTheme -> DarkColorScheme
|
||||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
// else -> LightColorScheme
|
||||||
}
|
// }
|
||||||
|
// val view = LocalView.current
|
||||||
darkTheme -> DarkColorScheme
|
// if (!view.isInEditMode) {
|
||||||
else -> LightColorScheme
|
// SideEffect {
|
||||||
}
|
// val window = (view.context as Activity).window
|
||||||
val view = LocalView.current
|
// window.statusBarColor = colorScheme.primary.toArgb()
|
||||||
if (!view.isInEditMode) {
|
// WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
|
||||||
SideEffect {
|
// }
|
||||||
val window = (view.context as Activity).window
|
// }
|
||||||
window.statusBarColor = colorScheme.primary.toArgb()
|
//
|
||||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
|
// MaterialTheme(
|
||||||
}
|
// colorScheme = colorScheme,
|
||||||
}
|
// typography = Typography,
|
||||||
|
// content = content
|
||||||
MaterialTheme(
|
// )
|
||||||
colorScheme = colorScheme,
|
//}
|
||||||
typography = Typography,
|
|
||||||
content = content
|
|
||||||
)
|
|
||||||
}*/
|
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
package com.example.android_programming.vmodel
|
||||||
|
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.CreationExtras
|
||||||
|
import com.example.android_programming.App
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.database.AppDatabase
|
||||||
|
import com.example.android_programming.model.Order
|
||||||
|
import com.example.android_programming.model.OrderSneaker
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
class OrderViewModel(val database: AppDatabase) : ViewModel() {
|
||||||
|
private var _selectedItems = mutableStateOf<List<Sneaker>>(emptyList())
|
||||||
|
val selectedItems get() = _selectedItems.value
|
||||||
|
var city = mutableStateOf("")
|
||||||
|
val street = mutableStateOf("")
|
||||||
|
val house = mutableStateOf("")
|
||||||
|
|
||||||
|
fun addSelectedItem(item: Sneaker) {
|
||||||
|
_selectedItems.value = _selectedItems.value + item
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteOrder(order: Order) = viewModelScope.launch {
|
||||||
|
database.orderDao().delete(order)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOrderList(id: Int) = viewModelScope.launch {
|
||||||
|
database.userDao().getUserOrders(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeSelectedItem(item: Sneaker) {
|
||||||
|
val updatedItems = _selectedItems.value.toMutableList()
|
||||||
|
updatedItems.remove(item)
|
||||||
|
_selectedItems.value = updatedItems
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createOrder() = viewModelScope.launch {
|
||||||
|
val order = Order(
|
||||||
|
date = Date().time,
|
||||||
|
city = city.value,
|
||||||
|
street = street.value,
|
||||||
|
house = house.value,
|
||||||
|
subtotal = getSubTotal(),
|
||||||
|
taxes = "%.2f".format(getSubTotal() * 0.05).toDouble(),
|
||||||
|
total = "%.2f".format(getSubTotal() * 0.05 + getSubTotal()).toDouble(),
|
||||||
|
creatorUserId = GlobalUser.getInstance().getUser()?.userId!!
|
||||||
|
)
|
||||||
|
|
||||||
|
val orderId = database.orderDao().createOrder(order)
|
||||||
|
|
||||||
|
for (sneaker in selectedItems) {
|
||||||
|
val orderSneaker = OrderSneaker( orderId.toInt(), sneaker.sneakerId!!)
|
||||||
|
database.orderDao().insertOrderSneaker(orderSneaker)
|
||||||
|
}
|
||||||
|
city.value = ""
|
||||||
|
street.value = ""
|
||||||
|
house.value = ""
|
||||||
|
_selectedItems = mutableStateOf(emptyList())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSubTotal(): Double {
|
||||||
|
return selectedItems.sumOf { it.price }
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object{
|
||||||
|
val factory: ViewModelProvider.Factory = object : ViewModelProvider.Factory{
|
||||||
|
override fun <T : ViewModel> create(
|
||||||
|
modelClass: Class<T>,
|
||||||
|
extras: CreationExtras
|
||||||
|
): T {
|
||||||
|
val database = (checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY]) as App).database
|
||||||
|
return OrderViewModel(database) as T
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.example.android_programming.vmodel
|
||||||
|
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import androidx.lifecycle.ViewModelProvider.AndroidViewModelFactory.Companion.APPLICATION_KEY
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.CreationExtras
|
||||||
|
import com.example.android_programming.App
|
||||||
|
import com.example.android_programming.R
|
||||||
|
import com.example.android_programming.database.AppDatabase
|
||||||
|
import com.example.android_programming.model.Sneaker
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class SneakerViewModel(val database: AppDatabase): ViewModel() {
|
||||||
|
var brand = mutableStateOf("")
|
||||||
|
val model = mutableStateOf("")
|
||||||
|
val description = mutableStateOf("")
|
||||||
|
val price = mutableStateOf("")
|
||||||
|
val photo = mutableStateOf(R.drawable.img)
|
||||||
|
val SneakerList = database.sneakerDao().getAllSneakers()
|
||||||
|
var sneaker: Sneaker? = null
|
||||||
|
|
||||||
|
fun insertSneaker() = viewModelScope.launch {
|
||||||
|
val sneaker = Sneaker(
|
||||||
|
brand = brand.value,
|
||||||
|
model = model.value,
|
||||||
|
description = description.value,
|
||||||
|
price = price.value.toDouble(),
|
||||||
|
photo = photo.value
|
||||||
|
)
|
||||||
|
database.sneakerDao().insert(sneaker)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteSneaker(sneaker : Sneaker) = viewModelScope.launch {
|
||||||
|
database.sneakerDao().delete(sneaker)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSneakerById(id: Int) = viewModelScope.launch {
|
||||||
|
database.sneakerDao().getSneakerById(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun UpdateSneaker(sneaker: Sneaker) = viewModelScope.launch {
|
||||||
|
database.sneakerDao().update(sneaker)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object{
|
||||||
|
val factory: ViewModelProvider.Factory = object : ViewModelProvider.Factory{
|
||||||
|
override fun <T : ViewModel> create(
|
||||||
|
modelClass: Class<T>,
|
||||||
|
extras: CreationExtras): T {
|
||||||
|
val database = (checkNotNull(extras[APPLICATION_KEY]) as App).database
|
||||||
|
return SneakerViewModel(database) as T
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.example.android_programming.vmodel
|
||||||
|
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.CreationExtras
|
||||||
|
import com.example.android_programming.App
|
||||||
|
import com.example.android_programming.GlobalUser
|
||||||
|
import com.example.android_programming.database.AppDatabase
|
||||||
|
import com.example.android_programming.model.RoleEnum
|
||||||
|
import com.example.android_programming.model.User
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class UserViewModel(val database: AppDatabase): ViewModel() {
|
||||||
|
|
||||||
|
var name = mutableStateOf("")
|
||||||
|
val surname = mutableStateOf("")
|
||||||
|
val email = mutableStateOf("")
|
||||||
|
val password = mutableStateOf("")
|
||||||
|
fun createUser() = viewModelScope.launch {
|
||||||
|
val user = User(
|
||||||
|
name = name.value,
|
||||||
|
surname = surname.value,
|
||||||
|
email = email.value,
|
||||||
|
password = password.value,
|
||||||
|
role = RoleEnum.User
|
||||||
|
)
|
||||||
|
database.userDao().createUser(user)
|
||||||
|
}
|
||||||
|
fun authUser() = viewModelScope.launch {
|
||||||
|
val user = database.userDao().getUserByEmail(email.value)
|
||||||
|
if (password.value != "" && user.password == password.value) {
|
||||||
|
val globalUser = GlobalUser.getInstance()
|
||||||
|
globalUser.setUser(user)
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun isValidEmail(email: String): Boolean {
|
||||||
|
return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object{
|
||||||
|
val factory: ViewModelProvider.Factory = object : ViewModelProvider.Factory{
|
||||||
|
override fun <T : ViewModel> create(
|
||||||
|
modelClass: Class<T>,
|
||||||
|
extras: CreationExtras
|
||||||
|
): T {
|
||||||
|
val database = (checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY]) as App).database
|
||||||
|
return UserViewModel(database) as T
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
app/src/main/res/drawable/img.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
app/src/main/res/drawable/img_1.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
app/src/main/res/drawable/img_2.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
app/src/main/res/drawable/img_3.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
app/src/main/res/drawable/img_4.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
app/src/main/res/drawable/img_5.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
app/src/main/res/drawable/sales.png
Normal file
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 29 KiB |