void UpdateAllColors() { // TODO: Fix this once Google implements the new way. // Right now, copy what is done with the activity indicator. Color progressColor = Element.ProgressColor; Color backgroundColor = Element.BackgroundColor; if (progressColor.IsDefault) { if (backgroundColor.IsDefault) { // reset everything to defaults _colorScheme = new BasicColorScheme( _defaultColorScheme.PrimaryColor, _defaultColorScheme.PrimaryLightColor, _defaultColorScheme.PrimaryColor); } else { // handle the case where only the background is set var background = backgroundColor.ToUIColor(); // TODO: Potentially override background alpha to match material design. // TODO: Potentially override primary color to match material design. _colorScheme = new BasicColorScheme( _defaultColorScheme.PrimaryColor, background, _defaultColorScheme.PrimaryColor); } } else if (!progressColor.IsDefault) { if (backgroundColor.IsDefault) { // handle the case where only the progress is set var progress = progressColor.ToUIColor(); _colorScheme = new BasicColorScheme( progress, progress.ColorWithAlpha(BackgroundAlpha), progress); } else { // handle the case where both are set var background = backgroundColor.ToUIColor(); var progress = progressColor.ToUIColor(); // TODO: Potentially override alpha to match material design. _colorScheme = new BasicColorScheme( progress, background, progress); } } }
void UpdateAllColors() { Color progressColor = Element.ProgressColor; Color backgroundColor = Element.BackgroundColor; if (progressColor.IsDefault) { if (backgroundColor.IsDefault) { // reset everything to defaults _colorScheme = new BasicColorScheme( _defaultColorScheme.PrimaryColor, _defaultColorScheme.PrimaryLightColor, _defaultColorScheme.PrimaryColor); } else { // handle the case where only the background is set var background = backgroundColor.ToUIColor(); _colorScheme = new BasicColorScheme( _defaultColorScheme.PrimaryColor, background, _defaultColorScheme.PrimaryColor); } } else if (!progressColor.IsDefault) { if (backgroundColor.IsDefault) { // handle the case where only the progress is set var progress = progressColor.ToUIColor(); progress.GetRGBA(out _, out _, out _, out var alpha); _colorScheme = new BasicColorScheme( progress, progress.ColorWithAlpha(alpha * MaterialColors.SliderTrackAlpha), progress); } else { // handle the case where both are set var background = backgroundColor.ToUIColor(); var progress = progressColor.ToUIColor(); _colorScheme = new BasicColorScheme( progress, background, progress); } } }
protected override void OnElementChanged(ElementChangedEventArgs <ProgressBar> e) { _colorScheme?.Dispose(); _colorScheme = CreateColorScheme(); base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { _defaultColorScheme = CreateColorScheme(); SetNativeControl(CreateNativeControl()); } UpdateProgressColor(); UpdateProgress(); ApplyTheme(); } }