Sfoglia il codice sorgente

feat: change navigation, add check login and password

chirikh 1 settimana fa
parent
commit
0ba7dadee4

+ 8 - 0
Development/.idea/deploymentTargetSelector.xml

@@ -4,6 +4,14 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
+        <DropdownSelection timestamp="2024-11-18T08:51:58.351051900Z">
+          <Target type="DEFAULT_BOOT">
+            <handle>
+              <DeviceId pluginId="LocalEmulator" identifier="path=C:\AndroidSettings\.android\avd\Pixel_8_Pro_API_34.avd" />
+            </handle>
+          </Target>
+        </DropdownSelection>
+        <DialogSelection />
       </SelectionState>
     </selectionStates>
   </component>

+ 6 - 1
Development/app/src/main/java/com/example/development/MainActivity.kt

@@ -24,6 +24,7 @@ import com.example.development.mainActivity.components.PasswordRecovery2
 import com.example.development.mainActivity.components.PasswordRecovery3
 import com.example.development.mainActivity.components.RegistrationScreen2
 import com.example.development.mainActivity.components.Reviews
+import com.example.development.mainActivity.components.SplashScreen
 import com.example.development.mainActivity.components.TableReserve
 import com.example.development.mainActivity.components.TableReserve2
 import com.example.development.mainActivity.components.UserProfile
