не все так плохо)))надеюсь
This commit is contained in:
parent
235636627b
commit
d3ea61ad03
@ -46,6 +46,8 @@ import androidx.paging.compose.collectAsLazyPagingItems
|
|||||||
import com.example.myapplication.Graph.AuthScreen
|
import com.example.myapplication.Graph.AuthScreen
|
||||||
import com.example.myapplication.dataBase.model.RoleEnum
|
import com.example.myapplication.dataBase.model.RoleEnum
|
||||||
import com.example.myapplication.ui.AppViewModelProvider
|
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.lesson.LessonListViewModel
|
import com.example.myapplication.ui.lesson.LessonListViewModel
|
||||||
import com.example.myapplication.ui.user.CurrentUserViewModel
|
import com.example.myapplication.ui.user.CurrentUserViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -53,9 +55,8 @@ import kotlinx.coroutines.launch
|
|||||||
@SuppressLint("UnrememberedMutableState")
|
@SuppressLint("UnrememberedMutableState")
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonListViewModel: LessonListViewModel = viewModel(factory = AppViewModelProvider.Factory), currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)) {
|
fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonListViewModel: LessonListViewModel = viewModel(factory = AppViewModelProvider.Factory), currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory), directionViewModel: DirectionDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory), dayViewModel: DayDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory)) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
var getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
var getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
Log.d("Profile", "getUser: $getUser")
|
Log.d("Profile", "getUser: $getUser")
|
||||||
@ -64,9 +65,18 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
var password by remember { mutableStateOf(getUser?.password) }
|
var password by remember { mutableStateOf(getUser?.password) }
|
||||||
var fio by remember { mutableStateOf(getUser?.fio) }
|
var fio by remember { mutableStateOf(getUser?.fio) }
|
||||||
val lessonId = getUser?.lessonId
|
val lessonId = getUser?.lessonId
|
||||||
|
|
||||||
var userLessonText by remember { mutableStateOf("Записи нет") }
|
var userLessonText by remember { mutableStateOf("Записи нет") }
|
||||||
lessonListViewModel.getUserLesson(lessonId).observeForever { lesson ->
|
lessonListViewModel.getUserLesson(lessonId).observeForever { lesson ->
|
||||||
userLessonText = lesson?.time ?: "Записи нет"
|
if (lesson != null) {
|
||||||
|
lesson.directionId.let { directionViewModel.setCurrentDirection(it) }
|
||||||
|
val directionUiState = directionViewModel.directionUiState
|
||||||
|
lesson.dayOfWeekId.let { dayViewModel.setCurrentDayOfWeek(it) }
|
||||||
|
val dayOfWeekUiState = dayViewModel.dayOfWeekUiState
|
||||||
|
userLessonText = String.format("%s %s\n Направление: %s\n Тренер: %s\t Зал: %s", dayOfWeekUiState.dayOfWeek?.dayName,lesson.time, directionUiState.direction?.directionName, lesson.teacher, lesson.classNumber)
|
||||||
|
} else{
|
||||||
|
userLessonText = "Записи нет"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.d("Profile11", "getUserLesson: $userLessonText")
|
Log.d("Profile11", "getUserLesson: $userLessonText")
|
||||||
|
|
||||||
@ -183,7 +193,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.offset(
|
.offset(
|
||||||
x = 9.dp,
|
x = 9.dp,
|
||||||
y = 60.dp
|
y = 30.dp
|
||||||
)
|
)
|
||||||
.requiredWidth(width = 393.dp)
|
.requiredWidth(width = 393.dp)
|
||||||
.requiredHeight(height = 70.dp)
|
.requiredHeight(height = 70.dp)
|
||||||
@ -230,7 +240,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.offset(
|
.offset(
|
||||||
x = 106.dp,
|
x = 106.dp,
|
||||||
y = 60.dp
|
y = 30.dp
|
||||||
)
|
)
|
||||||
.requiredWidth(width = 200.dp)
|
.requiredWidth(width = 200.dp)
|
||||||
.requiredHeight(height = 310.dp)
|
.requiredHeight(height = 310.dp)
|
||||||
@ -250,7 +260,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.requiredWidth(width = 300.dp)
|
.requiredWidth(width = 300.dp)
|
||||||
.requiredHeight(height = 80.dp)
|
.requiredHeight(height = 60.dp)
|
||||||
.background(Color.White)
|
.background(Color.White)
|
||||||
.border(width = 1.dp, color = Color.Black) // Добавляем черную границу,
|
.border(width = 1.dp, color = Color.Black) // Добавляем черную границу,
|
||||||
)
|
)
|
||||||
@ -281,7 +291,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.requiredWidth(width = 300.dp)
|
.requiredWidth(width = 300.dp)
|
||||||
.requiredHeight(height = 80.dp)
|
.requiredHeight(height = 60.dp)
|
||||||
.background(Color.White)
|
.background(Color.White)
|
||||||
.border(width = 1.dp, color = Color.Black) // Добавляем черную границу
|
.border(width = 1.dp, color = Color.Black) // Добавляем черную границу
|
||||||
)
|
)
|
||||||
@ -369,7 +379,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.offset(
|
.offset(
|
||||||
x = 0.dp,
|
x = 0.dp,
|
||||||
y = 20.dp
|
y = 5.dp
|
||||||
)
|
)
|
||||||
.requiredWidth(width = 393.dp)
|
.requiredWidth(width = 393.dp)
|
||||||
.requiredHeight(height = 70.dp)
|
.requiredHeight(height = 70.dp)
|
||||||
@ -379,7 +389,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
.align(alignment = Alignment.TopStart)
|
.align(alignment = Alignment.TopStart)
|
||||||
.offset(
|
.offset(
|
||||||
x = 0.dp,
|
x = 0.dp,
|
||||||
y = 27.dp
|
y = 10.dp
|
||||||
)
|
)
|
||||||
.requiredWidth(width = 393.dp)
|
.requiredWidth(width = 393.dp)
|
||||||
.requiredHeight(height = 70.dp)
|
.requiredHeight(height = 70.dp)
|
||||||
@ -390,7 +400,6 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
.requiredHeight(height = 70.dp)
|
.requiredHeight(height = 70.dp)
|
||||||
.clip(shape = RoundedCornerShape(5.dp))
|
.clip(shape = RoundedCornerShape(5.dp))
|
||||||
.background(color = Color.White)
|
.background(color = Color.White)
|
||||||
|
|
||||||
)
|
)
|
||||||
if (getUser?.role == RoleEnum.User) {
|
if (getUser?.role == RoleEnum.User) {
|
||||||
Text(
|
Text(
|
||||||
@ -398,12 +407,11 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
color = Color.Black,
|
color = Color.Black,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
fontSize = 24.sp,
|
fontSize = 21.sp,
|
||||||
fontWeight = FontWeight.Bold
|
fontWeight = FontWeight.Bold
|
||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -428,25 +436,25 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.offset(
|
.offset(
|
||||||
x = 9.dp,
|
x = 9.dp,
|
||||||
y = 10.dp
|
y = (-25).dp
|
||||||
)
|
)
|
||||||
.requiredWidth(width = 393.dp)
|
.requiredWidth(width = 393.dp)
|
||||||
.requiredHeight(height = 100.dp)
|
.requiredHeight(height = 80.dp)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(alignment = Alignment.TopStart)
|
.align(alignment = Alignment.TopStart)
|
||||||
.offset(
|
.offset(
|
||||||
x = 0.dp,
|
x = 0.dp,
|
||||||
y = 27.dp
|
y = 10.dp
|
||||||
)
|
)
|
||||||
.requiredWidth(width = 393.dp)
|
.requiredWidth(width = 393.dp)
|
||||||
.requiredHeight(height = 70.dp)
|
.requiredHeight(height = 80.dp)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.requiredWidth(width = 393.dp)
|
.requiredWidth(width = 393.dp)
|
||||||
.requiredHeight(height = 70.dp)
|
.requiredHeight(height = 80.dp)
|
||||||
.clip(shape = RoundedCornerShape(5.dp))
|
.clip(shape = RoundedCornerShape(5.dp))
|
||||||
.background(color = Color.White)
|
.background(color = Color.White)
|
||||||
|
|
||||||
@ -462,9 +470,8 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp)
|
|
||||||
.background(Color.LightGray)
|
|
||||||
.requiredWidth(300.dp)
|
.requiredWidth(300.dp)
|
||||||
|
.requiredHeight(80.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -182,6 +182,7 @@ private fun SwipeToDelete(
|
|||||||
},
|
},
|
||||||
dismissContent = {
|
dismissContent = {
|
||||||
LessonListItem(lesson = lesson,
|
LessonListItem(lesson = lesson,
|
||||||
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(vertical = 7.dp)
|
.padding(vertical = 7.dp)
|
||||||
.clickable { onClick(lesson.uid) })
|
.clickable { onClick(lesson.uid) })
|
||||||
@ -508,13 +509,9 @@ private fun LessonList(
|
|||||||
private fun LessonListItem(
|
private fun LessonListItem(
|
||||||
lesson: Lesson, modifier: Modifier = Modifier
|
lesson: Lesson, modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
var dir = ""
|
val directionViewModel: DirectionDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
||||||
if (lesson.directionId == 3) dir = "Contemporary"
|
lesson.directionId.let { directionViewModel.setCurrentDirection(it) }
|
||||||
if (lesson.directionId == 1) dir = "K-pop"
|
val directionUiState = directionViewModel.directionUiState
|
||||||
if (lesson.directionId == 2) dir = "House"
|
|
||||||
if (lesson.directionId == 4) dir = "BreakDance"
|
|
||||||
if (lesson.directionId == 6) dir = "Dancehall"
|
|
||||||
if (lesson.directionId == 5) dir = "Jazz-funk"
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
shape = RoundedCornerShape(0.dp),
|
shape = RoundedCornerShape(0.dp),
|
||||||
@ -524,7 +521,7 @@ private fun LessonListItem(
|
|||||||
modifier = modifier.align(CenterHorizontally)
|
modifier = modifier.align(CenterHorizontally)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = String.format("%s %s %s", lesson.time, lesson.teacher, dir)
|
text = String.format("%s %s %s", lesson.time, lesson.teacher, directionUiState.direction?.directionName)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,18 +105,18 @@
|
|||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"userName": "user2",
|
"userName": "user2",
|
||||||
"fio": "Илья Петрович Мунин",
|
|
||||||
"password": "5678",
|
"password": "5678",
|
||||||
|
"fio": "Илья Петрович Мунин",
|
||||||
"role": "User",
|
"role": "User",
|
||||||
"lessonId": null
|
"lessonId": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"userName": "user3",
|
"userName": "user3",
|
||||||
"fio": "Мария Денисовна Амова",
|
|
||||||
"password": "13579",
|
"password": "13579",
|
||||||
|
"fio": "Мария Денисовна Амова",
|
||||||
"role": "User",
|
"role": "User",
|
||||||
"lessonId": null
|
"lessonId": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 7,
|
"id": 7,
|
||||||
@ -124,7 +124,7 @@
|
|||||||
"password": "user7",
|
"password": "user7",
|
||||||
"fio": "user7",
|
"fio": "user7",
|
||||||
"role": "User",
|
"role": "User",
|
||||||
"lessonId": 4
|
"lessonId": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 8,
|
"id": 8,
|
||||||
|
Loading…
Reference in New Issue
Block a user