I've got a theme switcher in my Xamarin Forms app that works great using a set of static Resource files. However, my app also has an iOS extension and the theming breaks down at that point.
In the main application, I am assigning the theme to the current application's Resources property (ie. Global Styles) and all views utilize the resources and automatically change when the theme changes. Something like so:
Application.Current.Resources = new MyThemes.Default();
In the extension however, there is no "Application" as pages are just added directly to the root UIViewController. Because of that, I can't use Application.Current, which is always null. The pages work fine, but no theme is applied. I can use the themes if I manually assign them to each page as I create them, though it doesn't act like Global Styles and cascade down to child pages. In other words, something like this:
var myPage = new ContentPage();
myPage.Resources = new MyThemes.Default();
viewController = myPage.CreateViewController();
This works, but it's not perfect and would require me to rewrite portions of shared views that currently are styled automatically by the Global Styles.
I've been digging around trying to find a clue to implement this proper, but haven't had any luck and feel like I'm missing something. Everything I've found only seems to talk about themes from a core application point and not extensions.
Are there documentation or examples on using Theme Resources and Global Styles in a Xamarin Forms iOS Extensions? Any help is appreciated, thanks!
Edit: It's also worth noting that references to Application.Current in custom renderers cause silent crashes when the custom renderer is loaded as an extension. This can be fixed by using a BindableProperty instead.