Skip to content

Commit

Permalink
fix(ui): top bar title translation
Browse files Browse the repository at this point in the history
  • Loading branch information
rhunk committed Apr 9, 2024
1 parent 1f03592 commit 9024b22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Navigation(
} == true }

TopAppBar(title = {
routes.getCurrentRoute(navBackStackEntry)?.title?.invoke() ?: Text(text = routes.getCurrentRoute(navBackStackEntry)?.routeInfo?.translatedKey ?: "Unknown Page")
val currentRoute = routes.getCurrentRoute(navBackStackEntry)
currentRoute?.title?.invoke() ?: Text(text = currentRoute?.routeInfo?.translatedKey?.value ?: "Unknown Page")
}, navigationIcon = {
val backButtonAnimation by animateFloatAsState(if (canGoBack) 1f else 0f,
label = "backButtonAnimation"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class RouteInfo(
val icon: ImageVector = Icons.Default.Home,
val primary: Boolean = false,
) {
var translatedKey: String? = null
var translatedKey: Lazy<String?>? = null
val childIds = mutableListOf<String>()
}

Expand Down Expand Up @@ -132,7 +132,7 @@ class Routes(
this.routeInfo = routeInfo
routes = this@Routes
context = this@Routes.context
this.routeInfo.translatedKey = context.translation.getOrNull("manager.routes.${route.routeInfo.key.substringBefore("/")}")
this.routeInfo.translatedKey = lazy { context.translation.getOrNull("manager.routes.${route.routeInfo.key.substringBefore("/")}") }
}
routes.add(route)
return route
Expand Down

0 comments on commit 9024b22

Please sign in to comment.