таня бох
This commit is contained in:
parent
ebd0a6c91b
commit
84dbb70f6e
@ -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)
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user