소스 검색

Доделала роли, вставку данных

Blueris 1 개월 전
부모
커밋
0b73ab35d7

+ 8 - 0
.idea/deploymentTargetSelector.xml

@@ -4,6 +4,14 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
+        <DropdownSelection timestamp="2024-09-19T15:51:56.112685800Z">
+          <Target type="DEFAULT_BOOT">
+            <handle>
+              <DeviceId pluginId="PhysicalDevice" identifier="serial=3f99f7b3" />
+            </handle>
+          </Target>
+        </DropdownSelection>
+        <DialogSelection />
       </SelectionState>
     </selectionStates>
   </component>

+ 24 - 0
.idea/inspectionProfiles/Project_Default.xml

@@ -1,6 +1,30 @@
 <component name="InspectionProjectProfileManager">
   <profile version="1.0">
     <option name="myName" value="Project Default" />
+    <inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
     <inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
       <option name="composableFile" value="true" />
       <option name="previewFile" value="true" />

+ 2 - 0
app/build.gradle.kts

@@ -63,6 +63,8 @@ dependencies {
     implementation(libs.androidx.ui.tooling.preview)
     implementation(libs.androidx.material3)
     implementation(libs.androidx.storage)
+    implementation(libs.androidx.navigation.compose)
+    implementation(libs.androidx.runtime.livedata)
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
     androidTestImplementation(libs.androidx.espresso.core)

+ 10 - 0
app/src/main/java/com/example/test/model/Admin.kt

@@ -0,0 +1,10 @@
+package com.example.test.model
+
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class Admin(
+    val id: Int,
+    val id_user: String?
+)
+

+ 29 - 0
app/src/main/java/com/example/test/navigation/Navigation.kt

@@ -0,0 +1,29 @@
+package com.example.test.navigation
+
+import androidx.compose.runtime.Composable
+import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
+import androidx.navigation.compose.rememberNavController
+import com.example.test.view.ui.view.MainViewModel
+import com.example.test.view.ui.view.components.auth
+import com.example.test.view.ui.view.components.FilmsList
+import com.example.test.view.ui.view.components.Insert
+
+/*Класс для перемещения по страницам*/
+@Composable
+fun Navigation() {
+    val navController = rememberNavController()
+    NavHost(navController = navController,
+        startDestination = "auth")
+    {
+        composable("auth") {
+            auth(navController, MainViewModel())
+        }
+        composable("FilmList"){ // Update the route name to "FilmList"
+            FilmsList(navController)
+        }
+        composable("Insert"){ // Update the route name to "FilmList"
+            Insert(navController)
+        }
+    }
+}

+ 3 - 10
app/src/main/java/com/example/test/view/ui/view/MainActivity.kt

@@ -6,18 +6,11 @@ import androidx.activity.compose.setContent
 import androidx.activity.enableEdgeToEdge
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.padding
-import androidx.compose.material3.Scaffold
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
 import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.tooling.preview.Preview
+import com.example.test.navigation.Navigation
 import com.example.test.view.ui.view.theme.TestTheme
 import com.example.test.view.ui.view.components.FilmsList
 import com.example.test.view.ui.view.components.auth
-import com.example.test.view.ui.view.theme.TestTheme
 
 class MainActivity : ComponentActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -29,8 +22,8 @@ class MainActivity : ComponentActivity() {
                     verticalArrangement = Arrangement.Center,
                     horizontalAlignment = Alignment.CenterHorizontally
                 ) {
-                   auth()
-                   FilmsList()
+
+                   Navigation()
                 }
                 }
             }

+ 19 - 3
app/src/main/java/com/example/test/view/ui/view/MainViewModel.kt

@@ -1,5 +1,11 @@
 package com.example.test.view.ui.view
 
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.ui.Alignment
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
 import com.example.test.domain.utlls.Constant
@@ -8,8 +14,12 @@ import io.github.jan.supabase.gotrue.providers.builtin.Email
 import io.github.jan.supabase.gotrue.providers.builtin.OTP
 import io.github.jan.supabase.postgrest.from
 import kotlinx.coroutines.launch
