Beispiel #1
0
 void UpdateSelectedColor()
 {
     if (CellParent != null && CellParent.SelectedColor != Xamarin.Forms.Color.Default)
     {
         _selectedColor.Color = CellParent.SelectedColor.MultiplyAlpha(0.5).ToAndroid();
         _ripple.SetColor(DrawableUtility.GetPressedColorSelector(CellParent.SelectedColor.ToAndroid()));
     }
     else
     {
         _selectedColor.Color = Android.Graphics.Color.Argb(125, 180, 180, 180);
         _ripple.SetColor(DrawableUtility.GetPressedColorSelector(Android.Graphics.Color.Rgb(180, 180, 180)));
     }
 }
Beispiel #2
0
 private void UpdateSelectedColor()
 {
     if (CellParent != null && CellParent.SelectedColor != Color.Default)
     {
         _selectedColor.Color = CellParent.SelectedColor.MultiplyAlpha(0.5).ToAndroid();
         _ripple.SetColor(RendererUtils.GetPressedColorSelector(CellParent.SelectedColor.ToAndroid()));
     }
     else
     {
         _selectedColor.Color = Android.Graphics.Color.Argb(125, 180, 180, 180);
         _ripple.SetColor(RendererUtils.GetPressedColorSelector(Android.Graphics.Color.Rgb(180, 180, 180)));
     }
 }
Beispiel #3
0
        private RippleDrawable CreateRipple(Color color)
        {
            if (Element is Layout)
            {
                var mask = new ColorDrawable(Color.White);
                ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask);

                return(ripple);
            }

            var background = View.Background;

            if (null == background)
            {
                var mask = new ColorDrawable(Color.White);
                ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask);

                return(ripple);
            }

            if (background is RippleDrawable)
            {
                ripple = (RippleDrawable)background.GetConstantState().NewDrawable();
                ripple.SetColor(GetPressedColorSelector(color));

                return(ripple);
            }

            ripple = new RippleDrawable(GetPressedColorSelector(color), background, null);

            return(ripple);
        }
Beispiel #4
0
        void UpdateEffectColor()
        {
            _view.Touch -= View_Touch;
            if (_layer != null)
            {
                _layer.Dispose();
                _layer = null;
            }
            var color = AddCommand.GetEffectColor(Element);

            if (color == Xamarin.Forms.Color.Default)
            {
                return;
            }

            if (_useRipple)
            {
                _ripple.SetColor(getPressedColorSelector(color.ToAndroid()));
            }
            else
            {
                _layer = new FrameLayout(Container.Context);
                _layer.LayoutParameters = new ViewGroup.LayoutParams(-1, -1);
                _layer.SetBackgroundColor(color.ToAndroid());
                _view.Touch += View_Touch;
            }
        }
Beispiel #5
0
        private RippleDrawable CreateRipple(Android.Graphics.Color color)
        {
            if (Element is Layout)
            {
                var mask = new ColorDrawable(Android.Graphics.Color.White);
                return(_ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask));
            }

            var back = _view.Background;

            if (back == null)
            {
                var mask = new ColorDrawable(Android.Graphics.Color.White);
                return(_ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask));
            }
            else if (back is RippleDrawable)
            {
                _ripple = (RippleDrawable)back.GetConstantState().NewDrawable();
                _ripple.SetColor(GetPressedColorSelector(color));

                return(_ripple);
            }
            else
            {
                return(_ripple = new RippleDrawable(GetPressedColorSelector(color), back, null));
            }
        }
Beispiel #6
0
        public void Update()
        {
            var color = AlterColor.GetAccent(_element).ToAndroid();

            var trackColors = new ColorStateList(new int[][]
            {
                new int[] { global::Android.Resource.Attribute.StateChecked },
                new int[] { -global::Android.Resource.Attribute.StateChecked },
            },
                                                 new int[] {
                Android.Graphics.Color.Argb(76, color.R, color.G, color.B),
                Android.Graphics.Color.Argb(76, 50, 50, 50)
            }
                                                 );

            _track.SetTintList(trackColors);

            var thumbColors = new ColorStateList(new int[][]
            {
                new int[] { global::Android.Resource.Attribute.StateChecked },
                new int[] { -global::Android.Resource.Attribute.StateChecked },
            },
                                                 new int[] {
                color,
                Android.Graphics.Color.Argb(255, 244, 244, 244)
            }
                                                 );

            _thumb.SetTintList(thumbColors);

            _background.SetColor(trackColors);
        }
Beispiel #7
0
        private RippleDrawable CreateRipple(Color color)
        {
            if (Element is Xamarin.Forms.Layout)
            {
                var mask = new ColorDrawable(Color.White);
                ripple = new RippleDrawable(GetRippleColorSelector(color), null, mask);
                return(ripple);
            }

            var back = View.Background;

            if (back == null)
            {
                var mask = new ColorDrawable(Color.White);
                return(ripple = new RippleDrawable(GetRippleColorSelector(color), null, mask));
            }

            if (back is RippleDrawable)
            {
                ripple = (RippleDrawable)back.GetConstantState().NewDrawable();
                ripple.SetColor(GetRippleColorSelector(color));

                return(ripple);
            }

            return(ripple = new RippleDrawable(GetRippleColorSelector(color), back, null));
        }
