diff --git a/app/src/main/java/com/example/myapplication/database/dao/UserDao.kt b/app/src/main/java/com/example/myapplication/database/dao/UserDao.kt index c092ae7..ea7fa1d 100644 --- a/app/src/main/java/com/example/myapplication/database/dao/UserDao.kt +++ b/app/src/main/java/com/example/myapplication/database/dao/UserDao.kt @@ -29,4 +29,7 @@ interface UserDao { @Delete suspend fun delete(user: User) + + @Query("select count(*) from cards where user_id = :userId") + fun getAdsCount(userId: Int): Int? } \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/user.kt b/app/src/main/java/com/example/myapplication/screens/user.kt index 666389f..fa326e6 100644 --- a/app/src/main/java/com/example/myapplication/screens/user.kt +++ b/app/src/main/java/com/example/myapplication/screens/user.kt @@ -40,6 +40,7 @@ fun UserSettings(navController: NavHostController) { val login = remember { mutableStateOf("") } val password = remember { mutableStateOf("") } + val adsCount = remember { mutableStateOf(0) } val userId = 1 userId?.let { @@ -48,6 +49,7 @@ fun UserSettings(navController: NavHostController) { val user = MobileAppDataBase.getInstance(context).userDao().getById(userId!!) login.value = user!!.login 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 = "Пароль пользователя: ${password.value}") + LoginField(text = "Количество объявлений пользователя: ${adsCount.value}") } } Column(modifier = Modifier