Skip to content

Commit

Permalink
Set app name - Activity title
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Nov 8, 2024
1 parent 767ff14 commit 6a46977
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -900,7 +911,8 @@ fun MainScreen(
modifier =
Modifier
.fillMaxSize()
.padding(padding),
.padding(padding)
.padding(40.dp),
)
}
},
Expand Down

0 comments on commit 6a46977

Please sign in to comment.