Beispiel #8
0
        private void UpdateEffectColor()
        {
            var color = ViewEffect.GetTouchFeedbackColor(Element);

            if (color == Color.Default)
            {
                return;
            }

            _color   = color.ToAndroid();
            _color.A = 80;

            if (EnableRipple)
            {
                _ripple.SetColor(GetPressedColorSelector(_color));
            }
        }
Beispiel #9
0
        void UpdateEffectColor()
        {
            var color = VisualFeedbackEffect.GetFeedbackColor(Element);

            var nativeColor = color.ToAndroid();

            nativeColor.A = 80;

            ripple?.SetColor(GetPressedColorSelector(nativeColor));
        }
        void UpdateRippleColor()
        {
            var rippleColor = ToFlatButton.GetRippleColor(Element).ToAndroid();

            if (Ripple == null)
            {
                Inset  = new InsetDrawable(Shape, 0, 1, 0, 1);
                Ripple = new RippleDrawable(getPressedColorSelector(rippleColor.ToArgb()), Inset, null);
            }
            else
            {
                Ripple.SetColor(getPressedColorSelector(rippleColor.ToArgb()));
            }
        }
        private void UpdateRipple()
        {
            if (_effect.IsDisabled)
            {
                return;
            }

            if (_effect.NativeAnimationColor == _rippleColor && _effect.NativeAnimationRadius == _rippleRadius)
            {
                return;
            }
            _rippleColor  = _effect.NativeAnimationColor;
            _rippleRadius = _effect.NativeAnimationRadius;
            _ripple.SetColor(GetColorStateList());
            _ripple.Radius = (int)(View.Context.Resources.DisplayMetrics.Density * _effect.NativeAnimationRadius);
        }
Beispiel #12
0
        private void SetEffectColor()
        {
            var color = TouchEffect.GetColor(Element);

            if (Xamarin.Forms.Color.Default == color)
            {
                return;
            }

            effectColor = color.ToAndroid();
            effectAlpha = (byte)(effectColor.A == 255 ? 80 : effectColor.A);

            if (EnableRipple)
            {
                ripple.SetColor(GetPressedColorSelector(effectColor));
            }
        }
Beispiel #13
0
        private void SetEffectColor()
        {
            var color = host.TapColor;

            if (color == Xamarin.Forms.Color.Default)
            {
                return;
            }

            this.color = color.ToAndroid();
            alpha      = this.color.A == 255 ? (byte)80 : this.color.A;

            if (EnableRipple)
            {
                ripple.SetColor(GetPressedColorSelector(this.color));
            }
        }
        void SetEffectColor()
        {
            var color = TouchEffect.GetColor(Element);

            if (color == Xamarin.Forms.Color.Default)
            {
                return;
            }

            _color = color.ToAndroid();
            _alpha = _color.A == 255 ? (byte)80 : _color.A;

            if (EnableRipple)
            {
                _ripple.SetColor(GetPressedColorSelector(_color));
            }
        }
Beispiel #15
0
        void UpdateEffectColor()
        {
            var color = TouchEffect.GetColor(Element);

            if (color == Xamarin.Forms.Color.Default)
            {
                return;
            }

            _color   = color.ToAndroid();
            _color.A = 80;

            if (EnableRipple)
            {
                _ripple.SetColor(GetPressedColorSelector(_color));
            }
        }
Beispiel #16
0
        private void UpdateRipple()
        {
            if (_effect?.IsDisabled ?? true)
            {
                return;
            }

            if (_effect.NativeAnimationColor == _rippleColor && _effect.NativeAnimationRadius == _rippleRadius)
            {
                return;
            }
            _rippleColor  = _effect.NativeAnimationColor;
            _rippleRadius = _effect.NativeAnimationRadius;
            _ripple.SetColor(GetColorStateList());
            if (AndroidOS.Build.VERSION.SdkInt >= AndroidOS.BuildVersionCodes.M)
            {
                _ripple.Radius = (int)(View.Context.Resources.DisplayMetrics.Density * _effect.NativeAnimationRadius);
            }
        }
Beispiel #17
0
        void UpdateRipple()
        {
            if (effect?.IsDisabled ?? true)
            {
                return;
            }

            if (effect.NativeAnimationColor == rippleColor && effect.NativeAnimationRadius == rippleRadius)
            {
                return;
            }

            rippleColor  = effect.NativeAnimationColor;
            rippleRadius = effect.NativeAnimationRadius;
            ripple.SetColor(GetColorStateList());
            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                ripple.Radius = (int)(View.Context.Resources.DisplayMetrics.Density * effect.NativeAnimationRadius);
            }
        }