Hi
For my app i need to have two themes, normal and dark (how original..!)
But i don't really know how to handle that with Xamarin.
In my settings i have a switch allowing the user to choose between the two themes. It saves the value as a bool into a settings plugin.
So far i just succeded to change the background according to that bool, this way. And i'm sure it's not proper way at all.
protected override void OnAppearing()
{
var image = "";
if (AppSettings.GetValueOrDefault("switch_night", false))
{
image = "fond_fonce.png";
}
else
{
image = "fond_clair.png";
}
BackgroundImage = image;
base.OnAppearing();
}
But i need to change not only the background, all this elements have to change:
- colorPrimary in styles.xml android project
- colors of all buttons (defined in xaml now)
- Colors of some ios elements (haven't spend much time on this platform yet)
I read about custom renderers, but haven't really understood deeply how it work. Is it the best solution, or there is easier way to achieve?
Thanks