Sfoglia il codice sorgente

refactor: Добавление нескольких экранов

k1rakato 21 ore fa
parent
commit
4f25b9b2a9

+ 2 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/FavoritPlants.kt

@@ -0,0 +1,2 @@
+package com.example.tomatoandpotatoapp.Screens
+

+ 159 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/SelectedPlant.kt

@@ -0,0 +1,159 @@
+package com.example.tomatoandpotatoapp.Screens
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+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.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.KeyboardArrowLeft
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.focus.focusModifier
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.res.imageResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.lifecycle.viewmodel.compose.viewModel
+import com.example.tomatoandpotatoapp.R
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import com.example.tomatoandpotatoapp.navigationPack.Screens
+
+
+@Preview
+@Composable
+fun CurrentPlant(viewModel: SupabaseAuthViewModel = viewModel()) {
+
+    val alonePlant = viewModel.alonePlant
+
+
+    Box(modifier = Modifier.fillMaxSize()) {
+        Box(
+            modifier = Modifier
+                .fillMaxSize()
+                .background(
+                    brush = Brush.verticalGradient(
+                        colors = listOf(
+                            Color(0xFF666666).copy(alpha = 0.85f),
+                            Color(0xFF666666).copy(alpha = 0.1f)
+                        ),
+                        startY = 0.0f,
+                        endY = 1500.0f
+                    )
+                )
+        )
+        Column(modifier = Modifier.fillMaxSize(), ) {
+            Row (
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .height(95.dp)
+                    .background(color = Color(0xffD9D9D9)),
+
+
+            ) {
+                Column(
+                    horizontalAlignment = Alignment.CenterHorizontally,
+                    verticalArrangement = Arrangement.Center) {
+                    Button(
+                        onClick = {
+                            //navController.navigate(Screens.PlantsCatalog.route)
+                        },
+                        modifier = Modifier
+                            .padding(start = 28.dp, top = 41.dp)
+                            .width(31.dp)
+                            .height(31.dp),
+                        colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF78EE99)),
+                        shape = RoundedCornerShape(10.dp),
+                        contentPadding = PaddingValues(1.dp)
+                    ) {
+                        Icon(
+                            imageVector = Icons.Filled.KeyboardArrowLeft,
+                            contentDescription = ""
+                        )
+                    }
+                }
+
+                Column (modifier = Modifier.fillMaxWidth().padding(top = 42.dp, end = 36.dp),
+                    horizontalAlignment = Alignment.CenterHorizontally,
+                    verticalArrangement = Arrangement.Center
+                ) {
+                    Text(text = "alonePlant!!.title",
+                        fontSize = 25.sp,
+                        fontWeight = FontWeight.W700,
+                        textAlign = TextAlign.Center)
+                    //cry(((
+
+                }
+            }
+
+            Spacer(modifier = Modifier.height(60.dp))
+
+            Column() {
+
+            }
+
+            Spacer(modifier = Modifier.weight(0.2f))
+
+            Row(
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .height(105.dp)
+                    .background(color = Color(0xff718588)),
+                horizontalArrangement = Arrangement.SpaceEvenly
+            ) {
+                IconButton(
+                    onClick = { },
+                    modifier = Modifier.size(120.dp)
+                ) {
+                    Icon(
+                        bitmap = ImageBitmap.imageResource(R.drawable.message),
+                        contentDescription = "",
+                        modifier = Modifier.size(55.dp)
+                    )
+                }
+                IconButton(
+                    onClick = { /*TODO*/ },
+                    modifier = Modifier.size(120.dp)
+                ) {
+                    Icon(
+                        bitmap = ImageBitmap.imageResource(R.drawable.catalogblack),
+                        contentDescription = "",
+                        modifier = Modifier.size(55.dp)
+                    )
+                }
+                IconButton(
+                    onClick = { /*navController.navigate(Screens.ProfileScreen.route)*/ },
+                    modifier = Modifier.size(120.dp)
+                ) {
+                    Icon(
+                        bitmap = ImageBitmap.imageResource(R.drawable.profile),
+                        contentDescription = "",
+                        modifier = Modifier.size(55.dp)
+                    )
+                }
+
+
+            }
+        }
+    }
+}

+ 4 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/ViewModelsPack/SupabaseAuthViewModel.kt

@@ -4,7 +4,9 @@ import android.content.Context
 import android.content.SharedPreferences
 import android.util.Log
 import androidx.compose.runtime.State
+import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
 import com.example.tomatoandpotatoapp.data.models.GenderTable
@@ -32,6 +34,8 @@ class SupabaseAuthViewModel : ViewModel() {
     private val _plants = mutableStateOf(listOf<Plants>())
     val plants: State<List<Plants>> = _plants
 
+    var alonePlant by mutableStateOf<Plants?>(null)
+
     private val _typesOfPlants = mutableStateOf(listOf<TypesOfPlants>())
     val typesOfPlants: State<List<TypesOfPlants>> = _typesOfPlants