mkko / DrawerView

A drop-in view, to be used as a drawer anywhere in your app
MIT License
373 stars 57 forks source link

Customize backgroundEffect blur styles for BackgroundEffectStyle.systemDefault #66

Open mixdesign opened 2 months ago

mixdesign commented 2 months ago

Hey! Thanks for great lib which we use in our Sajda app for a long time.

Sajda - is a super app for Muslims with more than 3 million MAU and 1.5 million DAU.

We faced with a small limitation in DrawerView. When I would like to set a backgroundEffect to systemDefault, for light mode I can not set it to .extraLight or some other values iOS provides!

So, this PR basically adds this customization for both dark and light modes, without changing the current behavior.

Regards.

mkko commented 1 month ago

Hey, thank you for the great feedback. Also thank you chiming in on this.

I would hope to integrate the whole style using the given trait collection (user interface style, accessibility contrast). I'd be more than happy to add support for these. Unfortunately I don't have time to write a full example, but what would you think about something following:

public var backgroundEffect: (TraitCollection) -> UIVisualEffect?

This would be similar to what UIColor has. UIColor has this great UIColor(dynamicProvider: (UITraitCollection) -> UIColor>) constructor, but unfortunately UIVisualEffect doesn't, at least to my knowledge. With this dynamic provider, we could get rid of the custom BackgroundEffectStyle altogehter.

Generally I would think that people either care about the dark mode or don't. When they don't, they might skip setting the value which would lead to difficult to detect bugs in their apps. Similar to setting only a background color of a label to fixed value but not realizing that the text color is still dnyamic. WDYT?