private void BlurStyleButtonOnClicked(object sender, EventArgs e) { var selectedButton = (Button)sender; if (selectedButton == LightButton) { _blurStyle = MaterialFrame.MaterialFrame.BlurStyle.Light; } else if (selectedButton == DarkButton) { _blurStyle = MaterialFrame.MaterialFrame.BlurStyle.Dark; } else { _blurStyle = MaterialFrame.MaterialFrame.BlurStyle.ExtraLight; } ResourcesHelper.SetBlurStyle(_blurStyle); selectedButton.TextColor = _blurStyle != MaterialFrame.MaterialFrame.BlurStyle.ExtraLight ? ResourcesHelper.GetResourceColor("TextPrimaryColor") : ResourcesHelper.GetResourceColor("TextPrimaryDarkColor"); selectedButton.BackgroundColor = ResourcesHelper.GetResourceColor(ResourcesHelper.DynamicPrimaryColor); foreach (var button in _blurStyleButtons) { if (button == selectedButton) { continue; } button.TextColor = _blurStyle != MaterialFrame.MaterialFrame.BlurStyle.ExtraLight ? ResourcesHelper.GetResourceColor("TextPrimaryDarkColor") : ResourcesHelper.GetResourceColor("TextPrimaryColor"); button.BackgroundColor = Color.Transparent; } }
public static void SetBlurStyle(MaterialFrame.MaterialFrame.BlurStyle blurStyle) { string wallpaper = string.Empty; switch (blurStyle) { case MaterialFrame.MaterialFrame.BlurStyle.Light: SetDarkColors(false); switch (Device.RuntimePlatform) { case Device.iOS: wallpaper = "catalina_dark.jpg"; break; case Device.Android: wallpaper = "bing_dark.jpg"; break; default: wallpaper = "bliss_portrait.jpg"; break; } break; case MaterialFrame.MaterialFrame.BlurStyle.Dark: SetDarkColors(true); switch (Device.RuntimePlatform) { case Device.iOS: wallpaper = "catalina_light.jpg"; break; case Device.Android: wallpaper = "milky_light.jpg"; break; default: wallpaper = "windows7_portrait.png"; break; } break; case MaterialFrame.MaterialFrame.BlurStyle.ExtraLight: SetLightColors(true); switch (Device.RuntimePlatform) { case Device.iOS: wallpaper = "undersea_light.jpg"; break; case Device.Android: wallpaper = "bing_light.jpg"; break; default: wallpaper = "vista_portrait_2.jpg"; break; } break; } TaskMonitor.Create( async() => { SetDynamicResource(DynamicBackgroundImageSource, new FileImageSource { File = wallpaper }); // give some time to the big picture to load await Task.Delay(100); SetDynamicResource(DynamicBlurStyle, blurStyle); }); }