From 21dace91cd88db9303e8546ef8f3df51a361245d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 22 Dec 2023 23:17:12 +0400 Subject: [PATCH] =?UTF-8?q?4-=D1=83=D1=8E=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB?= =?UTF-8?q?,=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8F=20=D1=81=D0=B2=D1=8F=D0=B7=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=81=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=BA=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/myapplication/database/dao/UserDao.kt | 3 +++ app/src/main/java/com/example/myapplication/screens/user.kt | 3 +++ 2 files changed, 6 insertions(+) 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