|
@@ -1,5 +1,6 @@
|
|
|
package com.example.mystictale.Screen.registration
|
|
|
|
|
|
+import android.widget.Toast
|
|
|
import androidx.compose.foundation.Image
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.Box
|
|
@@ -14,29 +15,40 @@ import androidx.compose.foundation.layout.width
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonColors
|
|
|
+import androidx.compose.material3.CircularProgressIndicator
|
|
|
import androidx.compose.material3.LinearProgressIndicator
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.getValue
|
|
|
+import androidx.compose.runtime.mutableStateOf
|
|
|
+import androidx.compose.runtime.remember
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.draw.paint
|
|
|
+import androidx.compose.ui.graphics.BlendMode.Companion.Screen
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.StrokeCap
|
|
|
import androidx.compose.ui.layout.ContentScale
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
import androidx.navigation.NavController
|
|
|
import com.example.mystictale.R
|
|
|
+import com.example.mystictale.ViewModels.AuthViewModel
|
|
|
+import com.example.mystictale.models.UserState
|
|
|
import com.example.mystictale.navigation.Screens
|
|
|
-import com.example.mystictale.resources.ChooseGender
|
|
|
+import com.example.mystictale.resources.components.ChooseGender
|
|
|
import com.example.mystictale.ui.theme.DarkPurple
|
|
|
import com.example.mystictale.ui.theme.OpenSans
|
|
|
|
|
|
@Composable
|
|
|
-fun RegistrationGender(navController: NavController) {
|
|
|
+fun RegistrationGender(navController: NavController, viewModel: AuthViewModel) {
|
|
|
+ val userState by viewModel.userState
|
|
|
+ val flag = remember { mutableStateOf(false) }
|
|
|
+ val context = LocalContext.current
|
|
|
Column(
|
|
|
Modifier
|
|
|
.fillMaxSize()
|
|
@@ -106,12 +118,12 @@ fun RegistrationGender(navController: NavController) {
|
|
|
style = MaterialTheme.typography.headlineMedium
|
|
|
)
|
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
|
- ChooseGender()
|
|
|
+ ChooseGender(viewModel)
|
|
|
}
|
|
|
}
|
|
|
Box(Modifier.padding(bottom = 40.dp)) {
|
|
|
Button(
|
|
|
- onClick = { },
|
|
|
+ onClick = {viewModel.onSignUpEmailPassword(context = context) },
|
|
|
modifier = Modifier
|
|
|
.width(290.dp)
|
|
|
.height(48.dp),
|
|
@@ -123,7 +135,7 @@ fun RegistrationGender(navController: NavController) {
|
|
|
disabledContainerColor = DarkPurple
|
|
|
)
|
|
|
) {
|
|
|
- Text("Далее", fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
|
|
+ Text("Завершить", fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -131,5 +143,24 @@ fun RegistrationGender(navController: NavController) {
|
|
|
|
|
|
|
|
|
}
|
|
|
+ if(flag.value){
|
|
|
+ when (userState) {
|
|
|
+ is UserState.Loading -> {
|
|
|
+ CircularProgressIndicator()
|
|
|
+ }
|
|
|
+
|
|
|
+ is UserState.Success -> {
|
|
|
+ val message = (userState as UserState.Success).message
|
|
|
+ navController.navigate(Screens.Start.route)
|
|
|
+ flag.value = false
|
|
|
+ }
|
|
|
+
|
|
|
+ is UserState.Error -> {
|
|
|
+ val message = (userState as UserState.Error).message
|
|
|
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
|
|
+ flag.value = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|