таня бох
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
|
val argument = currentUserViewModel.argument.value
|
||||||
var passwordVisibility by rememberSaveable { mutableStateOf(false) }
|
var passwordVisibility by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.requiredWidth(width = 412.dp)
|
.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.DayDropDownViewModel
|
||||||
import com.example.myapplication.ui.edit.DirectionDropDownViewModel
|
import com.example.myapplication.ui.edit.DirectionDropDownViewModel
|
||||||
import com.example.myapplication.ui.edit.LessonEdit
|
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.edit.LessonEditViewModel
|
||||||
import com.example.myapplication.ui.lesson.LessonList
|
import com.example.myapplication.ui.lesson.LessonList
|
||||||
import com.example.myapplication.ui.lesson.LessonListViewModel
|
import com.example.myapplication.ui.lesson.LessonListViewModel
|
||||||
@ -52,12 +52,12 @@ fun HomeNavGraph(navController: NavHostController, currentUserViewModel: Current
|
|||||||
) {
|
) {
|
||||||
LessonEdit(navController)
|
LessonEdit(navController)
|
||||||
}
|
}
|
||||||
composable(
|
// composable(
|
||||||
BottomBarScreen.LessonRecord.route,
|
// BottomBarScreen.LessonRecord.route,
|
||||||
arguments = listOf(navArgument("id") { type = NavType.IntType })
|
// arguments = listOf(navArgument("id") { type = NavType.IntType })
|
||||||
) {
|
// ) {
|
||||||
LessonRecord(navController)
|
// LessonRecord(navController)
|
||||||
}
|
// }
|
||||||
composable(route = BottomBarScreen.DirectionView.route) { DirectionView(navController) }
|
composable(route = BottomBarScreen.DirectionView.route) { DirectionView(navController) }
|
||||||
composable(route = BottomBarScreen.Profile.route) {
|
composable(route = BottomBarScreen.Profile.route) {
|
||||||
Profile(
|
Profile(
|
||||||
|
@ -29,7 +29,7 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
abstract fun remoteKeysDao(): RemoteKeysDao
|
abstract fun remoteKeysDao(): RemoteKeysDao
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val DB_NAME: String = "pmy-dbbbb5"
|
private const val DB_NAME: String = "bd"
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var INSTANCE: AppDatabase? = null
|
private var INSTANCE: AppDatabase? = null
|
||||||
|
@ -25,98 +25,99 @@ import com.example.myapplication.ui.AppViewModelProvider
|
|||||||
import com.example.myapplication.ui.user.CurrentUserViewModel
|
import com.example.myapplication.ui.user.CurrentUserViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
//@Composable
|
||||||
fun LessonRecord(
|
//fun LessonRecord(
|
||||||
navController: NavController,
|
// navController: NavController,
|
||||||
viewModel: LessonEditViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
// viewModel: LessonEditViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
||||||
directionViewModel: DirectionDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
// directionViewModel: DirectionDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
||||||
currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
// currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
||||||
) {
|
//) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
// val coroutineScope = rememberCoroutineScope()
|
||||||
directionViewModel.setCurrentDirection(viewModel.lessonUiState.lessonDetails.directionId)
|
// directionViewModel.setCurrentDirection(viewModel.lessonUiState.lessonDetails.directionId)
|
||||||
val getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
// val getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
||||||
Log.d("getUserLesson", "gU: $getUser")
|
// Log.d("getUserLesson", "gU: $getUser")
|
||||||
val lessonCurId = viewModel.getUidLesson()
|
//
|
||||||
LessonRecord(
|
// LessonRecord(
|
||||||
lessonUiState = viewModel.lessonUiState,
|
// lessonUiState = viewModel.lessonUiState,
|
||||||
directionUiState = directionViewModel.directionUiState,
|
// directionUiState = directionViewModel.directionUiState,
|
||||||
onClick = {
|
// onClick = {
|
||||||
coroutineScope.launch {
|
// coroutineScope.launch {
|
||||||
Log.d("LessonBefore", "LB: ${getUser?.lessonId}")
|
// val lessonCurId = viewModel.getUidLesson()
|
||||||
|
// Log.d("LessonBefore", "LB: ${getUser?.lessonId}")
|
||||||
getUser?.let {
|
//
|
||||||
it.lessonId = lessonCurId
|
// getUser?.let {
|
||||||
Log.d("LessonAfter", "LA: ${getUser?.lessonId}")
|
// it.lessonId = lessonCurId
|
||||||
currentUserViewModel.updateUser(it)
|
// Log.d("LessonAfter", "LA: ${getUser?.lessonId}")
|
||||||
Log.d("UserAfter", "UA: $getUser")
|
// currentUserViewModel.updateUser(it)
|
||||||
}
|
// Log.d("UserAfter", "UA: $getUser")
|
||||||
|
// }
|
||||||
navController.popBackStack()
|
//
|
||||||
}
|
// navController.popBackStack()
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
) {}
|
// }
|
||||||
}
|
// ) {}
|
||||||
|
//}
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
//
|
||||||
@Composable
|
//@OptIn(ExperimentalMaterial3Api::class)
|
||||||
private fun LessonRecord(
|
//@Composable
|
||||||
lessonUiState: LessonUiState,
|
//private fun LessonRecord(
|
||||||
directionUiState: DirectionUiState,
|
// lessonUiState: LessonUiState,
|
||||||
onClick: () -> Unit,
|
// directionUiState: DirectionUiState,
|
||||||
onUpdate: (LessonDetails) -> Unit
|
// onClick: () -> Unit,
|
||||||
) {
|
// onUpdate: (LessonDetails) -> Unit
|
||||||
Column(
|
//) {
|
||||||
Modifier
|
// Column(
|
||||||
.fillMaxWidth()
|
// Modifier
|
||||||
.padding(all = 10.dp)
|
// .fillMaxWidth()
|
||||||
) {
|
// .padding(all = 10.dp)
|
||||||
OutlinedTextField(
|
// ) {
|
||||||
modifier = Modifier.fillMaxWidth(),
|
// OutlinedTextField(
|
||||||
value = lessonUiState.lessonDetails.time,
|
// modifier = Modifier.fillMaxWidth(),
|
||||||
onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(time = it)) },
|
// value = lessonUiState.lessonDetails.time,
|
||||||
label = { Text(stringResource(id = R.string.lesson_TimeDate)) },
|
// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(time = it)) },
|
||||||
singleLine = true,
|
// label = { Text(stringResource(id = R.string.lesson_TimeDate)) },
|
||||||
readOnly = true
|
// singleLine = true,
|
||||||
)
|
// readOnly = true
|
||||||
OutlinedTextField(
|
// )
|
||||||
modifier = Modifier.fillMaxWidth(),
|
// OutlinedTextField(
|
||||||
value = lessonUiState.lessonDetails.teacher,
|
// modifier = Modifier.fillMaxWidth(),
|
||||||
onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(teacher = it)) },
|
// value = lessonUiState.lessonDetails.teacher,
|
||||||
label = { Text(stringResource(id = R.string.lesson_teacher)) },
|
// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(teacher = it)) },
|
||||||
singleLine = true,
|
// label = { Text(stringResource(id = R.string.lesson_teacher)) },
|
||||||
readOnly = true
|
// singleLine = true,
|
||||||
)
|
// readOnly = true
|
||||||
OutlinedTextField(
|
// )
|
||||||
modifier = Modifier.fillMaxWidth(),
|
// OutlinedTextField(
|
||||||
value = directionUiState.direction?.directionName
|
// modifier = Modifier.fillMaxWidth(),
|
||||||
?: stringResource(id = R.string.lesson_direction),
|
// value = directionUiState.direction?.directionName
|
||||||
label = { Text(stringResource(id = R.string.lesson_direction)) },
|
// ?: stringResource(id = R.string.lesson_direction),
|
||||||
onValueChange = {},
|
// label = { Text(stringResource(id = R.string.lesson_direction)) },
|
||||||
readOnly = true,
|
// onValueChange = {},
|
||||||
)
|
// readOnly = true,
|
||||||
OutlinedTextField(
|
// )
|
||||||
modifier = Modifier.fillMaxWidth(),
|
// OutlinedTextField(
|
||||||
value = lessonUiState.lessonDetails.classNumber.toString(),
|
// modifier = Modifier.fillMaxWidth(),
|
||||||
onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(classNumber = it.toIntOrNull() ?: 0)) },
|
// value = lessonUiState.lessonDetails.classNumber.toString(),
|
||||||
label = { Text(stringResource(id = R.string.lesson_classNumber)) },
|
// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(classNumber = it.toIntOrNull() ?: 0)) },
|
||||||
singleLine = true,
|
// label = { Text(stringResource(id = R.string.lesson_classNumber)) },
|
||||||
readOnly = true
|
// singleLine = true,
|
||||||
)
|
// readOnly = true
|
||||||
OutlinedTextField(
|
// )
|
||||||
modifier = Modifier.fillMaxWidth(),
|
// OutlinedTextField(
|
||||||
value = lessonUiState.lessonDetails.countRecord.toString(),
|
// modifier = Modifier.fillMaxWidth(),
|
||||||
onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(countRecord = it.toIntOrNull() ?: 0)) },
|
// value = lessonUiState.lessonDetails.countRecord.toString(),
|
||||||
label = { Text(stringResource(id = R.string.lesson_countRecord)) },
|
// onValueChange = { onUpdate(lessonUiState.lessonDetails.copy(countRecord = it.toIntOrNull() ?: 0)) },
|
||||||
singleLine = true,
|
// label = { Text(stringResource(id = R.string.lesson_countRecord)) },
|
||||||
readOnly = true
|
// singleLine = true,
|
||||||
)
|
// readOnly = true
|
||||||
Button(
|
// )
|
||||||
onClick = onClick,
|
// Button(
|
||||||
shape = MaterialTheme.shapes.small,
|
// onClick = onClick,
|
||||||
modifier = Modifier.fillMaxWidth()
|
// shape = MaterialTheme.shapes.small,
|
||||||
) {
|
// modifier = Modifier.fillMaxWidth()
|
||||||
Text(text = stringResource(R.string.lesson_record_button))
|
// ) {
|
||||||
}
|
// Text(text = stringResource(R.string.lesson_record_button))
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
@ -121,10 +121,11 @@ fun LessonList(
|
|||||||
if (getUser?.role == RoleEnum.Admin) {
|
if (getUser?.role == RoleEnum.Admin) {
|
||||||
val route = BottomBarScreen.LessonEdit.route.replace("{id}", uid.toString())
|
val route = BottomBarScreen.LessonEdit.route.replace("{id}", uid.toString())
|
||||||
navController.navigate(route)
|
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 ->
|
){ lesson: Lesson ->
|
||||||
if (getUser?.role == RoleEnum.Admin) {
|
if (getUser?.role == RoleEnum.Admin) {
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
"fio": "Анна Викторовна Сомова",
|
"fio": "Анна Викторовна Сомова",
|
||||||
"password": "1234",
|
"password": "1234",
|
||||||
"role": "Admin",
|
"role": "Admin",
|
||||||
"lessonId": 1
|
"lessonId": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
@ -108,7 +108,7 @@
|
|||||||
"fio": "Илья Петрович Мунин",
|
"fio": "Илья Петрович Мунин",
|
||||||
"password": "5678",
|
"password": "5678",
|
||||||
"role": "User",
|
"role": "User",
|
||||||
"lessonId": 3
|
"lessonId": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
@ -116,7 +116,7 @@
|
|||||||
"fio": "Мария Денисовна Амова",
|
"fio": "Мария Денисовна Амова",
|
||||||
"password": "13579",
|
"password": "13579",
|
||||||
"role": "User",
|
"role": "User",
|
||||||
"lessonId": 3
|
"lessonId": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 7,
|
"id": 7,
|
||||||
@ -125,6 +125,22 @@
|
|||||||
"fio": "user7",
|
"fio": "user7",
|
||||||
"role": "User",
|
"role": "User",
|
||||||
"lessonId": null
|
"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