Skip to content

Commit

Permalink
Refine comments and remove debug print in resource environment
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Dec 11, 2023
1 parent cd03ffd commit 5208ef6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ internal fun rememberEnvironment(): ResourceEnvironment {
}
}

//expensive operation - do not use during recomposition
//it is required for a non-composable access to string resources
/**
* Provides the resource environment for non-composable access to string resources.
* It is an expensive operation! Don't use it in composable functions with no cache!
*/
internal expect fun getResourceEnvironment(): ResourceEnvironment

internal fun Resource.getPathByEnvironment(environment: ResourceEnvironment): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal actual fun getResourceEnvironment(): ResourceEnvironment {
val mainScreen = UIScreen.mainScreen
val isDarkTheme = mainScreen.traitCollection().userInterfaceStyle == UIUserInterfaceStyle.UIUserInterfaceStyleDark

//there is no an API to get a screen size in MM and calculate a real DPI
//there is no an API to get a physical screen size and calculate a real DPI
val density = mainScreen.scale.toFloat()
return ResourceEnvironment(
language = LanguageQualifier(locale.languageCode),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ internal actual fun getResourceEnvironment(): ResourceEnvironment {
((displaySizePX / displaySizeMM) * 25.4f).toInt()
} ?: 0

println("DPI = $dpi")

return ResourceEnvironment(
language = LanguageQualifier(locale.languageCode),
region = RegionQualifier(locale.regionCode.orEmpty()),
Expand Down

0 comments on commit 5208ef6

Please sign in to comment.