Open brudaswen opened 1 year ago
Hello. When I thought about implementing such feature I had a slightly different idea in mind.
When using Compose, app's theme is usually not set to dark. Just use CompositionLocal with required palette. So when using standard android tools, same picture will be taken for any color scheme.
I think it would be more practical to solve such a moment at level of generated code: put all images in drawable-nodpi
(or another suitable directory) with different names, for example my_image_light.xml
and my_image_night.xml
, and in generated code make function with argument, like:
Res.image.my_image(isDark = true)
I would like to think that adding the images into the resource directories as originally proposed by @brudaswen is the simpler option here, since it would make use of Androids in built darkmode support and would also work for XML based layouts?
When doing that it would be trivial to add your solution too and reference a different image in a theme. Only like proposed by @brudaswen both solutions would work without any additional overhead too.
Also the proposed solution would work seamlessly for iOS, which seems like a nice solution tbh.
Any news about this MR? 😄 We also interested in supporting of dark/light theme for shared images
Any news about this MR? 😄 We also interested in supporting of dark/light theme for shared images
We switched to our own version https://github.com/brudaswen/libres/releases/tag/1.2.2-night until there is another solution. The version is available via jitpack https://jitpack.io/#brudaswen/libres/1.2.2-night
Any news about this MR? 😄 We also interested in supporting of dark/light theme for shared images
We switched to our own version https://github.com/brudaswen/libres/releases/tag/1.2.2-night until there is another solution. The version is available via jitpack https://jitpack.io/#brudaswen/libres/1.2.2-night
Thank you for publishing your fork as a library. Our team is also in need of this functionality. I wonder why is this PR not approved by library maintainers yet...
Night/Dark Mode Images
Night/Dark Mode images are supported for Android and iOS by adding the
(night)
modifier. The filename and type of the image must match the corresponding day/light version without the(night)
modifier.drawable-night-nodpi
."appearances" : [ { "appearance" : "luminosity", "value" : "dark" } ]
entry in theimageset
.Closes #24
Output Example
Android
iOS