.
This commit is contained in:
parent
ea3b827b55
commit
1921585f6f
@ -63,6 +63,7 @@ dependencies {
|
||||
implementation("androidx.compose.ui:ui-graphics")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview")
|
||||
implementation("androidx.compose.material3:material3:1.1.2")
|
||||
implementation("androidx.compose.material:material:1.4.3")
|
||||
|
||||
// Room
|
||||
val room_version = "2.5.2"
|
||||
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
@ -33,6 +34,7 @@ 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.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -73,6 +75,23 @@ fun Enter(navController: NavController, modifier: Modifier = Modifier, lessonLis
|
||||
val users = mutableStateOf<List<User>>(entryScreenViewModel.userList)
|
||||
val argument = currentUserViewModel.argument.value
|
||||
var passwordVisibility by rememberSaveable { mutableStateOf(false) }
|
||||
val showInvalidPasswordDialog = remember { mutableStateOf(false) }
|
||||
|
||||
|
||||
if (showInvalidPasswordDialog.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showInvalidPasswordDialog.value = false },
|
||||
title = { Text(text = "Ошибка") },
|
||||
text = { Text(text = "Неверный логин и/или пароль. Если вы у нас впервые - зарегистрируйтесь!") },
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = { showInvalidPasswordDialog.value = false },
|
||||
) {
|
||||
Text(text = "Ок")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
@ -196,14 +215,19 @@ fun Enter(navController: NavController, modifier: Modifier = Modifier, lessonLis
|
||||
Button(
|
||||
onClick = {
|
||||
if (passwordValue.isNotEmpty()) {
|
||||
var userExists = false
|
||||
users.value.forEach { user ->
|
||||
if (user.password == passwordValue && user.userName == emailValue) {
|
||||
currentUserViewModel.setArgument(user.uid.toString())
|
||||
Log.d("CurrentUserViewModel1", "Текущий пользователь: $user")
|
||||
navController.navigate(route = Graph.passUserId(user.uid.toString())) {
|
||||
}
|
||||
userExists = true
|
||||
}
|
||||
}
|
||||
if (!userExists) {
|
||||
showInvalidPasswordDialog.value = true
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
|
@ -478,18 +478,24 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
||||
}
|
||||
else{
|
||||
Text(
|
||||
text = "Получить отчет",
|
||||
color = Color.Black,
|
||||
text = "К записи",
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Center,
|
||||
style = TextStyle(
|
||||
fontSize = 16.sp,
|
||||
fontSize = 17.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.background(Color.LightGray)
|
||||
.requiredWidth(300.dp)
|
||||
.requiredWidth(width = 343.dp)
|
||||
.requiredHeight(height = 44.dp)
|
||||
.wrapContentHeight(align = Alignment.CenterVertically)
|
||||
.align(Alignment.Center)
|
||||
.clickable(
|
||||
enabled = getUser?.lessonId != null,
|
||||
onClick = {
|
||||
val route = BottomBarScreen.LessonRecord.route.replace("{id}", lessonId.toString())
|
||||
navController.navigate(route)
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -514,7 +520,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
||||
)
|
||||
)
|
||||
Text(
|
||||
text = "К записи",
|
||||
text = "Получить отчет",
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Center,
|
||||
style = TextStyle(
|
||||
@ -529,12 +535,6 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
||||
.clickable(
|
||||
enabled = getUser?.lessonId != null,
|
||||
onClick = {
|
||||
// getUser?.lessonId = null
|
||||
// coroutineScope.launch {
|
||||
// getUser?.let {
|
||||
// currentUserViewModel.updateUser(it)
|
||||
// }
|
||||
// }
|
||||
val route = BottomBarScreen.LessonRecord.route.replace("{id}", lessonId.toString())
|
||||
navController.navigate(route)
|
||||
})
|
||||
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
@ -34,6 +35,7 @@ import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -79,6 +81,21 @@ fun Registration(navController: NavController, modifier: Modifier = Modifier, re
|
||||
registerScreenViewModel.users.observeForever { userList ->
|
||||
users.value = userList
|
||||
}
|
||||
val showInvalidPasswordDialog = remember { mutableStateOf(false) }
|
||||
if (showInvalidPasswordDialog.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showInvalidPasswordDialog.value = false },
|
||||
title = { Text(text = "Ошибка") },
|
||||
text = { Text(text = "Пользователь с таким логином уже есть") },
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = { showInvalidPasswordDialog.value = false },
|
||||
) {
|
||||
Text(text = "Ок")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
var passwordVisibility by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
@ -214,9 +231,10 @@ fun Registration(navController: NavController, modifier: Modifier = Modifier, re
|
||||
var isExist = false;
|
||||
if (passwordValue.isNotEmpty() && loginValue.isNotEmpty() && fioValue.isNotEmpty()) {
|
||||
users.value.forEach { user ->
|
||||
if (user.userName == loginValue || user.fio == fioValue) {
|
||||
if (user.userName == loginValue) {
|
||||
Log.d("User already exist. User id: ", user.uid.toString())
|
||||
isExist = true
|
||||
showInvalidPasswordDialog.value = true
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
|
@ -29,7 +29,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun remoteKeysDao(): RemoteKeysDao
|
||||
|
||||
companion object {
|
||||
private const val DB_NAME: String = "bd4"
|
||||
private const val DB_NAME: String = "bd8"
|
||||
|
||||
@Volatile
|
||||
private var INSTANCE: AppDatabase? = null
|
||||
|
@ -37,10 +37,12 @@ fun LessonRecord(
|
||||
val getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
||||
Log.d("getUserLesson", "gU: $getUser")
|
||||
val lessonCurId = viewModel.getUidLesson()
|
||||
val lessonDetails = viewModel.lessonUiState.lessonDetails
|
||||
LessonRecord(
|
||||
lessonUiState = viewModel.lessonUiState,
|
||||
directionUiState = directionViewModel.directionUiState,
|
||||
enabled = getUser?.lessonId != lessonCurId,
|
||||
enabled = (getUser?.lessonId != lessonCurId) && (lessonDetails.countRecord > 0),
|
||||
enabled1 = getUser?.lessonId == lessonCurId,
|
||||
onClick = {
|
||||
coroutineScope.launch {
|
||||
Log.d("LessonBefore", "LB: ${getUser?.lessonId}")
|
||||
@ -55,9 +57,16 @@ fun LessonRecord(
|
||||
}
|
||||
navController.popBackStack()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
onClick1 = {
|
||||
getUser?.lessonId = null
|
||||
coroutineScope.launch {
|
||||
getUser?.let {
|
||||
currentUserViewModel.updateUser(it)
|
||||
}
|
||||
viewModel.updateRecordsForCancel()
|
||||
}
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
||||
@ -67,7 +76,9 @@ private fun LessonRecord(
|
||||
lessonUiState: LessonUiState,
|
||||
directionUiState: DirectionUiState,
|
||||
enabled: Boolean,
|
||||
enabled1: Boolean,
|
||||
onClick: () -> Unit,
|
||||
onClick1: () -> Unit,
|
||||
onUpdate: (LessonDetails) -> Unit
|
||||
) {
|
||||
Column(
|
||||
@ -123,5 +134,13 @@ private fun LessonRecord(
|
||||
) {
|
||||
Text(text = stringResource(R.string.lesson_record_button))
|
||||
}
|
||||
Button(
|
||||
onClick = onClick1,
|
||||
enabled = enabled1,
|
||||
shape = MaterialTheme.shapes.small,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(text = stringResource(R.string.lesson_cancel_button))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,6 @@ private fun SwipeToDelete(
|
||||
},
|
||||
dismissContent = {
|
||||
LessonListItem(lesson = lesson,
|
||||
|
||||
modifier = Modifier
|
||||
.padding(vertical = 7.dp)
|
||||
.clickable { onClick(lesson.uid) })
|
||||
|
@ -12,7 +12,7 @@
|
||||
<string name="lesson_empty_description">Занятий нет</string>
|
||||
<string name="lesson_save_button">Занятие сохранено</string>
|
||||
<string name="lesson_record_button">Записаться</string>
|
||||
|
||||
<string name="lesson_cancel_button">Отменить запись</string>
|
||||
<string name="student_phone">Телефон</string>
|
||||
<string name="lesson_TimeDate">Время начала и конца</string>
|
||||
<string name="lesson_DayOfWeek">День недели</string>
|
||||
|
@ -91,6 +91,23 @@
|
||||
"dayOfWeekId": 5,
|
||||
"directionId": 1,
|
||||
"countRecord": 5
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"teacher": "Софья Олеговна",
|
||||
"time": "10.00",
|
||||
"classNumber": 6,
|
||||
"dayOfWeekId": 3,
|
||||
"directionId": 6,
|
||||
"countRecord": 5
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"teacher": "Илона",
|
||||
"time": "10.00",
|
||||
"classNumber": 5,
|
||||
"dayOfWeekId": 5,
|
||||
"directionId": 3
|
||||
}
|
||||
],
|
||||
"users": [
|
||||
@ -108,7 +125,7 @@
|
||||
"password": "5678",
|
||||
"fio": "Илья Петрович Мунин",
|
||||
"role": "User",
|
||||
"lessonId": 1
|
||||
"lessonId": 7
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
@ -116,7 +133,7 @@
|
||||
"password": "13579",
|
||||
"fio": "Мария Денисовна Амова",
|
||||
"role": "User",
|
||||
"lessonId": 1
|
||||
"lessonId": 3
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
@ -124,7 +141,7 @@
|
||||
"password": "user7",
|
||||
"fio": "user7",
|
||||
"role": "User",
|
||||
"lessonId": 3
|
||||
"lessonId": 7
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
@ -132,7 +149,15 @@
|
||||
"password": "user8",
|
||||
"fio": "user8",
|
||||
"role": "User",
|
||||
"lessonId": 5
|
||||
"lessonId": null
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"userName": "user7",
|
||||
"password": "parol",
|
||||
"fio": "user7",
|
||||
"role": "User",
|
||||
"lessonId": 7
|
||||
}
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user