Browse Source

update: completely made by DropdownMenu

Maksutka 6 ngày trước cách đây
mục cha
commit
292583b350

+ 81 - 20
TripHelper/app/src/main/java/com/example/triphelper/view/Registration/Registration.kt

@@ -1,6 +1,7 @@
 package com.example.triphelper.view.Registration
 
 import androidx.compose.foundation.Image
+import androidx.compose.foundation.ScrollState
 import androidx.compose.foundation.border
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
@@ -11,10 +12,13 @@ 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.layout.wrapContentSize
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowForward
 import androidx.compose.material.icons.filled.MoreVert
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults.buttonColors
@@ -33,7 +37,6 @@ import androidx.compose.runtime.collectAsState
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
-import androidx.compose.runtime.savedinstancestate.savedInstanceState
 import androidx.compose.runtime.setValue
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
@@ -42,6 +45,8 @@ import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.font.FontFamily
 import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.DpOffset
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.hilt.navigation.compose.hiltViewModel
@@ -54,6 +59,7 @@ import com.example.triphelper.view.style.TextFieldStylePasswordAuth
 import com.example.triphelper.view.style.TripHelperLogoStyle
 import com.example.triphelper.view.theme.Casagrand
 import com.example.triphelper.view.theme.Roboto
+import com.example.triphelper.view.theme.SeoulLight
 
 
 @Composable
@@ -67,6 +73,7 @@ fun Registration(
     var selectedItem by remember { mutableStateOf("") }
     val repeatPassword = remember { mutableStateOf("") }
     val name = remember { mutableStateOf("") }
+    val coutryTitle = remember { mutableStateOf("") }
     val country by viewModel.country.collectAsState(initial = emptyList())
 
     LaunchedEffect(key1 = viewModel.navigationTo) {
@@ -102,14 +109,16 @@ fun Registration(
             {
                 TextFieldStyleAuth("Почта", email)
                 TextFieldStyleAuth("Имя", name)
-                var expanded by remember { mutableStateOf(false) }
-                var selectedOption by remember { mutableStateOf("") }
                 Box {
-                    Button(onClick = {  expanded = true
-                                     viewModel.getCountry()},
+                    Button(
+                        onClick = {
+                            expanded = true
+                            viewModel.getCountry()
+                        },
                         shape = RoundedCornerShape(15.dp),
                         modifier = Modifier
-                            .height(80.dp)
+                            .fillMaxWidth()
+                            .height(90.dp)
                             .border(
                                 width = 4.dp,
                                 color = Color(0xFF510B3C),
@@ -117,28 +126,80 @@ fun Registration(
                             ),
                         colors = buttonColors(
                             containerColor = Color.White
-                        )) {
-                        Text("$selectedOption",
-                            fontFamily = Roboto,
-                            fontWeight = FontWeight.Bold,
-                            fontSize = 32.sp,
-                            color = Color(0xFFDC5B6E))
+                        )
+                    ) {
+                        Row(
+                            modifier = Modifier.fillMaxSize(), // Занимаем всю ширину кнопки
+                            horizontalArrangement = Arrangement.Start, // Выравнивание по началу
+                            verticalAlignment = Alignment.CenterVertically // Выравнивание по центру по вертикали
+                        )
+                        {
+                            if (selectedItem.isEmpty()) {
+                                Row(
+                                    horizontalArrangement = Arrangement.SpaceBetween,
+                                    verticalAlignment = Alignment.CenterVertically,
+                                    modifier = Modifier.fillMaxWidth()
+                                )
+                                {
+                                    Text(
+                                        "Выберите страну",
+                                        fontFamily = SeoulLight,
+                                        fontSize = 32.sp,
+                                        color = Color(0xFFDC5B6E).copy(alpha = 0.7f),
+                                        textAlign = TextAlign.Start
+                                    )
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.galka_down),
+                                        contentDescription = null,
+                                        tint = Color(0xFFDC5B6E).copy(alpha = 0.7f),
+
+                                    )
+                                }
+                            } else {
+                                Text(
+                                    "$selectedItem",
+                                    fontFamily = SeoulLight,
+                                    fontWeight = FontWeight.W600,
+                                    fontSize = 32.sp,
+                                    color = Color(0xFFDC5B6E),
+                                    textAlign = TextAlign.Start
+                                )
+                            }
+
+                        }
                     }
                     DropdownMenu(
                         expanded = expanded,
-                        onDismissRequest = { expanded = false }
+                        onDismissRequest = { expanded = false },
+                        containerColor = Color.White,
+                        modifier = Modifier
+                            .fillMaxWidth(0.9f)
+                            .height(200.dp)
                     ) {
-                        country.forEach{
-                            item -> DropdownMenuItem(
-                            onClick = { selectedItem = item.title},
-                            text = { Text(item.title) })
+                        country.forEach { item ->
+                            DropdownMenuItem(
+                                onClick = {
+                                    selectedItem = item.title
+                                    coutryTitle.value = item.title
+                                    expanded = false
+                                },
+                                text = {
+                                    Text(
+                                        text = item.title,
+                                        fontSize = 18.sp,
+                                        fontFamily = Roboto,
+                                        color = Color(0xFF510B3C),
+                                        fontWeight = FontWeight.Bold,
+                                        textAlign = TextAlign.Start
+                                    )
+                                }
+                            )
                         }
                     }
                 }
+                TextFieldStylePasswordAuth("Пароль", password)
+                TextFieldStylePasswordAuth("Повтор пароля", repeatPassword)
             }
-
-            TextFieldStylePasswordAuth("Пароль", password)
-            TextFieldStylePasswordAuth("Повтор пароля", repeatPassword)
             Row(
                 modifier = Modifier
 

+ 10 - 0
TripHelper/app/src/main/res/drawable/galka_down.xml

@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="26dp"
+    android:height="13dp"
+    android:viewportWidth="26"
+    android:viewportHeight="13">
+  <path
+      android:pathData="M0.577,0.537C-0.192,1.243 -0.192,2.389 0.577,3.096L10.216,11.941C11.755,13.353 14.249,13.353 15.788,11.94L25.423,3.09C26.192,2.383 26.192,1.237 25.423,0.53C24.654,-0.177 23.406,-0.177 22.637,0.53L14.39,8.105C13.62,8.812 12.373,8.812 11.603,8.105L3.363,0.537C2.594,-0.17 1.347,-0.17 0.577,0.537Z"
+      android:fillColor="#DC5B6E"
+      android:fillAlpha="0.7"/>
+</vector>