-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix language settings #726
Conversation
} | ||
val configuration = resources.configuration | ||
configuration.setLocale(locale) | ||
resources.updateConfiguration(configuration, resources.displayMetrics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateConfiguration()
is deprecated but it can simplify implementation.
If there is a better way to implement this, it may be better to change it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing this issue 👍
How about adding the following code to uicomponent-compose:core
?
This way, you don't need to rely on updateConfiguration
.
private val TextSettingLocal = compositionLocalOf<>()
@Coposable
fun MultiLangText.getTextWithSetting() {
when(LocalLangSetting.current) {
Lang.SYSTEM -> currentLangTitle
...
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks your proposal !
I implemented it as a trial. 28e48c7
If it looks like ok, I'll try to rewrite the other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
👀 |
} | ||
|
||
@JvmInline | ||
value class LangSettingProvidableCompositionLocal internal constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure if this value class approach is good or bad. Is there any reason for this? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm also not sure all that well.
I use this approach that is used in Coil.
It seems like a good approach that current
can implement custom getter (can use composable function).
If coil, it is needed the context to get the ImageLoader so can use LocalContext, but this does not require composable functions so it might not make sense...
https://github.com/coil-kt/coil/blob/99c45789ec19895f657d0be7303da2e666b64f14/coil-compose-singleton/src/main/java/coil/compose/LocalImageLoader.kt#L51
because 0.39.0 is not supported 'value class'
28e48c7
to
a29f7fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put together commits 41a83ba
@Composable | ||
fun Lang?.getTitle(): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete context and add composable annotation.
This maybe resolves #694
@@ -67,7 +67,7 @@ allprojects { | |||
targetExclude('bin/**/*.kt') | |||
targetExclude("**/generated/**/*.kt") | |||
|
|||
ktlint("0.39.0") | |||
ktlint("0.42.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrade ktlint because value class is not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thank you for the cool pull request 🆒 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for the new mechanisms to DroidKaigi app!
Issue
Overview (Required)
combine()
.Links
Screenshot