bgogetap / StickyHeaders

Easily add Sticky Headers to your RecyclerView
Apache License 2.0
521 stars 88 forks source link

Please add support for dark mode #95

Open mobilekosmos opened 4 years ago

mobilekosmos commented 4 years ago

According to material design in dark mode elevation is defined by a transparent white layer over the original color instead of using shadows. I tried changing the background color of the sticky headers by using setStickyHeaderListener in set the backgroundColor in headerAttached but this doesn't work reliable, don't know why, in one of our lists the colors gets changed starting with the second sticky header, in other lists using the same StickyLayoutManager the headers don't change at all.

bgogetap commented 4 years ago

There are no other views used for the sticky header besides the item view for your list item.

https://github.com/bgogetap/StickyHeaders/blob/master/stickyheaders/src/main/java/com/brandongogetap/stickyheaders/StickyHeaderPositioner.java#L242

This library shouldn't be interfering with any sort of theme customization.

What changes do you think this library needs to support solving your issue?

mobilekosmos commented 4 years ago

I think we need a function to set a color that is applied instead of the elevation in case of being in dark mode.

bgogetap commented 4 years ago

Quickly reading the Material Design spec, it says a transparent overlay should be used, not a different background color. I think shadows stay as well. https://material.io/design/color/dark-theme.html#properties

Not sure why updating the view in headerAttached isn't working, though I do see a potential for a bug if setListener is called after a header has been stickied. There is no "catch up", so if there is already a header stickied when the listener is attached, it won't get called until the next attach event (#97).

Can you verify you are getting the expected callbacks at the right time? If not, there may be some work to be done here, otherwise I'm not sure what else this library could do. I'm actually not positive how the Material Design elevation spec is handled on Android in dark mode.

mobilekosmos commented 4 years ago

"Quickly reading the Material Design spec, it says a transparent overlay should be used, not a different background color." I know, but what is the result of doing so? the color changes, so the material spec says how you come up with the color, not how to implement it which can be done/is being done setting colors. There is a template somewhere in the documentation with graphics for each elevation, you can use a color picker and then you know which hex codes you can use.

mobilekosmos commented 4 years ago

"Can you verify you are getting the expected callbacks at the right time?" I debugged the code and the callbacks are being called at the right time, when I first open the list no callback (as expected), once I scroll up and the first header gets sticked headerAttached is called, but only the second time, with the second header the background color really changes, maybe some caching issue or because of recycling some view? Cannot see where the issue comes from yet.