4-ую начал, пользователя связал с карточками

This commit is contained in:
Артём Алейкин 2023-12-22 23:17:12 +04:00
parent f1c0642cf7
commit 21dace91cd
2 changed files with 6 additions and 0 deletions

View File

@ -29,4 +29,7 @@ interface UserDao {
@Delete @Delete
suspend fun delete(user: User) suspend fun delete(user: User)
@Query("select count(*) from cards where user_id = :userId")
fun getAdsCount(userId: Int): Int?
} }

View File

@ -40,6 +40,7 @@ fun UserSettings(navController: NavHostController) {
val login = remember { mutableStateOf("") } val login = remember { mutableStateOf("") }
val password = remember { mutableStateOf("") } val password = remember { mutableStateOf("") }
val adsCount = remember { mutableStateOf(0) }
val userId = 1 val userId = 1
userId?.let { userId?.let {
@ -48,6 +49,7 @@ fun UserSettings(navController: NavHostController) {
val user = MobileAppDataBase.getInstance(context).userDao().getById(userId!!) val user = MobileAppDataBase.getInstance(context).userDao().getById(userId!!)
login.value = user!!.login login.value = user!!.login
password.value = user!!.password password.value = user!!.password
adsCount.value = MobileAppDataBase.getInstance(context).userDao().getAdsCount(userId)?: 0
} }
} }
} }
@ -67,6 +69,7 @@ fun UserSettings(navController: NavHostController) {
) )
LoginField(text = "Логин пользователя: ${login.value}") LoginField(text = "Логин пользователя: ${login.value}")
LoginField(text = "Пароль пользователя: ${password.value}") LoginField(text = "Пароль пользователя: ${password.value}")
LoginField(text = "Количество объявлений пользователя: ${adsCount.value}")
} }
} }
Column(modifier = Modifier Column(modifier = Modifier