+import com.example.test.view.ui.view.components.FilmsList
+import com.example.test.view.ui.view.components.auth
 
-class MainViewModel():ViewModel() {
+class MainViewModel(): ViewModel() {
+    private val _loginResult = MutableLiveData<Boolean>()
+    val loginResult: LiveData<Boolean> = _loginResult
 
     fun onSignInEmailCode(emailUser: String) {
         viewModelScope.launch {
@@ -27,7 +37,7 @@ class MainViewModel():ViewModel() {
         }
     }
 
-    fun onSignInEmailPassword(emailUser: String, passwordUser: String) {
+    fun onSignInEmailPassword(emailUser: String, passwordUser: String): Boolean {
         viewModelScope.launch {
             try {
                 val user = Constant.supabase.auth.signInWith(Email) {
@@ -37,13 +47,16 @@ class MainViewModel():ViewModel() {
                 println(user.toString())
                 println(Constant.supabase.auth.currentUserOrNull()!!.id)
                 println("Success")
+                _loginResult.postValue(true)
             } catch (e: Exception) {
                 println("Error")
                 println(e.message.toString())
+                _loginResult.postValue(false)
             }
         }
+        return _loginResult.value ?: false
     }
-    fun onSignUpEmail(emailUser: String, passwordUser: String) {
+    fun onSignUpEmail(emailUser: String, passwordUser: String): Boolean {
         viewModelScope.launch {
             try{
                 var  user =  Constant.supabase.auth.signUpWith(Email) {
@@ -53,12 +66,15 @@ class MainViewModel():ViewModel() {
                 println(user.toString())
                 println(Constant.supabase.auth.currentUserOrNull()!!.id)
                 println("Success")
+                _loginResult.postValue(true)
             }
             catch (e: Exception) {
                 println("Error")
                 println(e.message.toString())
+                _loginResult.postValue(false)
             }
 
         }
+        return _loginResult.value ?: false
     }
 }

+ 123 - 66
app/src/main/java/com/example/test/view/ui/view/components/FilmList.kt

@@ -6,12 +6,14 @@ import com.example.test.domain.utlls.Constant
 
 import android.util.Log
 import androidx.compose.foundation.Image
+import androidx.compose.foundation.border
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
+import androidx.compose.material3.Button
 import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
@@ -22,38 +24,45 @@ import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.RectangleShape
 import androidx.compose.ui.layout.ContentScale
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.navigation.NavHostController
 import coil.compose.AsyncImagePainter
 import coil.compose.rememberAsyncImagePainter
 import coil.request.ImageRequest
 import coil.size.Size
+import com.example.test.model.Admin
 import com.example.test.model.genre
+import io.github.jan.supabase.gotrue.auth
+import androidx.navigation.NavController
 
 import io.github.jan.supabase.postgrest.from
-import io.github.jan.supabase.postgrest.query.PostgrestQueryBuilder
-import io.github.jan.supabase.postgrest.result.PostgrestResult
 import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.selects.select
 import kotlinx.coroutines.withContext
 
 @Composable
-fun FilmsList() {
-    var Films1 by remember { mutableStateOf<List<films>>(listOf()) }
-    var Rating1 by remember { mutableStateOf<List<rating>>(listOf()) }
-    var Genre1 by remember { mutableStateOf<List<genre>>(listOf()) }
+fun FilmsList(navHost: NavHostController) {
+    var films by remember { mutableStateOf<List<films>>(listOf()) }
+    var ratings by remember { mutableStateOf<List<rating>>(listOf()) }
+    var genres by remember { mutableStateOf<List<genre>>(listOf()) }
+    var users by remember { mutableStateOf<List<Admin>>(listOf()) }
 
     LaunchedEffect(Unit) {
         withContext(Dispatchers.IO) {
             try {
-                Films1 = Constant.supabase.from("films")
+                films = Constant.supabase.from("films")
                     .select().decodeList<films>()
-                Rating1 = Constant.supabase.from("rating")
+                ratings = Constant.supabase.from("rating")
                     .select().decodeList<rating>()
-                Genre1 = Constant.supabase.from("genre")
+                genres = Constant.supabase.from("genre")
                     .select().decodeList<genre>()
-                Films1.forEach { film ->
+                users = Constant.supabase.from("Admin")
+                    .select().decodeList<Admin>()
+                films.forEach { film ->
                     Log.d("C", film.films_name)
                 }
             } catch (e: Exception) {
@@ -61,66 +70,114 @@ fun FilmsList() {
             }
         }
     }
-    LazyColumn {
 
+    LazyColumn {
         items(
-            Films1,
-            key = { films -> films.id },
-        ) { films ->
-            val imageState = rememberAsyncImagePainter(
-                model = ImageRequest.Builder(LocalContext.current).data(films.foto)
-                    .size(Size.ORIGINAL).build()
-            ).state
-            if (imageState is AsyncImagePainter.State.Error) {
-                Box(
-                    modifier = Modifier
-                        .fillMaxWidth()
-                        .height(200.dp),
-                    contentAlignment = Alignment.Center
-                ) {
-                    CircularProgressIndicator()
-                }
-            }
+            films,
+            key = { film -> film.id },
+        ) { film ->
+            FilmItem(
+                film = film,
+                ratings = ratings,
+                genres = genres,
+                users = users,
+                navHost = navHost,
+            )
+        }
+    }
+}
 
-            if (imageState is AsyncImagePainter.State.Success) {
-                Image(
-                    modifier = Modifier
-                        .fillMaxWidth()
-                        .height(200.dp),
-                    painter = imageState.painter,
-                    contentDescription = "",
-                    contentScale = ContentScale.Crop
-                )
-            }
+@Composable
+fun FilmItem(
+    film: films,
+    ratings: List<rating>,
+    genres: List<genre>,
+    users: List<Admin>,
+    navHost: NavHostController,
+) {
+    val imageState = rememberAsyncImagePainter(
+        model = ImageRequest.Builder(LocalContext.current).data(film.foto)
+            .size(Size.ORIGINAL).build()
+    ).state
+
+    if (imageState is AsyncImagePainter.State.Error) {
+        Box(
+            modifier = Modifier
+                .fillMaxWidth()
+                .height(200.dp),
+            contentAlignment = Alignment.Center
+        ) {
+            CircularProgressIndicator()
+        }
+    }
+
+    if (imageState is AsyncImagePainter.State.Success) {
+        Image(
+            modifier = Modifier
+                .fillMaxWidth()
+                .height(200.dp),
+            painter = imageState.painter,
+            contentDescription = "",
+            contentScale = ContentScale.Crop
+        )
+    }
+
+    Text(
+        film.films_name,
+        modifier = Modifier
+            .padding(8.dp)
+            .border(width = 1.dp, color = Color.Gray, shape = RectangleShape)
+            .padding(horizontal = 4.dp, vertical = 2.dp),
+    )
+
+    val ratingId = film.rating
+    val rating = ratings.find { it.id == ratingId }
+    if (rating != null) {
+        Text(
+            "Рейтинг: ${rating.rating}",
+            modifier = Modifier
+                .padding(8.dp)
+                .border(width = 1.dp, color = Color.Gray, shape = RectangleShape)
+                .padding(horizontal = 4.dp, vertical = 2.dp),
+        )
+        val genreId = film.genre
+        val genre = genres.find { it.id == genreId }
+        if (genre != null) {
             Text(
-                films.films_name,
-                modifier = Modifier.padding(8.dp),
+                "Жанр: ${genre.genre}",
+                modifier = Modifier
+                    .padding(8.dp)
+                    .border(width = 1.dp, color = Color.Gray, shape = RectangleShape)
+                    .padding(horizontal = 4.dp, vertical = 2.dp),
             )
-            val ratingId = films.rating
-            val rating = Rating1.find { it.id == ratingId }
-            if (rating != null) {
-                Text(
-                    "Рейтинг: ${rating.rating}",
-                    modifier = Modifier.padding(8.dp),
-                )
-                val genreId = films.genre
-                val genre = Genre1.find { it.id == genreId }
-                if (genre != null) {
-                    Text(
-                        "Жанр: ${genre.genre}",
-                        modifier = Modifier.padding(8.dp),
-                    )
-                } else {
-                    Text(
-                        "Жанр не найден",
-                        modifier = Modifier.padding(8.dp),
-                    )
-                }
-            } else {
-                Text(
-                    "Рейтинг не найден",
-                    modifier = Modifier.padding(8.dp),
-                )
+        } else {
+            Text(
+                "Жанр не найден",
+                modifier = Modifier
+                    .padding(8.dp)
+                    .border(width = 1.dp, color = Color.Gray, shape = RectangleShape)
+                    .padding(horizontal = 4.dp, vertical = 2.dp),
+            )
+        }
+    } else {
+        Text(
+            "Рейтинг не найден",
+            modifier = Modifier
+                .padding(8.dp)
+                .border(width = 1.dp, color = Color.Gray, shape = RectangleShape)
+                .padding(horizontal = 4.dp, vertical = 2.dp),
+        )
+    }
+
+    val userId = Constant.supabase.auth.currentUserOrNull()?.id
+    val userIdString = userId.toString()
+    if (userId != null) {
+        val user = users.find { it.id_user == userIdString }
+        if (user != null) {
+            Button(onClick = {
+                navHost.navigate("Insert")
+            }) {
+                Text("Перейти на страницу изменений", fontSize = 25.sp, color = Color.White)
             }
         }
     }

+ 141 - 0
app/src/main/java/com/example/test/view/ui/view/components/Insert.kt

@@ -0,0 +1,141 @@
+package com.example.test.view.ui.view.components
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.runtime.Composable
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.RadioButton
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextField
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.navigation.NavHostController
+import com.example.test.domain.utlls.Constant
+import com.example.test.model.films
+import io.github.jan.supabase.postgrest.from
+import kotlinx.coroutines.launch
+import org.w3c.dom.Text
+
+
+@Composable
+fun Insert(navHost: NavHostController) {
+    val context = LocalContext.current
+    val supabase = Constant.supabase
+    val scope = rememberCoroutineScope()
+
+    val filmName = remember { mutableStateOf("") }
+    val ratingId = remember { mutableStateOf(1) }
+    val genreId = remember { mutableStateOf(1) }
+    val fotoUrl = remember { mutableStateOf("") }
+
+    Column(
+        modifier = Modifier
+            .fillMaxWidth()
+            .padding(top = 300.dp, start = 15.dp, end = 15.dp)
+            .background(Color.DarkGray.copy(alpha = 0.2f))
+            .fillMaxWidth(),
+        verticalArrangement = Arrangement.Center,
+        horizontalAlignment = Alignment.CenterHorizontally
+    ) {
+        TextField(
+            value = filmName.value,
+            onValueChange = { filmName.value = it },
+            label = { Text("Название фильма", fontSize = 18.sp, color = Color.White) },
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(horizontal = 16.dp)
+                .background(Color.White, shape = RoundedCornerShape(8.dp))
+                .border(width = 1.dp, color = Color.White, shape = RoundedCornerShape(8.dp))
+        )
+        Spacer(modifier = Modifier.height(8.dp))
+        TextField(
+            value = ratingId.value.toString(),
+            enabled = false,
+            onValueChange = { ratingId.value = it.toInt() },
+            label = { Text("Рейтинг", fontSize = 18.sp, color = Color.White) },
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(horizontal = 16.dp)
+                .background(Color.White, shape = RoundedCornerShape(8.dp))
+                .border(width = 1.dp, color = Color.White, shape = RoundedCornerShape(8.dp))
+        )
+        Spacer(modifier = Modifier.height(8.dp))
+        RatingOptions(ratingId)
+        TextField(
+            value = genreId.value.toString(),
+            enabled = false,
+            onValueChange = { genreId.value = it.toInt() },
+            label = { Text("Жанр", fontSize = 18.sp, color = Color.White) },
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(horizontal = 16.dp)
+                .background(Color.White, shape = RoundedCornerShape(8.dp))
+                .border(width = 1.dp, color = Color.White, shape = RoundedCornerShape(8.dp))
+        )
+        Spacer(modifier = Modifier.height(8.dp))
+        RatingOptions(genreId)
+        TextField(
+            value = fotoUrl.value,
+            onValueChange = { fotoUrl.value = it },
+            label = { Text("Ссылка на фото", fontSize = 18.sp, color = Color.White) },
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(horizontal = 16.dp)
+                .background(Color.White, shape = RoundedCornerShape(8.dp))
+                .border(width = 1.dp, color = Color.White, shape = RoundedCornerShape(8.dp))
+        )
+        Spacer(modifier = Modifier.height(16.dp))
+        Button(onClick = {
+            scope.launch {
+                val count = supabase.from("films").select().data.count()
+                val newFilm = films(
+                    id = count.toInt() + 1,
+                    films_name = filmName.value,
+                    foto = fotoUrl.value.ifBlank { null },
+                    rating = ratingId.value,
+                    genre = genreId.value
+                )
+                supabase.from("films").insert(newFilm)
+            }
+        })
+        {
+            Text("Подтвердить", fontSize = 25.sp, color = Color.White)
+        }
+        ButtonDefaults.buttonColors(Color.White)
+    }
+}
+
+@Composable
+fun RatingOptions(selectedId: MutableState<Int>) {
+    val options = listOf(1, 2, 3, 4, 5)
+
+    Row {
+        options.forEach { option ->
+            RadioButton(
+                selected = selectedId.value == option,
+                onClick = { selectedId.value = option },
+
+            )
+            Text(option.toString())
+            Spacer(modifier = Modifier.width(8.dp))
+        }
+    }
+}

+ 84 - 19
app/src/main/java/com/example/test/view/ui/view/components/auth.kt

@@ -1,79 +1,144 @@
 package com.example.test.view.ui.view.components
 
+import android.text.style.BackgroundColorSpan
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
 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.material3.TextField
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.getValue
+import androidx.compose.runtime.livedata.observeAsState
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
 import androidx.compose.ui.Alignment
+import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.TextStyle
 import androidx.compose.ui.text.input.PasswordVisualTransformation
 import androidx.compose.ui.text.input.VisualTransformation
-import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import androidx.navigation.NavController
+import androidx.navigation.NavHostController
 import com.example.test.view.ui.view.MainViewModel
 import com.example.test.R
 
 
-@Preview
 @Composable
-fun auth() {
+fun auth(navController: NavController, viewModel: MainViewModel)  {
     val viewModel = MainViewModel()
     val email = remember { mutableStateOf("") }
     val password = remember { mutableStateOf("") }
+    var showError = remember { mutableStateOf(false) }
     Column(
-        Modifier.padding(top = 30.dp, start = 15.dp, end = 15.dp),
+        Modifier
+            .padding(top = 300.dp, start = 15.dp, end = 15.dp)
+            .background(Color.DarkGray.copy(alpha = 0.2f))
+            .fillMaxWidth(),
         verticalArrangement = Arrangement.Center,
         horizontalAlignment = Alignment.CenterHorizontally
 
     ) {
         TextField(
             value = email.value,
-            textStyle = TextStyle(fontSize = 25.sp),
-            onValueChange = { newText -> email.value = newText }
+            textStyle = TextStyle(fontSize = 25.sp, color = Color.White),
+            onValueChange = { newText -> email.value = newText },
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(horizontal = 16.dp)
+                .background(
+                    Color.White,
+                    shape = RoundedCornerShape(8.dp)
+                )
+                .border(
+                    width = 1.dp,
+                    color = Color.White,
+                    shape = RoundedCornerShape(8.dp)
+                )
         )
         var passwordVisibility: Boolean by remember { mutableStateOf(false) }
-        TextField(value = password.value,
+        TextField(
+            value = password.value,
             visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(),
             leadingIcon = {
                 IconButton(onClick = {
                     passwordVisibility = !passwordVisibility
                 }) {
-                    if(passwordVisibility) {
+                    if (passwordVisibility) {
                         Icon(
                             painter = painterResource(id = R.drawable.baseline_person_24),
-                            contentDescription = ""
+                            contentDescription = "",
+                            tint = Color.White
                         )
-                    }
-                    else {
+                    } else {
                         Icon(
                             painter = painterResource(id = R.drawable.baseline_person_off_24),
-                            contentDescription = ""
+                            contentDescription = "",
+                            tint = Color.White
                         )
                     }
                 }
             },
-            onValueChange = { newText -> password.value = newText })
+            onValueChange = { newText -> password.value = newText },
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(horizontal = 16.dp)
+                .background(
+                    Color.White,
+                    shape = RoundedCornerShape(8.dp)
+                )
+                .border(
+                    width = 1.dp,
+                    color = Color.White,
+                    shape = RoundedCornerShape(8.dp)
+                )
+        )
+
         Button(onClick = {
-            viewModel.onSignInEmailPassword(email.value,password.value)
-        }){
-            Text("SigIn", fontSize = 25.sp)
+            if (viewModel.onSignInEmailPassword(email.value, password.value)) {
+                showError.value = false
+                navController.navigate("FilmList")
+            }
+            else
+            {
+                showError.value = true
+            }
+        }) {
+            Text("Вход", fontSize = 25.sp, color = Color.White)
         }
+                ButtonDefaults.buttonColors(Color.White)
+
         Button(onClick = {
-            viewModel.onSignUpEmail(email.value,password.value)
-        }){
-            Text("SigUp", fontSize = 25.sp)
+            if (viewModel.onSignUpEmail(email.value, password.value)) {
+                showError.value = false
+                navController.navigate("FilmList")
+            }
+            else
+            {
+                showError.value = true
+            }
+        }) {
+            Text("Регистрация", fontSize = 25.sp, color = Color.White)
+        }
+                ButtonDefaults.buttonColors(Color.White)
+        if (showError.value) {
+            Text(
+                text = "Неверные данные",
+                color = Color.Red,
+                fontSize = 18.sp
+            )
         }
     }
 }

+ 6 - 6
app/src/main/java/com/example/test/view/ui/view/theme/Color.kt

@@ -2,10 +2,10 @@ package com.example.test.view.ui.view.theme
 
 import androidx.compose.ui.graphics.Color
 
-val Purple80 = Color(0xFFD0BCFF)
-val PurpleGrey80 = Color(0xFFCCC2DC)
-val Pink80 = Color(0xFFEFB8C8)
+val Purple80 = Color(0xFF3F51B5)
+val PurpleGrey80 = Color(0xFF8444E5)
+val Pink80 = Color(0xFF6FACFF)
 
-val Purple40 = Color(0xFF6650a4)
-val PurpleGrey40 = Color(0xFF625b71)
-val Pink40 = Color(0xFF7D5260)
+val Purple40 = Color(0xFFB29CE8)
+val PurpleGrey40 = Color(0xFFAEA9B9)
+val Pink40 = Color(0xFF857E80)

+ 4 - 0
gradle/libs.versions.toml

@@ -16,6 +16,8 @@ storageKt = "2.0.4"
 xmodule_z = "2.6.0"
 volley = "1.2.1"
 storage = "1.4.2"
+navigationCompose = "2.8.1"
+runtimeLivedata = "1.7.2"
 
 [libraries]
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -47,6 +49,8 @@ supabase-postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt"
 xmodule_z = { module = "io.github.jan-tennert.supabase:[module]", version.ref = "xmodule_z" }
 volley = { group = "com.android.volley", name = "volley", version.ref = "volley" }
 androidx-storage = { group = "androidx.test.services", name = "storage", version.ref = "storage" }
+androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
+androidx-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "runtimeLivedata" }
 
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }