stleamist / BetterSafariView

A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI.
MIT License
582 stars 57 forks source link

preferredControlAccentColor does not support dark mode in Asset Catalog colors #16

Open sebmos opened 3 years ago

sebmos commented 3 years ago

Hey,

I'm using the pre-defined AccentColor color in the Asset Catalog of my app, and I've struggled a bit applying it to the SafariView.

I initially tried this, which I'm using in a few places in my app:

.preferredControlAccentColor(.accentColor)

Unfortunately, this resulted iOS' default blue accent color being used. I guess SFSafariViewController lives in its own context that ignores the accent color?

I then tried loading the AccentColor from the Asset Catalog like this:

.preferredControlAccentColor(Color("AccentColor"))

This worked fine in light mode, but failed in dark mode: The light mode color was used in both scenarios.

I finally got it to work by switching back to the deprecated method, setting the UIColor directly:

.preferredControlTintColor(UIColor(named: "AccentColor"))

This works - it appears converting from Color to UIColor loses a lot of information!

I'm not sure if there's a good way to solve this, but it might be worth putting this into the README.md.

stleamist commented 3 years ago

Hi Sebastian,

Thank you for reporting this issue! It will be fixed in the next release.

I'll keep you informed when a new version has been released :)

sbilling commented 1 year ago

@stleamist was this ever resolved to your knowledge? I am still running into it