@@ -41,8 +42,12 @@ class MainActivity : ComponentActivity() {
 
                     NavHost(
                         navController = navController,
-                        startDestination = "SplashScreen"
+                        startDestination = "RegistrationScreen"
                     ){
+                        composable("SplashScreen")
+                        {
+                            SplashScreen(navController, viewModel)
+                        }
                         composable("RegistrationScreen")
                         {
                             RegistrationScreen(navController, viewModel)

+ 3 - 2
Development/app/src/main/java/com/example/development/domain/utils/CustomEmaill.kt

@@ -30,7 +30,8 @@ fun CustomEmail(
         modifier = Modifier
             .clip(RoundedCornerShape(10.dp))
             .background(Color(0XFFE8EFFF))
-
+            .width(300.dp)
+            .height(50.dp)
     ) {
         OutlinedTextField(
             keyboardOptions = KeyboardOptions(
@@ -55,7 +56,7 @@ fun CustomEmail(
                 .fillMaxWidth(1f)
                 .background(Color(0XFFF5F5F9))
                 .height(height = 50.dp)
-                .width(width = 316.dp),
+                .width(width = 80.dp),
             placeholder = {
                 Text(
                     modifier = Modifier.fillMaxWidth(),

+ 3 - 2
Development/app/src/main/java/com/example/development/domain/utils/CustomPassword.kt

@@ -39,7 +39,8 @@ fun CustomPassword(
         modifier = Modifier
             .clip(RoundedCornerShape(10.dp))
             .background(Color(0XFFE8EFFF))
-
+            .width(300.dp)
+            .height(50.dp)
     ) {
         OutlinedTextField(
             keyboardOptions = KeyboardOptions(
@@ -81,7 +82,7 @@ fun CustomPassword(
                 .fillMaxWidth(1f)
                 .background(Color(0XFFF5F5F9))
                 .height(height = 50.dp)
-                .width(width = 316.dp),
+                .width(width = 200.dp),
             placeholder = {
                 Text(
                     modifier = Modifier.fillMaxWidth(),

+ 4 - 2
Development/app/src/main/java/com/example/development/mainActivity/MainViewModel.kt

@@ -19,7 +19,7 @@ import kotlinx.coroutines.launch
 
 class MainViewModel():ViewModel() {
     private val _users = mutableStateOf(listOf<User>())
-    var users = listOf<User>()
+    val users: State<List<User>> = _users
 
     fun onSignInEmailCode(emailUser: String) {
         viewModelScope.launch {
@@ -150,7 +150,7 @@ class MainViewModel():ViewModel() {
         viewModelScope.launch {
             try{
                 var flag = false
-                users = Constants.supabase.from("Users")
+                _users.value = Constants.supabase.from("Users")
                     .select(){
                         filter{
                             User::UID eq Constants.supabase.auth.currentUserOrNull()!!.id
@@ -165,4 +165,6 @@ class MainViewModel():ViewModel() {
             }
         }
     }
+
+
 }

+ 4 - 3
Development/app/src/main/java/com/example/development/mainActivity/components/AuthorizationPage.kt

@@ -76,7 +76,7 @@ fun AuthorizationScreen(navController: NavHostController, viewModel: MainViewMod
                     "АВТОРИЗАЦИЯ",
                     color = Color.White,
                     modifier = Modifier.padding(bottom = 50.dp),
-                    fontSize = 30.sp,
+                    fontSize = 32.sp,
                     fontWeight = FontWeight.Bold,
                     fontFamily = OldStandart
                 )
@@ -125,6 +125,7 @@ fun AuthorizationScreen(navController: NavHostController, viewModel: MainViewMod
                             viewModel.onSignInEmailPassword(email.value,password.value)
                             viewModel.FindUser()
                             flag.value = true
+                            navController.navigate("MainPage")
                         },
                         shape = RoundedCornerShape(23.dp),
                         border = BorderStroke(1.dp, Color(255,215,0)),
@@ -141,7 +142,7 @@ fun AuthorizationScreen(navController: NavHostController, viewModel: MainViewMod
                     }
                     Button(
                         modifier = Modifier.padding(top = 5.dp).height(50.dp).width(280.dp),
-                        onClick = {},
+                        onClick = {navController.navigate("MainPage")},
                         shape = RoundedCornerShape(23.dp),
                         border = BorderStroke(1.dp, Color(255,215,0, 0)),
                         colors = ButtonDefaults.buttonColors(
@@ -193,7 +194,7 @@ fun AuthorizationScreen(navController: NavHostController, viewModel: MainViewMod
                 Button(
                     modifier = Modifier
                         .padding(top = 10.dp),
-                    onClick = {},
+                    onClick = {navController.navigate("AuthorizationScreen")},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(230, 235, 239,0),
                         contentColor = Color.Gray

+ 7 - 4
Development/app/src/main/java/com/example/development/mainActivity/components/MainPage.kt

@@ -1,6 +1,7 @@
 package com.example.development.mainActivity.components
 
 import android.widget.ScrollView
+import androidx.annotation.Nullable
 import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
@@ -47,8 +48,10 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.navigation.NavHostController
 import com.example.development.R
+import com.example.development.domain.utils.Constants
 import com.example.development.mainActivity.MainViewModel
 import com.example.development.ui.theme.OldStandart
+import io.github.jan.supabase.gotrue.auth
 
 @Composable
 fun MainPage(navController: NavHostController, viewModel: MainViewModel)
@@ -81,7 +84,7 @@ fun MainPage(navController: NavHostController, viewModel: MainViewModel)
                     modifier = Modifier
                         .padding(0.dp)
                         .width(100.dp),
-                    onClick = {},
+                    onClick = {navController.navigate("MenuPage")},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(230, 235, 239, 0),
                         contentColor = Color.Gray
@@ -101,7 +104,7 @@ fun MainPage(navController: NavHostController, viewModel: MainViewModel)
                     modifier = Modifier
                         .padding(0.dp)
                         .width(170.dp),
-                    onClick = {},
+                    onClick = {navController.navigate("TableReserve")},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(230, 235, 239, 0),
                         contentColor = Color.Gray
@@ -122,7 +125,7 @@ fun MainPage(navController: NavHostController, viewModel: MainViewModel)
                 Button(
                     modifier = Modifier
                         .padding(0.dp),
-                    onClick = {},
+                    onClick = {navController.navigate("UserProfile")},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(230, 235, 239, 0),
                         contentColor = Color.Gray
@@ -172,7 +175,7 @@ fun MainPage(navController: NavHostController, viewModel: MainViewModel)
                 )
                 Row(modifier = Modifier.horizontalScroll(rememberScrollState()), verticalAlignment = Alignment.Top, horizontalArrangement = Arrangement.Center)
                 {
-                    Image(painter = painterResource(id = R.drawable.img_1),
+                    Image(painter = painterResource(id = R.drawable.img),
                         contentDescription = "",
                         contentScale = ContentScale.FillWidth,
                         modifier = Modifier

+ 2 - 2
Development/app/src/main/java/com/example/development/mainActivity/components/MenuPage.kt

@@ -70,7 +70,7 @@ fun MenuPage(navController: NavHostController, viewModel: MainViewModel)
     var files: List<BucketItem>? = null
     LaunchedEffect(Unit) {
         withContext(Dispatchers.IO) {
-            menu = Constants.supabase.from("posts")
+            menu = Constants.supabase.from("menu")
                 .select().decodeList<Menu>()
             menu.forEach { it ->
                 Log.d("P", it.name)
@@ -110,7 +110,7 @@ fun MenuPage(navController: NavHostController, viewModel: MainViewModel)
                 Button(
                     modifier = Modifier
                         .padding(0.dp),
-                    onClick = {},
+                    onClick = {navController.navigate("MainPage")},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(255, 215, 0, 0),
                         contentColor = Color.Gray

+ 10 - 9
Development/app/src/main/java/com/example/development/mainActivity/components/RegistrationScreen.kt

@@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.width
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
 import androidx.compose.material.icons.filled.Person
+import androidx.compose.material.icons.filled.Phone
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults
 import androidx.compose.material3.Icon
@@ -84,7 +85,7 @@ fun RegistrationScreen(navController: NavHostController, viewModel: MainViewMode
                     "РЕГИСТРАЦИЯ",
                     color = Color.White,
                     modifier = Modifier.padding(bottom = 50.dp),
-                    fontSize = 30.sp,
+                    fontSize = 32.sp,
                     fontWeight = FontWeight.Bold,
                     fontFamily = OldStandart
                 )
@@ -115,9 +116,9 @@ fun RegistrationScreen(navController: NavHostController, viewModel: MainViewMode
                     Button(
                         modifier = Modifier.padding(top = 15.dp).height(50.dp),
                         onClick = {
-                            if (flag.value) { viewModel.onSignUpEmail(email.value,password.value) }
+                            if (flag.value) { viewModel.onSignUpEmail(email.value,password.value);
+                                navController.navigate("RegistrationScreen2")}
                             else { Toast.makeText(context, "Пароли не совпадают", Toast.LENGTH_SHORT).show() }
-                            navController.navigate("RegistrationScreen2")
                         },
                         shape = RoundedCornerShape(23.dp),
                         border = BorderStroke(1.dp, Color(255,215,0)),
@@ -256,7 +257,7 @@ fun RegistrationScreen2(navController: NavHostController, viewModel: MainViewMod
                         .fillMaxWidth(1f)
                         .background(Color(0XFFF5F5F9))
                         .height(height = 56.dp)
-                        .width(width = 320.dp),
+                        .width(width = 200.dp),
                     isError = surnameFlag.value,
                     placeholder = {
                         Text(
@@ -316,8 +317,8 @@ fun RegistrationScreen2(navController: NavHostController, viewModel: MainViewMod
 
             }
             Column {
-                OutlinedTextField(value = phoneNumber.value, onValueChange = { it -> name.value = it },
-                    leadingIcon = { Icon(Icons.Filled.Person, contentDescription = "Имя") },
+                OutlinedTextField(value = phoneNumber.value, onValueChange = { it -> phoneNumber.value = it },
+                    leadingIcon = { Icon(Icons.Filled.Phone, contentDescription = "Номер телефона") },
                     colors = TextFieldDefaults.colors(
                         focusedContainerColor = Color(0XFFF5F5F9),
                         focusedIndicatorColor = Color(0xFFEBEBEB),
@@ -345,11 +346,11 @@ fun RegistrationScreen2(navController: NavHostController, viewModel: MainViewMod
                     }
                 )
 
-                if (name.value.isEmpty()) {
-                    nameFlag.value = true
+                if (phoneNumber.value.isEmpty()) {
+                    phoneFlag.value = true
                     Text("Введите номер телефона", color = Color.Red, fontSize = 10.sp)
                 } else {
-                    nameFlag.value = false
+                    phoneFlag.value = false
                 }
 
             }

+ 1 - 1
Development/app/src/main/java/com/example/development/mainActivity/components/Reviews.kt

@@ -89,7 +89,7 @@ fun Reviews(navController: NavHostController, viewModel: MainViewModel)
                 Button(
                     modifier = Modifier
                         .padding(0.dp),
-                    onClick = {},
+                    onClick = {navController.navigate("MainPage")},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(255, 215, 0, 0),
                         contentColor = Color.Gray

+ 12 - 8
Development/app/src/main/java/com/example/development/mainActivity/components/UserProfile.kt

@@ -97,42 +97,46 @@ fun UserProfile(navController: NavHostController, viewModel: MainViewModel){
             {
                 Button(
                     modifier = Modifier
-                        .padding(0.dp),
+                        .padding()
+                        .height(70.dp),
                     onClick = {},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(255, 215, 0),
                         contentColor = Color.Gray
                     ),
+                    shape = RoundedCornerShape(10.dp),
                     border = BorderStroke(0.dp, color = Color(255, 215, 0))
                 )
                 {
                     Text(
-                        "Персональные данные",
-                        fontSize = 16.sp,
+                        "Персональные\nданные",
+                        fontSize = 20.sp,
                         color = Color.White,
                         fontWeight = FontWeight.Normal,
+                        fontFamily = OldStandart,
                         textAlign = TextAlign.Center,
-                        fontFamily = OldStandart
                     )
                 }
                 Button(
                     modifier = Modifier
-                        .padding(0.dp),
+                        .padding()
+                        .height(70.dp),
                     onClick = {},
                     colors = ButtonDefaults.buttonColors(
                         containerColor = Color(230, 235, 239, 0),
                         contentColor = Color.Gray
                     ),
+                    shape = RoundedCornerShape(10.dp),
                     border = BorderStroke(0.dp, color = Color(230, 235, 239, 0))
                 )
                 {
                     Text(
-                        "История бронирования",
-                        fontSize = 16.sp,
+                        "История\nбронирования",
+                        fontSize = 20.sp,
                         color = Color.White,
                         fontWeight = FontWeight.Normal,
+                        fontFamily = OldStandart,
                         textAlign = TextAlign.Center,
-                        fontFamily = OldStandart
                     )
                 }
             }

BIN
Development/app/src/main/res/drawable/img.png