diff --git a/app/src/main/java/com/example/myapplication/Enter.kt b/app/src/main/java/com/example/myapplication/Enter.kt index 6f3dac2..4efe270 100644 --- a/app/src/main/java/com/example/myapplication/Enter.kt +++ b/app/src/main/java/com/example/myapplication/Enter.kt @@ -74,7 +74,6 @@ fun Enter(navController: NavController, modifier: Modifier = Modifier, lessonLis val argument = currentUserViewModel.argument.value var passwordVisibility by rememberSaveable { mutableStateOf(false) } - Box( modifier = modifier .requiredWidth(width = 412.dp) diff --git a/app/src/main/java/com/example/myapplication/Graph/HomeNavGraph.kt b/app/src/main/java/com/example/myapplication/Graph/HomeNavGraph.kt index 9d617f1..473b676 100644 --- a/app/src/main/java/com/example/myapplication/Graph/HomeNavGraph.kt +++ b/app/src/main/java/com/example/myapplication/Graph/HomeNavGraph.kt @@ -23,7 +23,7 @@ import com.example.myapplication.ui.AppViewModelProvider import com.example.myapplication.ui.edit.DayDropDownViewModel import com.example.myapplication.ui.edit.DirectionDropDownViewModel import com.example.myapplication.ui.edit.LessonEdit -import com.example.myapplication.ui.edit.LessonRecord +//import com.example.myapplication.ui.edit.LessonRecord import com.example.myapplication.ui.edit.LessonEditViewModel import com.example.myapplication.ui.lesson.LessonList import com.example.myapplication.ui.lesson.LessonListViewModel @@ -52,12 +52,12 @@ fun HomeNavGraph(navController: NavHostController, currentUserViewModel: Current ) { LessonEdit(navController) } - composable( - BottomBarScreen.LessonRecord.route, - arguments = listOf(navArgument("id") { type = NavType.IntType }) - ) { - LessonRecord(navController) - } +// composable( +// BottomBarScreen.LessonRecord.route, +// arguments = listOf(navArgument("id") { type = NavType.IntType }) +// ) { +// LessonRecord(navController) +// } composable(route = BottomBarScreen.DirectionView.route) { DirectionView(navController) } composable(route = BottomBarScreen.Profile.route) { Profile( diff --git a/app/src/main/java/com/example/myapplication/dataBase/AppDatabase.kt b/app/src/main/java/com/example/myapplication/dataBase/AppDatabase.kt index 65a9e6c..1dd73d6 100644 --- a/app/src/main/java/com/example/myapplication/dataBase/AppDatabase.kt +++ b/app/src/main/java/com/example/myapplication/dataBase/AppDatabase.kt @@ -29,7 +29,7 @@ abstract class AppDatabase : RoomDatabase() { abstract fun remoteKeysDao(): RemoteKeysDao companion object { - private const val DB_NAME: String = "pmy-dbbbb5" + private const val DB_NAME: String = "bd" @Volatile private var INSTANCE: AppDatabase? = null diff --git a/app/src/main/java/com/example/myapplication/ui/edit/LessonRecord.kt b/app/src/main/java/com/example/myapplication/ui/edit/LessonRecord.kt index a6e9eef..42e07cc 100644 --- a/app/src/main/java/com/example/myapplication/ui/edit/LessonRecord.kt +++ b/app/src/main/java/com/example/myapplication/ui/edit/LessonRecord.kt @@ -25,98 +25,99 @@ import com.example.myapplication.ui.AppViewModelProvider import com.example.myapplication.ui.user.CurrentUserViewModel import kotlinx.coroutines.launch -@Composable -fun LessonRecord( - navController: NavController, - viewModel: LessonEditViewModel = viewModel(factory = AppViewModelProvider.Factory), - directionViewModel: DirectionDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory), - currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory) -) { - val coroutineScope = rememberCoroutineScope() - directionViewModel.setCurrentDirection(viewModel.lessonUiState.lessonDetails.directionId) - val getUser by remember { mutableStateOf(currentUserViewModel.user) } - Log.d("getUserLesson", "gU: $getUser") - val lessonCurId = viewModel.getUidLesson() - LessonRecord( - lessonUiState = viewModel.lessonUiState, - directionUiState = directionViewModel.directionUiState, - onClick = { - coroutineScope.launch { - Log.d("LessonBefore", "LB: ${getUser?.lessonId}") - - getUser?.let { - it.lessonId = lessonCurId - Log.d("LessonAfter", "LA: ${getUser?.lessonId}") - currentUserViewModel.updateUser(it) - Log.d("UserAfter", "UA: $getUser") - } - - navController.popBackStack() - } - - } - ) {} -} - -@OptIn(ExperimentalMaterial3Api::class) -@Composable -private fun LessonRecord( - lessonUiState: LessonUiState, - directionUiState: DirectionUiState, - onClick: () -> Unit, - onUpdate: (LessonDetails) -> Unit -) { - Column( - Modifier - .fillMaxWidth() - .padding(all = 10.dp) - ) { - OutlinedTextField( - modifier = Modifier.fillMaxWidth(), - value = lessonUiState.lessonDetails.time, - onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(time = it)) }, - label = { Text(stringResource(id = R.string.lesson_TimeDate)) }, - singleLine = true, - readOnly = true - ) - OutlinedTextField( - modifier = Modifier.fillMaxWidth(), - value = lessonUiState.lessonDetails.teacher, - onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(teacher = it)) }, - label = { Text(stringResource(id = R.string.lesson_teacher)) }, - singleLine = true, - readOnly = true - ) - OutlinedTextField( - modifier = Modifier.fillMaxWidth(), - value = directionUiState.direction?.directionName - ?: stringResource(id = R.string.lesson_direction), - label = { Text(stringResource(id = R.string.lesson_direction)) }, - onValueChange = {}, - readOnly = true, - ) - OutlinedTextField( - modifier = Modifier.fillMaxWidth(), - value = lessonUiState.lessonDetails.classNumber.toString(), - onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(classNumber = it.toIntOrNull() ?: 0)) }, - label = { Text(stringResource(id = R.string.lesson_classNumber)) }, - singleLine = true, - readOnly = true - ) - OutlinedTextField( - modifier = Modifier.fillMaxWidth(), - value = lessonUiState.lessonDetails.countRecord.toString(), - onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(countRecord = it.toIntOrNull() ?: 0)) }, - label = { Text(stringResource(id = R.string.lesson_countRecord)) }, - singleLine = true, - readOnly = true - ) - Button( - onClick = onClick, - shape = MaterialTheme.shapes.small, - modifier = Modifier.fillMaxWidth() - ) { - Text(text = stringResource(R.string.lesson_record_button)) - } - } -} +//@Composable +//fun LessonRecord( +// navController: NavController, +// viewModel: LessonEditViewModel = viewModel(factory = AppViewModelProvider.Factory), +// directionViewModel: DirectionDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory), +// currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory) +//) { +// val coroutineScope = rememberCoroutineScope() +// directionViewModel.setCurrentDirection(viewModel.lessonUiState.lessonDetails.directionId) +// val getUser by remember { mutableStateOf(currentUserViewModel.user) } +// Log.d("getUserLesson", "gU: $getUser") +// +// LessonRecord( +// lessonUiState = viewModel.lessonUiState, +// directionUiState = directionViewModel.directionUiState, +// onClick = { +// coroutineScope.launch { +// val lessonCurId = viewModel.getUidLesson() +// Log.d("LessonBefore", "LB: ${getUser?.lessonId}") +// +// getUser?.let { +// it.lessonId = lessonCurId +// Log.d("LessonAfter", "LA: ${getUser?.lessonId}") +// currentUserViewModel.updateUser(it) +// Log.d("UserAfter", "UA: $getUser") +// } +// +// navController.popBackStack() +// } +// +// } +// ) {} +//} +// +//@OptIn(ExperimentalMaterial3Api::class) +//@Composable +//private fun LessonRecord( +// lessonUiState: LessonUiState, +// directionUiState: DirectionUiState, +// onClick: () -> Unit, +// onUpdate: (LessonDetails) -> Unit +//) { +// Column( +// Modifier +// .fillMaxWidth() +// .padding(all = 10.dp) +// ) { +// OutlinedTextField( +// modifier = Modifier.fillMaxWidth(), +// value = lessonUiState.lessonDetails.time, +// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(time = it)) }, +// label = { Text(stringResource(id = R.string.lesson_TimeDate)) }, +// singleLine = true, +// readOnly = true +// ) +// OutlinedTextField( +// modifier = Modifier.fillMaxWidth(), +// value = lessonUiState.lessonDetails.teacher, +// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(teacher = it)) }, +// label = { Text(stringResource(id = R.string.lesson_teacher)) }, +// singleLine = true, +// readOnly = true +// ) +// OutlinedTextField( +// modifier = Modifier.fillMaxWidth(), +// value = directionUiState.direction?.directionName +// ?: stringResource(id = R.string.lesson_direction), +// label = { Text(stringResource(id = R.string.lesson_direction)) }, +// onValueChange = {}, +// readOnly = true, +// ) +// OutlinedTextField( +// modifier = Modifier.fillMaxWidth(), +// value = lessonUiState.lessonDetails.classNumber.toString(), +// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(classNumber = it.toIntOrNull() ?: 0)) }, +// label = { Text(stringResource(id = R.string.lesson_classNumber)) }, +// singleLine = true, +// readOnly = true +// ) +// OutlinedTextField( +// modifier = Modifier.fillMaxWidth(), +// value = lessonUiState.lessonDetails.countRecord.toString(), +// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(countRecord = it.toIntOrNull() ?: 0)) }, +// label = { Text(stringResource(id = R.string.lesson_countRecord)) }, +// singleLine = true, +// readOnly = true +// ) +// Button( +// onClick = onClick, +// shape = MaterialTheme.shapes.small, +// modifier = Modifier.fillMaxWidth() +// ) { +// Text(text = stringResource(R.string.lesson_record_button)) +// } +// } +//} diff --git a/app/src/main/java/com/example/myapplication/ui/lesson/LessonList.kt b/app/src/main/java/com/example/myapplication/ui/lesson/LessonList.kt index 1b6ec73..0133823 100644 --- a/app/src/main/java/com/example/myapplication/ui/lesson/LessonList.kt +++ b/app/src/main/java/com/example/myapplication/ui/lesson/LessonList.kt @@ -121,10 +121,11 @@ fun LessonList( if (getUser?.role == RoleEnum.Admin) { val route = BottomBarScreen.LessonEdit.route.replace("{id}", uid.toString()) navController.navigate(route) - } else{ - val route = BottomBarScreen.LessonRecord.route.replace("{id}", uid.toString()) - navController.navigate(route) } +// else{ +// val route = BottomBarScreen.LessonRecord.route.replace("{id}", uid.toString()) +// navController.navigate(route) +// } } ){ lesson: Lesson -> if (getUser?.role == RoleEnum.Admin) { diff --git a/server/data.json b/server/data.json index 300f549..ec3414e 100644 --- a/server/data.json +++ b/server/data.json @@ -100,7 +100,7 @@ "fio": "Анна Викторовна Сомова", "password": "1234", "role": "Admin", - "lessonId": 1 + "lessonId": null }, { "id": 2, @@ -108,7 +108,7 @@ "fio": "Илья Петрович Мунин", "password": "5678", "role": "User", - "lessonId": 3 + "lessonId": null }, { "id": 3, @@ -116,7 +116,7 @@ "fio": "Мария Денисовна Амова", "password": "13579", "role": "User", - "lessonId": 3 + "lessonId": null }, { "id": 7, @@ -125,6 +125,22 @@ "fio": "user7", "role": "User", "lessonId": null + }, + { + "userName": "user8", + "password": "user8", + "fio": "user8", + "role": "User", + "lessonId": null, + "id": 8 + }, + { + "userName": "user8", + "password": "user8", + "fio": "user8", + "role": "User", + "lessonId": null, + "id": 9 } ] } \ No newline at end of file