|
@@ -2,6 +2,7 @@ package com.example.tomatoandpotatoapp.Screens
|
|
|
|
|
|
import android.widget.ImageButton
|
|
|
import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
import androidx.compose.foundation.layout.Column
|
|
@@ -14,36 +15,50 @@ 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.KeyboardArrowDown
|
|
|
+import androidx.compose.material.icons.filled.KeyboardArrowUp
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
+import androidx.compose.material3.DropdownMenu
|
|
|
+import androidx.compose.material3.DropdownMenuItem
|
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.IconButton
|
|
|
+import androidx.compose.material3.OutlinedTextField
|
|
|
import androidx.compose.material3.Text
|
|
|
+import androidx.compose.material3.TextFieldColors
|
|
|
+import androidx.compose.material3.TextFieldDefaults
|
|
|
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.geometry.Size
|
|
|
import androidx.compose.ui.graphics.Brush
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.ImageBitmap
|
|
|
+import androidx.compose.ui.layout.onGloballyPositioned
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
+import androidx.compose.ui.platform.LocalDensity
|
|
|
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.compose.ui.unit.toSize
|
|
|
import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import androidx.navigation.NavController
|
|
|
import com.example.tomatoandpotatoapp.R
|
|
|
import com.example.tomatoandpotatoapp.utils.EditProfileString
|
|
|
|
|
|
+
|
|
|
@Preview
|
|
|
@Composable
|
|
|
fun MyProfile(
|
|
|
- //viewModel: SupabaseAuthViewModel = viewModel(),
|
|
|
+ viewModel: SupabaseAuthViewModel = viewModel(),
|
|
|
//navController: NavController
|
|
|
) {
|
|
|
// val userState by viewModel.userState
|
|
@@ -67,6 +82,15 @@ fun MyProfile(
|
|
|
// val birthDate = remember {
|
|
|
// mutableStateOf(people.last().birthDate)
|
|
|
// }
|
|
|
+ var mSelectedText by remember { mutableStateOf("") }
|
|
|
+ var expanded by remember { mutableStateOf(false) }
|
|
|
+ var mTextFieldSize by remember { mutableStateOf(Size.Zero) }
|
|
|
+ val genders = listOf("Мужской", "Женский")
|
|
|
+
|
|
|
+ val icon = if (expanded)
|
|
|
+ Icons.Filled.KeyboardArrowUp
|
|
|
+ else
|
|
|
+ Icons.Filled.KeyboardArrowDown
|
|
|
|
|
|
Box(modifier = Modifier.fillMaxSize()) {
|
|
|
Box(
|
|
@@ -113,102 +137,176 @@ fun MyProfile(
|
|
|
EditProfileString(search = "", onValueChange = {}, enabled = true)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
|
|
|
|
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
|
|
|
|
|
- EditProfileString(search = "", onValueChange = {}, enabled = true)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- Spacer(modifier = Modifier.height(110.dp))
|
|
|
-
|
|
|
- Row(
|
|
|
- modifier = Modifier.fillMaxWidth(),
|
|
|
- horizontalArrangement = Arrangement.Center,
|
|
|
- verticalAlignment = Alignment.CenterVertically
|
|
|
- ) {
|
|
|
- Button(
|
|
|
- onClick = { },
|
|
|
+ OutlinedTextField(
|
|
|
+ value = mSelectedText,
|
|
|
+ onValueChange = { mSelectedText = it },
|
|
|
modifier = Modifier
|
|
|
- .width(278.dp)
|
|
|
- .height(45.dp),
|
|
|
+ .height(50.dp)
|
|
|
+ .width(316.dp)
|
|
|
+ .onGloballyPositioned { coordinates ->
|
|
|
+ mTextFieldSize = coordinates.size.toSize()
|
|
|
+ },
|
|
|
shape = RoundedCornerShape(20),
|
|
|
- colors = ButtonDefaults.buttonColors(containerColor = Color(0xff78EE99))
|
|
|
+ colors = TextFieldDefaults.colors(
|
|
|
+ focusedContainerColor = Color(0xFFF2D6FA),
|
|
|
+ focusedIndicatorColor = Color(0xFF4C2259),
|
|
|
+ focusedTextColor = Color.Black,
|
|
|
+ disabledIndicatorColor = Color.Transparent,
|
|
|
+ unfocusedIndicatorColor = Color.Transparent,
|
|
|
+ cursorColor = Color.Black,
|
|
|
+ focusedSupportingTextColor = Color.Black
|
|
|
+ ),
|
|
|
+ label = {
|
|
|
+ Text(
|
|
|
+ "Пол",
|
|
|
+ fontWeight = FontWeight.W600,
|
|
|
+ color = Color.Black
|
|
|
+ )
|
|
|
+ },
|
|
|
+ trailingIcon = {
|
|
|
+ Icon(icon, "contentDescription",
|
|
|
+ Modifier.clickable { expanded = !expanded })
|
|
|
+ }
|
|
|
)
|
|
|
- {
|
|
|
- Text(
|
|
|
- text = "Сохранить",
|
|
|
- fontSize = 20.sp,
|
|
|
- fontWeight = FontWeight.W700,
|
|
|
- color = Color.White
|
|
|
- )
|
|
|
+ DropdownMenu(
|
|
|
+ expanded = expanded,
|
|
|
+ onDismissRequest = { expanded = false },
|
|
|
+ modifier = Modifier
|
|
|
+ .width(with(LocalDensity.current) { mTextFieldSize.width.toDp() })
|
|
|
+ ) {
|
|
|
+ genders.forEach { label ->
|
|
|
+ DropdownMenuItem(onClick = {
|
|
|
+ mSelectedText = label
|
|
|
+ expanded = false
|
|
|
+ }) {
|
|
|
+ Text(text = label)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- Spacer(modifier = Modifier.height(25.dp))
|
|
|
+ Spacer(modifier = Modifier.height(30.dp))
|
|
|
|
|
|
- Row(
|
|
|
- modifier = Modifier.fillMaxWidth(),
|
|
|
- horizontalArrangement = Arrangement.Center,
|
|
|
- verticalAlignment = Alignment.CenterVertically
|
|
|
- ) {
|
|
|
- Button(
|
|
|
- onClick = { },
|
|
|
- modifier = Modifier
|
|
|
- .width(278.dp)
|
|
|
- .height(45.dp),
|
|
|
- shape = RoundedCornerShape(20),
|
|
|
- colors = ButtonDefaults.buttonColors(containerColor = Color(0xffFC5050))
|
|
|
- )
|
|
|
- {
|
|
|
- Text(
|
|
|
- text = "Выход",
|
|
|
- fontSize = 20.sp,
|
|
|
- fontWeight = FontWeight.W700,
|
|
|
- color = Color.White
|
|
|
- )
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ horizontalArrangement = Arrangement.Center
|
|
|
+ ) {
|
|
|
+ Button(
|
|
|
+ onClick = {},
|
|
|
+ modifier = Modifier
|
|
|
+ .height(50.dp)
|
|
|
+ .width(316.dp),
|
|
|
+ shape = RoundedCornerShape(20),
|
|
|
+ colors = ButtonDefaults
|
|
|
+ .buttonColors(containerColor = Color(0xFFF5F5F9))
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "Мои растения",
|
|
|
+ fontWeight = FontWeight.W800,
|
|
|
+ color = Color.Black,
|
|
|
+ fontSize = 22.sp
|
|
|
+ )
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- Spacer(modifier = Modifier.weight(0.2f))
|
|
|
|
|
|
- Row(modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .height(95.dp)
|
|
|
- .align(Alignment.End)
|
|
|
- .background(color = Color(0xff718588)),
|
|
|
- horizontalArrangement = Arrangement.SpaceEvenly
|
|
|
- ) {
|
|
|
- IconButton(
|
|
|
- onClick = { /*TODO*/ },
|
|
|
- modifier = Modifier.size(120.dp)
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.height(110.dp))
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ horizontalArrangement = Arrangement.Center,
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
|
- Icon(
|
|
|
- bitmap = ImageBitmap.imageResource(R.drawable.message),
|
|
|
- contentDescription ="",
|
|
|
- modifier = Modifier.size(55.dp))
|
|
|
+ Button(
|
|
|
+ onClick = { },
|
|
|
+ modifier = Modifier
|
|
|
+ .width(278.dp)
|
|
|
+ .height(45.dp),
|
|
|
+ shape = RoundedCornerShape(20),
|
|
|
+ colors = ButtonDefaults.buttonColors(containerColor = Color(0xff78EE99))
|
|
|
+ )
|
|
|
+ {
|
|
|
+ Text(
|
|
|
+ text = "Сохранить",
|
|
|
+ fontSize = 22.sp,
|
|
|
+ fontWeight = FontWeight.W700,
|
|
|
+ color = Color.White
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
- IconButton(
|
|
|
- onClick = { /*TODO*/ },
|
|
|
- modifier = Modifier.size(120.dp)
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.height(25.dp))
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ horizontalArrangement = Arrangement.Center,
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
|
- Icon(
|
|
|
- bitmap = ImageBitmap.imageResource(R.drawable.catalog),
|
|
|
- contentDescription ="",
|
|
|
- modifier = Modifier.size(55.dp))
|
|
|
+ Button(
|
|
|
+ onClick = { },
|
|
|
+ modifier = Modifier
|
|
|
+ .width(278.dp)
|
|
|
+ .height(45.dp),
|
|
|
+ shape = RoundedCornerShape(20),
|
|
|
+ colors = ButtonDefaults.buttonColors(containerColor = Color(0xffFC5050))
|
|
|
+ )
|
|
|
+ {
|
|
|
+ Text(
|
|
|
+ text = "Выход",
|
|
|
+ fontSize = 22.sp,
|
|
|
+ fontWeight = FontWeight.W700,
|
|
|
+ color = Color.White
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
- IconButton(
|
|
|
- onClick = { /*TODO*/ },
|
|
|
- modifier = Modifier.size(120.dp)
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.weight(0.2f))
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(95.dp)
|
|
|
+ //.align(Alignment.End)
|
|
|
+ .background(color = Color(0xff718588)),
|
|
|
+ horizontalArrangement = Arrangement.SpaceEvenly
|
|
|
) {
|
|
|
- Icon(
|
|
|
- bitmap = ImageBitmap.imageResource(R.drawable.profileblack),
|
|
|
- contentDescription ="",
|
|
|
- modifier = Modifier.size(55.dp))
|
|
|
- }
|
|
|
+ IconButton(
|
|
|
+ onClick = { /*TODO*/ },
|
|
|
+ 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.catalog),
|
|
|
+ contentDescription = "Каталог",
|
|
|
+ modifier = Modifier.size(55.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ IconButton(
|
|
|
+ onClick = { /*TODO*/ },
|
|
|
+ modifier = Modifier.size(120.dp)
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ bitmap = ImageBitmap.imageResource(R.drawable.profileblack),
|
|
|
+ contentDescription = "Профиль",
|
|
|
+ modifier = Modifier.size(55.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|