protected override void OnElementChanged(ElementChangedEventArgs <Slider> e) { _colorScheme?.Dispose(); _colorScheme = CreateColorScheme(); base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { _defaultColorScheme = CreateColorScheme(); SetNativeControl(CreateNativeControl()); Control.Continuous = true; Control.ValueChanged += OnControlValueChanged; } UpdateMaximum(); UpdateMinimum(); UpdateValue(); ApplyTheme(); } }
protected override void OnElementChanged(ElementChangedEventArgs <ActivityIndicator> e) { _colorScheme?.Dispose(); _colorScheme = CreateColorScheme(); base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { _defaultColorScheme = CreateColorScheme(); SetNativeControl(CreateNativeControl()); _backgroundLayer = new CAShapeLayer { LineWidth = Control.StrokeWidth, FillColor = UIColor.Clear.CGColor, Hidden = true }; Control.Layer.InsertSublayer(_backgroundLayer, 0); } UpdateColor(); UpdateIsRunning(); SetBackgroundColor(Element.BackgroundColor); ApplyTheme(); } }
private void UpdateColor() { if (_renderer?.NativeView == null || _backgroundElement == null || _visualElement == null) { return; } var color = _backgroundElement.Color == Color.Default ? _visualElement.BackgroundColor == Color.Default ? Color.Default : _visualElement.BackgroundColor : _backgroundElement.Color; switch (_renderer.NativeView) { case Card mCard: if (color == Color.Default) { return; } using (var themer = new SemanticColorScheme()) { themer.SurfaceColor = _backgroundElement.Color.ToUIColor(); CardsColorThemer.ApplySemanticColorScheme(themer, mCard); } break; case ChipView mChip: if (color == Color.Default) { return; } mChip.SetBackgroundColor(_backgroundElement.Color.ToUIColor(), UIControlState.Normal); break; case MButton mButton: if (color == Color.Default) { return; } mButton.SetBackgroundColor(_backgroundElement.Color.ToUIColor()); break; default: _renderer.NativeView.BackgroundColor = UIColor.Clear; if (color == Color.Default) { return; } _renderer.NativeView.SetColor(_backgroundElement.Color); break; } }
public MaterialTextField(IMaterialEntryRenderer element, IFontElement fontElement) { VisualElement.VerifyVisualFlagEnabled(); ClearButtonMode = UITextFieldViewMode.Never; _activeTextinputController = new MTextInputControllerFilled(this); TextInsetsMode = TextInputTextInsetsMode.IfContent; _typographyScheme = CreateTypographyScheme(); _colorScheme = (SemanticColorScheme)CreateColorScheme(); ApplyTypographyScheme(fontElement); ApplyTheme(element); }
void UpdateAllColors() { Color progressColor = Element.ProgressColor; Color backgroundColor = Element.BackgroundColor; if (progressColor.IsDefault) { if (backgroundColor.IsDefault) { // reset everything to defaults _colorScheme = CreateSemanticColorScheme(); var progress = _colorScheme.PrimaryColor; progress.GetRGBA(out _, out _, out _, out var alpha); _colorScheme.BackgroundColor = progress.ColorWithAlpha(alpha * MaterialColors.SliderTrackAlpha); } else { // handle the case where only the background is set var background = backgroundColor.ToUIColor(); _colorScheme = new SemanticColorScheme() { BackgroundColor = background }; } } 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 SemanticColorScheme() { PrimaryColor = progress, BackgroundColor = progress.ColorWithAlpha(alpha * MaterialColors.SliderTrackAlpha) }; } else { // handle the case where both are set var background = backgroundColor.ToUIColor(); var progress = progressColor.ToUIColor(); _colorScheme = new SemanticColorScheme() { PrimaryColor = progress, BackgroundColor = background }; } } }
protected override void OnElementChanged(ElementChangedEventArgs <ActivityIndicator> e) { _colorScheme?.Dispose(); _colorScheme = CreateColorScheme(); base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { _defaultColorScheme = CreateColorScheme(); SetNativeControl(CreateNativeControl()); } UpdateColor(); UpdateIsRunning(); ApplyTheme(); } }
protected override void OnElementChanged(ElementChangedEventArgs <ProgressBar> e) { _colorScheme?.Dispose(); _colorScheme = CreateSemanticColorScheme(); _containerScheme?.Dispose(); _containerScheme = new ContainerScheme(); base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { _defaultColorScheme = CreateSemanticColorScheme(); SetNativeControl(CreateNativeControl()); } UpdateProgressColor(); UpdateProgress(); ApplyTheme(); } }
public void UpdateGradients() { if (_renderer?.NativeView == null) { return; } var emptyGradients = _backgroundElement.Gradients == null || !_backgroundElement.Gradients.Any(); switch (_renderer.NativeView) { case Card mCard when emptyGradients: using (var themer = new SemanticColorScheme()) { themer.SurfaceColor = _visualElement.BackgroundColor.ToUIColor(); CardsColorThemer.ApplySemanticColorScheme(themer, mCard); } return; case ChipView mChip when emptyGradients: mChip.SetBackgroundColor(_visualElement.BackgroundColor.ToUIColor(), UIControlState.Normal); return; case UIView view when emptyGradients: view.BackgroundColor = _visualElement.BackgroundColor.ToUIColor(); return; } /* Chip does not accept background changes and does not support gradient */ if (_renderer.NativeView is ChipView) { return; } _renderer.NativeView.SetGradient(_backgroundElement); }
public MaterialEntryRenderer() { VisualElement.VerifyVisualFlagEnabled(); _colorScheme = (SemanticColorScheme)CreateColorScheme(); _typographyScheme = CreateTypographyScheme(); }