Esempio n. 1
0
        public void SetBorderBrush(RadialGradientPaint radialGradientPaint)
        {
            _strokeColor = null;
            _stroke      = radialGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 2
0
        public static void UpdateCancelButton(this UISearchBar uiSearchBar, ISearchBar searchBar,
                                              UIColor?cancelButtonTextColorDefaultNormal, UIColor?cancelButtonTextColorDefaultHighlighted, UIColor?cancelButtonTextColorDefaultDisabled)
        {
            uiSearchBar.ShowsCancelButton = !string.IsNullOrEmpty(uiSearchBar.Text);

            // We can't cache the cancel button reference because iOS drops it when it's not displayed
            // and creates a brand new one when necessary, so we have to look for it each time
            var cancelButton = uiSearchBar.FindDescendantView <UIButton>();

            if (cancelButton == null)
            {
                return;
            }

            if (searchBar.CancelButtonColor == null)
            {
                cancelButton.SetTitleColor(cancelButtonTextColorDefaultNormal, UIControlState.Normal);
                cancelButton.SetTitleColor(cancelButtonTextColorDefaultHighlighted, UIControlState.Highlighted);
                cancelButton.SetTitleColor(cancelButtonTextColorDefaultDisabled, UIControlState.Disabled);
            }
            else
            {
                cancelButton.SetTitleColor(searchBar.CancelButtonColor.ToNative(), UIControlState.Normal);
                cancelButton.SetTitleColor(searchBar.CancelButtonColor.ToNative(), UIControlState.Highlighted);
                cancelButton.SetTitleColor(searchBar.CancelButtonColor.ToNative(), UIControlState.Disabled);
            }
        }
Esempio n. 3
0
        public void SetBackground(RadialGradientPaint radialGradientPaint)
        {
            _backgroundColor = null;
            _background      = radialGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 4
0
        public void SetBorderBrush(LinearGradientPaint linearGradientPaint)
        {
            _strokeColor = null;
            _stroke      = linearGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 5
0
        public void SetBackground(LinearGradientPaint linearGradientPaint)
        {
            _backgroundColor = null;
            _background      = linearGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 6
0
        protected override void SetupDefaults(UIButton nativeView)
        {
            ButtonTextColorDefaultNormal      = nativeView.TitleColor(UIControlState.Normal);
            ButtonTextColorDefaultHighlighted = nativeView.TitleColor(UIControlState.Highlighted);
            ButtonTextColorDefaultDisabled    = nativeView.TitleColor(UIControlState.Disabled);

            base.SetupDefaults(nativeView);
        }
Esempio n. 7
0
        public static void UpdateThumbColor(this UISwitch uiSwitch, ISwitch view, UIColor?defaultThumbColor)
        {
            if (view == null)
            {
                return;
            }

            Maui.Color thumbColor = view.ThumbColor;
            uiSwitch.ThumbTintColor = thumbColor.IsDefault ? defaultThumbColor : thumbColor.ToNative();
        }
Esempio n. 8
0
        public static void UpdateThumbColor(this UISwitch uiSwitch, ISwitch view, UIColor?defaultThumbColor)
        {
            if (view == null)
            {
                return;
            }

            Graphics.Color thumbColor = view.ThumbColor;
            uiSwitch.ThumbTintColor = thumbColor?.ToPlatform() ?? defaultThumbColor;
        }
Esempio n. 9
0
        public void SetBorderBrush(SolidPaint solidPaint)
        {
            _strokeColor = solidPaint.Color == null
                                ? UIColor.Clear
                                : solidPaint.Color.ToNative();

            _stroke = null;

            SetNeedsDisplay();
        }
Esempio n. 10
0
		public void SetBackground(SolidPaint solidPaint)
		{
			if (solidPaint.Color == null)
				SetDefaultBackgroundColor();
			else
				_backgroundColor = solidPaint.Color.ToPlatform();

			_background = null;

			SetNeedsDisplay();
		}
Esempio n. 11
0
 public static void UpdateThumbColor(this UISlider uiSlider, ISlider slider, UIColor?defaultThumbColor)
 {
     if (slider.ThumbColor == Color.Default)
     {
         uiSlider.ThumbTintColor = defaultThumbColor;
     }
     else
     {
         uiSlider.ThumbTintColor = slider.ThumbColor.ToNative();
     }
 }
Esempio n. 12
0
 public static void UpdateThumbColor(this UISlider uiSlider, ISlider slider, UIColor?defaultThumbColor)
 {
     if (slider.ThumbColor == null)
     {
         uiSlider.ThumbTintColor = defaultThumbColor;
     }
     else
     {
         uiSlider.ThumbTintColor = slider.ThumbColor.ToPlatform();
     }
 }
Esempio n. 13
0
 protected override void OnElementChanged(ElementChangedEventArgs <DrawingView> e)
 {
     base.OnElementChanged(e);
     if (Element != null)
     {
         BackgroundColor                  = Element.BackgroundColor.ToUIColor();
         currentPath.LineWidth            = Element.DefaultLineWidth;
         lineColor                        = Element.DefaultLineColor.ToUIColor();
         Element.Lines.CollectionChanged += OnLinesCollectionChanged;
     }
 }
        void SetupDefaults(UISearchBar nativeView)
        {
            _defaultTextColor = QueryEditor?.TextColor;

            var cancelButton = nativeView.FindDescendantView <UIButton>();

            if (cancelButton != null)
            {
                _cancelButtonTextColorDefaultNormal      = cancelButton.TitleColor(UIControlState.Normal);
                _cancelButtonTextColorDefaultHighlighted = cancelButton.TitleColor(UIControlState.Highlighted);
                _cancelButtonTextColorDefaultDisabled    = cancelButton.TitleColor(UIControlState.Disabled);
            }
        }
Esempio n. 15
0
 public static void UpdateTextColor(this UITextField textField, IEntry entry, UIColor?defaultTextColor)
 {
     if (entry.TextColor == Color.Default)
     {
         if (defaultTextColor != null)
         {
             textField.TextColor = defaultTextColor;
         }
     }
     else
     {
         textField.TextColor = entry.TextColor.ToNative();
     }
 }
Esempio n. 16
0
        public void SetBackground(SolidPaint solidPaint)
        {
            if (solidPaint.Color == null)
            {
                SetDefaultBackgroundColor();
            }
            else
            {
                _backgroundColor = solidPaint.Color.ToNative();
            }

            _background = null;

            SetNeedsDisplay();
        }
Esempio n. 17
0
        protected override MauiTextField CreateNativeView()
        {
            var nativeEntry = new MauiTextField
            {
                BorderStyle   = UITextBorderStyle.RoundedRect,
                ClipsToBounds = true
            };

            _defaultTextColor = nativeEntry.TextColor;

            // Placeholder default color is 70% gray
            // https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITextField_Class/index.html#//apple_ref/occ/instp/UITextField/placeholder
            _defaultPlaceholderColor = ColorExtensions.SeventyPercentGrey.ToColor();

            return(nativeEntry);
        }
Esempio n. 18
0
        public static bool ARGBEquivalent(UIColor?color1, UIColor?color2, double tolerance = Tolerance)
        {
            if (color1 == null && color2 == null)
            {
                return(true);
            }
            if (color1 == null || color2 == null)
            {
                return(false);
            }

            color1.GetRGBA(out nfloat red1, out nfloat green1, out nfloat blue1, out nfloat alpha1);
            color2.GetRGBA(out nfloat red2, out nfloat green2, out nfloat blue2, out nfloat alpha2);

            return(Equal(red1, red2, tolerance) &&
                   Equal(green1, green2, tolerance) &&
                   Equal(blue1, blue2, tolerance) &&
                   Equal(alpha1, alpha2, tolerance));
        }
Esempio n. 19
0
        public static void UpdateTrackColor(this UISwitch uiSwitch, ISwitch view, UIColor?defaultOnTrackColor, UIColor?defaultOffTrackColor)
        {
            if (view == null)
            {
                return;
            }

            if (view.TrackColor == Maui.Color.Default)
            {
                uiSwitch.OnTintColor = defaultOnTrackColor;
            }
            else
            {
                uiSwitch.OnTintColor = view.TrackColor.ToNative();
            }

            UIView uIView;

            if (NativeVersion.IsAtLeast(13))
            {
                uIView = uiSwitch.Subviews[0].Subviews[0];
            }
            else
            {
                uIView = uiSwitch.Subviews[0].Subviews[0].Subviews[0];
            }

            if (view.TrackColor == Maui.Color.Default)
            {
                uIView.BackgroundColor = defaultOffTrackColor;
            }
            else
            {
                uIView.BackgroundColor = uiSwitch.OnTintColor;
            }
        }
Esempio n. 20
0
        public static void UpdatePlaceholderColor(this MauiTextView textView, IEditor editor, UIColor?defaultPlaceholderColor)
        {
            Color placeholderColor = editor.PlaceholderColor;

            if (placeholderColor.IsDefault)
            {
                textView.PlaceholderTextColor = defaultPlaceholderColor;
            }
            else
            {
                textView.PlaceholderTextColor = placeholderColor.ToNative();
            }
        }
Esempio n. 21
0
        public static void UpdateTextColor(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIColor?defaultTextColor)
        {
            var textColor = datePicker.TextColor;

            if (textColor == null)
            {
                platformDatePicker.TextColor = defaultTextColor;
            }
            else
            {
                platformDatePicker.TextColor = textColor.ToPlatform();
            }

            // HACK This forces the color to update; there's probably a more elegant way to make this happen
            platformDatePicker.UpdateDate(datePicker);
        }
 void SetupDefaults(MauiTimePicker nativeView)
 {
     DefaultTextColor = nativeView.TextColor;
 }
Esempio n. 23
0
 public static void UpdateMaximumTrackColor(this UISlider uiSlider, ISlider slider, UIColor?defaultMaxTrackColor)
 {
     if (slider.MaximumTrackColor == Color.Default)
     {
         uiSlider.MaximumTrackTintColor = defaultMaxTrackColor;
     }
     else
     {
         uiSlider.MaximumTrackTintColor = slider.MaximumTrackColor.ToNative();
     }
 }
Esempio n. 24
0
        internal static void UpdateiOS15TabBarAppearance(
            this UITabBar tabBar,
            ref UITabBarAppearance _tabBarAppearance,
            UIColor?defaultBarColor,
            UIColor?defaultBarTextColor,
            Color?selectedTabColor,
            Color?unselectedTabColor,
            Color?barBackgroundColor,
            Color?barTextColor)
        {
            if (_tabBarAppearance == null)
            {
                _tabBarAppearance = new UITabBarAppearance();
                _tabBarAppearance.ConfigureWithDefaultBackground();
            }

            var effectiveBarColor = (barBackgroundColor == null) ? defaultBarColor : barBackgroundColor.ToPlatform();

            // Set BarBackgroundColor
            if (effectiveBarColor != null)
            {
                _tabBarAppearance.BackgroundColor = effectiveBarColor;
            }

            // Set BarTextColor

            var effectiveBarTextColor = (barTextColor == null) ? defaultBarTextColor : barTextColor.ToPlatform();

            if (effectiveBarTextColor != null)
            {
                _tabBarAppearance.StackedLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes
                {
                    ForegroundColor = effectiveBarTextColor
                };
            }

            // Update colors for all variations of the appearance to also make it work for iPads, etc. which use different layouts for the tabbar
            // Also, set ParagraphStyle explicitly. This seems to be an iOS bug. If we don't do this, tab titles will be truncat...

            // Set SelectedTabColor
            if (selectedTabColor != null)
            {
                var foregroundColor = selectedTabColor.ToPlatform();
                _tabBarAppearance.StackedLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.StackedLayoutAppearance.Selected.IconColor = foregroundColor;

                _tabBarAppearance.InlineLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.InlineLayoutAppearance.Selected.IconColor = foregroundColor;

                _tabBarAppearance.CompactInlineLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.CompactInlineLayoutAppearance.Selected.IconColor = foregroundColor;
            }
            else
            {
                var foregroundColor = UITabBar.Appearance.TintColor;
                _tabBarAppearance.StackedLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.StackedLayoutAppearance.Selected.IconColor = foregroundColor;

                _tabBarAppearance.InlineLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.InlineLayoutAppearance.Selected.IconColor = foregroundColor;

                _tabBarAppearance.CompactInlineLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.CompactInlineLayoutAppearance.Selected.IconColor = foregroundColor;
            }

            // Set UnselectedTabColor
            if (unselectedTabColor != null)
            {
                var foregroundColor = unselectedTabColor.ToPlatform();
                _tabBarAppearance.StackedLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.StackedLayoutAppearance.Normal.IconColor = foregroundColor;

                _tabBarAppearance.InlineLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.InlineLayoutAppearance.Normal.IconColor = foregroundColor;

                _tabBarAppearance.CompactInlineLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foregroundColor, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.CompactInlineLayoutAppearance.Normal.IconColor = foregroundColor;
            }
            else
            {
                var foreground = UITabBar.Appearance.TintColor;
                _tabBarAppearance.StackedLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foreground, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.StackedLayoutAppearance.Normal.IconColor = foreground;

                _tabBarAppearance.InlineLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foreground, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.InlineLayoutAppearance.Normal.IconColor = foreground;

                _tabBarAppearance.CompactInlineLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes {
                    ForegroundColor = foreground, ParagraphStyle = NSParagraphStyle.Default
                };
                _tabBarAppearance.CompactInlineLayoutAppearance.Normal.IconColor = foreground;
            }

            // Set the TabBarAppearance
            tabBar.StandardAppearance = tabBar.ScrollEdgeAppearance = _tabBarAppearance;
        }
Esempio n. 25
0
        public static void UpdateTextColor(this UIButton nativeButton, IButton button, UIColor?buttonTextColorDefaultNormal, UIColor?buttonTextColorDefaultHighlighted, UIColor?buttonTextColorDefaultDisabled)
        {
            if (button.TextColor == Color.Default)
            {
                nativeButton.SetTitleColor(buttonTextColorDefaultNormal, UIControlState.Normal);
                nativeButton.SetTitleColor(buttonTextColorDefaultHighlighted, UIControlState.Highlighted);
                nativeButton.SetTitleColor(buttonTextColorDefaultDisabled, UIControlState.Disabled);
            }
            else
            {
                var color = button.TextColor.ToNative();

                nativeButton.SetTitleColor(color, UIControlState.Normal);
                nativeButton.SetTitleColor(color, UIControlState.Highlighted);
                nativeButton.SetTitleColor(color, UIControlState.Disabled);

                nativeButton.TintColor = color;
            }
        }
Esempio n. 26
0
 protected override void SetupDefaults(UISwitch nativeView)
 {
     DefaultOnTrackColor  = UISwitch.Appearance.OnTintColor;
     DefaultOffTrackColor = nativeView.GetOffTrackColor();
     DefaultThumbColor    = UISwitch.Appearance.ThumbTintColor;
 }
Esempio n. 27
0
 protected override void SetupDefaults(UISlider nativeView)
 {
     DefaultMinTrackColor = nativeView.MinimumTrackTintColor;
     DefaultMaxTrackColor = nativeView.MaximumTrackTintColor;
     DefaultThumbColor    = nativeView.ThumbTintColor;
 }
Esempio n. 28
0
 public bool Equals(UIColor?x, UIColor?y) => ARGBEquivalent(x, y);
Esempio n. 29
0
        public static void UpdateTextColor(this UILabel nativeLabel, ITextStyle textStyle, UIColor?defaultColor = null)
        {
            // Default value of color documented to be black in iOS docs
            var textColor = textStyle.TextColor;

            nativeLabel.TextColor = textColor.ToNative(defaultColor ?? ColorExtensions.LabelColor);
        }
Esempio n. 30
0
 protected override void SetupDefaults(MauiTextField nativeView)
 {
     DefaultTextColor = nativeView.TextColor;
 }