tgrapperon/swift-dependencies-additions

Additions suggestion/request

wltrup opened this issue · 1 comments

Hi Thomas,

I'd like to suggest two additions to your dependencies library:

  • a way to set the user interface style (ie, dark or light mode)
  • a way to directly get and set dates in UserDefaults

Thanks!

Hey @wltrup! Thanks for the suggestions!

I'll see if I can make the Dependency.Environment from _SwiftUIDependency property wrapper writable, so it injects the environment value at the same point it reads it.

About UserDefaults, I initially exposed what SwiftUI exposes through the AppStorage property wrapper, and UserDefaults through typed accessors, but you're right that UserDefaults also support writing Date directly, so I'll check if I can make it work nicely. It also should support arrays and dictionaries, so I'll check how far I can push the similarity of the API. I'll also try to guess why SwiftUI doesn't expose them!

I'm also going to convert this issue into a discussion if you wouldn't mind, as this is not a direct problem with the library.