From 6a46977863ca779ac19f9b8e6fa6a84e9e218279 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Fri, 8 Nov 2024 10:10:02 -0300 Subject: [PATCH] Set app name - Activity title --- .../greenart7c3/nostrsigner/ui/MainScreen.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt index 9d38f1f..e28914c 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt @@ -545,10 +545,21 @@ fun MainScreen( title = { var title by remember { mutableStateOf(routes.find { it.route.startsWith(destinationRoute) }?.title ?: "") } LaunchedEffect(destinationRoute) { - if (destinationRoute.startsWith("Permission/")) { + if (destinationRoute.startsWith("Permission/") || destinationRoute.startsWith("Activity/")) { launch(Dispatchers.IO) { navBackStackEntry?.arguments?.getString("packageName")?.let { packageName -> - title = database.applicationDao().getByKey(packageName)?.application?.name ?: packageName + title = if (destinationRoute.startsWith("Activity/")) { + "${database.applicationDao().getByKey(packageName)?.application?.name ?: packageName} - ${routes.find { it.route.startsWith(destinationRoute) }?.title}" + } else { + database.applicationDao().getByKey(packageName)?.application?.name ?: packageName + } + } + navBackStackEntry?.arguments?.getString("key")?.let { packageName -> + title = if (destinationRoute.startsWith("Activity/")) { + "${database.applicationDao().getByKey(packageName)?.application?.name ?: packageName} - ${routes.find { it.route.startsWith(destinationRoute) }?.title}" + } else { + database.applicationDao().getByKey(packageName)?.application?.name ?: packageName + } } } } else { @@ -900,7 +911,8 @@ fun MainScreen( modifier = Modifier .fillMaxSize() - .padding(padding), + .padding(padding) + .padding(40.dp), ) } },