Преглед изворни кода

полностью доделал создание пользователя

AlexMin пре 1 недеља
родитељ
комит
fff7272f20

BIN
.gradle/file-system.probe


+ 3 - 0
app/build.gradle.kts

@@ -56,6 +56,7 @@ android {
 }
 
 dependencies {
+
     implementation(libs.androidx.core.ktx)
     implementation(libs.androidx.lifecycle.runtime.ktx)
     implementation(libs.androidx.activity.compose)
@@ -97,4 +98,6 @@ dependencies {
     implementation(libs.coil.compose) // Или последняя версия
 
     implementation(libs.ui.tooling.preview)
+
+
 }

+ 2 - 2
app/src/main/java/com/example/iplace/main/viewModel/dataView/PolicyConditionality.kt

@@ -112,7 +112,7 @@ fun PolicyConditionality(navController: NavHostController) {
                     verticalAlignment = Alignment.CenterVertically,
                     modifier = Modifier.fillMaxWidth()
                 ) {
-                    IconButton(onClick = { navController.navigate("selectEnter") }) {
+                    IconButton(onClick = { navController.navigate("creatingUser") }) {
                         Icon(
                             imageVector = Icons.Default.ArrowBack,
                             contentDescription = "Назад",
@@ -196,7 +196,7 @@ fun PolicyConditionality(navController: NavHostController) {
                             fontFamily = basicNunitosans
                         )
                     }
-                    Spacer(modifier = Modifier.height(16.dp))
+                    Spacer(modifier = Modifier.height(40.dp))
                 }
             }
         }

+ 56 - 80
app/src/main/java/com/example/iplace/main/viewModel/mainView/CreatingUser.kt

@@ -56,6 +56,13 @@ import com.example.iplace.main.viewModel.MainViewModel
 import com.example.iplace.ui.theme.beige_white
 import com.example.iplace.ui.theme.brown_contrast
 import java.io.IOException
+import androidx.compose.foundation.layout.*
+import androidx.compose.material.*
+import androidx.compose.material.icons.filled.ArrowDropDown
+import androidx.compose.runtime.*
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+
 
 @Composable
 fun CreatingUser(navController: NavHostController) {
@@ -67,8 +74,7 @@ fun CreatingUser(navController: NavHostController) {
         Font(resId = R.font.basic_nunitosans)
     )
 
-    var expanded by remember { mutableStateOf(false) }
-    var selectedItem by remember { mutableStateOf("") }
+
 
     var selectedImageUri by remember { mutableStateOf<Uri?>(null) }
     var imageBitmap by remember { mutableStateOf<androidx.compose.ui.graphics.ImageBitmap?>(null) }
@@ -88,13 +94,19 @@ fun CreatingUser(navController: NavHostController) {
         }
     }
 
-    val emailUser = remember { mutableStateOf("") }
-    val passwordUser = remember { mutableStateOf("") }
+
     val nameUser = remember { mutableStateOf("") }
     val address = remember { mutableStateOf("") }
     val about_me = remember { mutableStateOf("") }
+    var expanded by remember { mutableStateOf(false) }
+    var selectedItem by remember { mutableStateOf("") }
     val id_genderFK = remember { mutableStateOf("") }
-    val img_user = remember { mutableStateOf("") }
+
+    val genderOptions = listOf(
+        Pair("Мужчина", "1"),
+        Pair("Женщина", "2")
+    )
+
 
     Image(
         painter = painterResource(id = R.drawable.cu6),
@@ -136,7 +148,7 @@ fun CreatingUser(navController: NavHostController) {
                     verticalAlignment = Alignment.CenterVertically,
                     modifier = Modifier.fillMaxWidth()
                 ) {
-                    IconButton(onClick = { navController.navigate("selectEnter") }) {
+                    IconButton(onClick = { navController.navigate("registration") }) {
                         Icon(
                             imageVector = Icons.Default.ArrowBack, // Или другой иконки
                             contentDescription = "Назад",
@@ -165,51 +177,50 @@ fun CreatingUser(navController: NavHostController) {
                         .clip(RoundedCornerShape(20.dp))
                 )
                 Spacer(modifier = Modifier.height(10.dp))
-                Box(
+
+                Column(
                     modifier = Modifier
                         .fillMaxWidth()
-                        .padding(horizontal = 16.dp)
-                        .clip(RoundedCornerShape(20.dp))
-                        .background(Color.White) // Фон выпадающего списка
-                        .clickable { expanded = !expanded } // Клик для раскрытия/сворачивания
+                        .padding(16.dp),
+                    horizontalAlignment = Alignment.CenterHorizontally
                 ) {
-                    // Выбранный элемент
-                    Text(
-                        text = selectedItem,
-                        modifier = Modifier.padding(16.dp),
-                        color = Color.Gray // Цвет текста выбранного элемента
+                    OutlinedTextField(
+                        value = selectedItem,
+                        onValueChange = { selectedItem = it },
+                        readOnly = true,
+                        label = { Text("Пол") },
+                        trailingIcon = {
+                            IconButton(onClick = { expanded = !expanded }) {
+                                Icon(Icons.Filled.ArrowDropDown, contentDescription = null)
+                            }
+                        },
+                        modifier = Modifier.fillMaxWidth()
                     )
 
-                    // Иконка раскрытия/сворачивания
-                    Icon(
-                        imageVector = if (expanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
-                        contentDescription = null,
+                    DropdownMenu(
+                        expanded = expanded,
+                        onDismissRequest = { expanded = false },
                         modifier = Modifier
-                            .align(Alignment.BottomEnd)
-                            .padding(16.dp)
-                    )
-
-//                    DropdownMenu(
-//                        expanded = expanded,
-//                        onDismissRequest = { expanded = false },
-//                        modifier = Modifier
-//                            .fillMaxWidth()
-//                            .background(Color.White) // Фон выпадающего меню
-//                    ) {
-//                        // Элементы выпадающего списка
-//                        listOf("Мужской", "Женский").forEach { item ->
-//                            DropdownMenuItem(
-//                                onClick = {
-//                                    selectedItem = item
-//                                    expanded = false
-//                                }
-//                            ) {
-//                                Text(text = item)
-//                            }
-//                        }
-//                    }
+                            .fillMaxWidth()
+                            .width(200.dp)
+                    ) {
+                        genderOptions.forEach { (gender, id) ->
+                            DropdownMenuItem(
+                                onClick = {
+                                    selectedItem = gender
+                                    id_genderFK.value = id
+                                    expanded = false
+                                },
+                                text = {
+                                    Text(text = gender)
+                                }
+                            )
+                        }
+                    }
                 }
 
+
+
                 Spacer(modifier = Modifier.height(10.dp))
 
                 OutlinedTextField(
@@ -229,47 +240,12 @@ fun CreatingUser(navController: NavHostController) {
                     label = { Text("О себе") },
                     modifier = Modifier
                         .fillMaxWidth()
-                        .height(45.dp)
                         .padding(horizontal = 16.dp)
                         .clip(RoundedCornerShape(20.dp))
                 )
                 Spacer(modifier = Modifier.height(10.dp))
-                Column(
-//                    modifier = Modifier
-//                        .fillMaxSize()
-//                        .padding(16.dp),
-                    horizontalAlignment = Alignment.CenterHorizontally
-                ) {
-                    Button(onClick = { launcher.launch("image/*") }) {
-                        Text("Выбрать фото")
-                    }
-                    Spacer(modifier = Modifier.height(0.dp))
-                    if (imageBitmap != null) {
-                        Image(
-                            painter = rememberImagePainter(
-                                data = imageBitmap
-                            ),
-                            contentDescription = "Selected Image",
-                            modifier = Modifier
-                                .width(50.dp)
-                                .height(50.dp)
-                        )
-                    } else if (selectedImageUri != null) {
-//                        Image(
-//                            painter = rememberImagePainter(
-//                                request = ImageRequest.Builder(context)
-//                                    .data(selectedImageUri)
-//                                    .build()
-//                            ),
-//                            contentDescription = "Selected Image",
-//                            modifier = Modifier
-//                                .width(200.dp)
-//                                .height(200.dp)
-//                        )
-                    } else {
-                        Text("Выберите фото", fontSize = 18.sp)
-                    }
-                }
+
+
 
 
 

+ 0 - 1
app/src/main/java/com/example/iplace/model/Place.kt

@@ -11,7 +11,6 @@ data class Place (
     val id_categoryFK: Int,
     val description: String,
     val address: String,
-    val id_img_placeFK: Int,
     val mapping: String,
     val author: String,
 )