From 2d91a893f761ecedeea4701e85e81a3b17758116 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 26 Jun 2019 10:20:42 -0400 Subject: [PATCH] fix cursor color to renderers --- src/iOS.Core/Utilities/ThemeHelpers.cs | 6 ------ src/iOS/Renderers/CustomEditorRenderer.cs | 16 ++++++++++++++++ src/iOS/Renderers/CustomEntryRenderer.cs | 10 ++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/iOS.Core/Utilities/ThemeHelpers.cs b/src/iOS.Core/Utilities/ThemeHelpers.cs index 06bf7f021..dd75bf6fe 100644 --- a/src/iOS.Core/Utilities/ThemeHelpers.cs +++ b/src/iOS.Core/Utilities/ThemeHelpers.cs @@ -9,20 +9,16 @@ namespace Bit.iOS.Core.Utilities { var lightTheme = false; var mutedColor = Xamarin.Forms.Color.FromHex("#777777").ToUIColor(); - var textColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor(); if(theme == "dark") { - textColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor(); mutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); } else if(theme == "black") { - textColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor(); mutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); } else if(theme == "nord") { - textColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor(); mutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor(); } else @@ -30,8 +26,6 @@ namespace Bit.iOS.Core.Utilities lightTheme = true; } - UITextField.Appearance.TintColor = textColor; - UITextView.Appearance.TintColor = textColor; UIStepper.Appearance.TintColor = mutedColor; if(!lightTheme) { diff --git a/src/iOS/Renderers/CustomEditorRenderer.cs b/src/iOS/Renderers/CustomEditorRenderer.cs index ba275cff0..89aaac734 100644 --- a/src/iOS/Renderers/CustomEditorRenderer.cs +++ b/src/iOS/Renderers/CustomEditorRenderer.cs @@ -1,4 +1,5 @@ using Bit.iOS.Renderers; +using System.ComponentModel; using UIKit; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; @@ -18,7 +19,22 @@ namespace Bit.iOS.Renderers // Remove padding Control.TextContainerInset = new UIEdgeInsets(0, 0, 0, 0); Control.TextContainer.LineFragmentPadding = 0; + UpdateTintColor(); } } + + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + base.OnElementPropertyChanged(sender, e); + if(e.PropertyName == Editor.TextColorProperty.PropertyName) + { + UpdateTintColor(); + } + } + + private void UpdateTintColor() + { + Control.TintColor = Element.TextColor.ToUIColor(); + } } } diff --git a/src/iOS/Renderers/CustomEntryRenderer.cs b/src/iOS/Renderers/CustomEntryRenderer.cs index 88bc15ffc..06b49610f 100644 --- a/src/iOS/Renderers/CustomEntryRenderer.cs +++ b/src/iOS/Renderers/CustomEntryRenderer.cs @@ -16,6 +16,7 @@ namespace Bit.iOS.Renderers if(Control != null && e.NewElement is Entry) { Control.ClearButtonMode = UITextFieldViewMode.WhileEditing; + UpdateTintColor(); UpdateFontSize(); iOSHelpers.SetBottomBorder(Control); } @@ -30,6 +31,10 @@ namespace Bit.iOS.Renderers { UpdateFontSize(); } + else if(e.PropertyName == Entry.TextColorProperty.PropertyName) + { + UpdateTintColor(); + } } private void UpdateFontSize() @@ -47,5 +52,10 @@ namespace Bit.iOS.Renderers } } } + + private void UpdateTintColor() + { + Control.TintColor = Element.TextColor.ToUIColor(); + } } }