exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6.01k stars 554 forks source link

Dynamic / Named Colors #691

Open proj-sashido opened 4 years ago

proj-sashido commented 4 years ago

Hi there,

First off - LOVE this library! I wanted to ask if there were any way to used named/dynamic colors, such that the color changes when the device changes UIUserInterfaceStyle (i.e. from Light Mode to Dark Mode)

This feature is available for UIColor in iOS 13+ using UIColor(named:) if using Asset Catalogs or:

let dynamicColor = UIColor { (traitCollection: UITraitCollection) -> UIColor in
    switch traitCollection.userInterfaceStyle {
    case
      .unspecified,
      .light: return .white
    case .dark: return .black
    }
}

if creating them programmatically.

I noticed that the initialisers for Color in Macaw don't seem to allow for this. If it's not currently supported, are there any plans to do so?

Alternatively, how would I go about manually changing the colours of my nodes upon detecting a change in the UIUserInterfaceStyle?

Cheers, Saf

amarunko commented 4 years ago

Hi, @project-academy , actually Macaw doesn't support dark mode for now, but it is good idea to add minimal methods for supporting changing trait collection etc