Exemple #1
0
        internal static ColorStateList GetColorStateList(this AppCompatCheckBox platformCheckBox, ICheckBox check)
        {
            AColor tintColor;

            // For the moment, we're only supporting solid color Paint for the Android Checkbox
            if (check.Foreground is SolidPaint solid)
            {
                var color = solid.Color;
                tintColor = color.ToPlatform();
            }
            else
            {
                Graphics.Color accent = platformCheckBox.Context?.GetAccentColor() ?? Graphics.Color.FromArgb("#ff33b5e5");
                tintColor = accent.ToPlatform();
            }

            return(ColorStateListExtensions.CreateCheckBox(tintColor));
        }
Exemple #2
0
        public static void UpdateForeground(this AppCompatCheckBox nativeCheckBox, ICheckBox check)
        {
            // TODO: Delete when implementing the logic to set the system accent color.
            Graphics.Color accent = Graphics.Color.FromArgb("#ff33b5e5");

            var targetColor = accent;

            // For the moment, we're only supporting solid color Paint for the Android Checkbox
            if (check.Foreground is SolidPaint solid)
            {
                targetColor = solid.Color;
            }

            var tintColor = targetColor.ToNative();

            var tintList = ColorStateListExtensions.CreateCheckBox(tintColor);

            var tintMode = PorterDuff.Mode.SrcIn;

            CompoundButtonCompat.SetButtonTintList(nativeCheckBox, tintList);
            CompoundButtonCompat.SetButtonTintMode(nativeCheckBox, tintMode);
        }