guillermomuntaner / Burritos

A collection of Swift Property Wrappers (formerly "Property Delegates")
MIT License
1.33k stars 43 forks source link

Update DynamicUIColor to use UIColor(dynamicProvider:) #2

Closed kylebshr closed 5 years ago

kylebshr commented 5 years ago

This creates a color that will auto-update on iOS 13, and falls back to the light color on any version less.

I'm very unsure about my approach with the tests - what's best practice for testing different iOS versions behavior? Open to suggestions.

guillermomuntaner commented 5 years ago

Hey @kylebshr thanks for the pull request.

My original implementation had two goals:

  1. Supporting systemwide dark mode in iOS 13 while trying to
  2. Offer a usable alternative to implement a custom dark mode (e.g. from app settings) in iOS <= 13.

With your changes the latter is lost. I am just thinking how to reintroduce this while keeping your UIColor(dynamicProvider:) changes.

My best idea so far is to reintroduce the 3rd parameter with a different shape. It could be an optional closure or a closure that returns an optional mode, where absence of value could mean using the system logic.

Feel free to do any change in this direction; otherwise I will try to help later today/tomorrow!

Thanks a lot for contributing and best regards.

guillermomuntaner commented 5 years ago

@kylebshr how do you like it?

I think it is a nice compromise between a nice default simple API, customisation possibilities & backwards compatibility.

kylebshr commented 5 years ago

Hey, sorry I didn't have time to take a look sooner - seems like a good approach 👍