From d8ee0714da984c040235af0a4d4c0a23e8512944 Mon Sep 17 00:00:00 2001 From: roubachof Date: Fri, 5 Feb 2021 16:43:04 +0100 Subject: [PATCH] Stopped using Triggers for color updates --- Tabs/Tabs/BottomTabItem.xaml | 66 ++++++++++++----------------- Tabs/Tabs/BottomTabItem.xaml.cs | 16 +++++++ Tabs/Tabs/UnderlinedTabItem.xaml | 54 +++++++++++------------ Tabs/Tabs/UnderlinedTabItem.xaml.cs | 12 ++++++ 4 files changed, 78 insertions(+), 70 deletions(-) diff --git a/Tabs/Tabs/BottomTabItem.xaml b/Tabs/Tabs/BottomTabItem.xaml index 3f5ebcf..7fa999c 100644 --- a/Tabs/Tabs/BottomTabItem.xaml +++ b/Tabs/Tabs/BottomTabItem.xaml @@ -1,11 +1,12 @@  - + @@ -23,47 +24,32 @@ - + - - - - - - - + - + \ No newline at end of file diff --git a/Tabs/Tabs/BottomTabItem.xaml.cs b/Tabs/Tabs/BottomTabItem.xaml.cs index 94234cf..a6aadbf 100644 --- a/Tabs/Tabs/BottomTabItem.xaml.cs +++ b/Tabs/Tabs/BottomTabItem.xaml.cs @@ -1,5 +1,7 @@ using System.Runtime.CompilerServices; +using Sharpnado.Tabs.Effects; + using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -41,6 +43,7 @@ public BottomTabItem() LabelSize = 12; UpdateTextVisibility(); + UpdateColors(); } [TypeConverter(typeof(ImageSourceConverter))] @@ -82,6 +85,13 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName case nameof(IsTextVisible): UpdateTextVisibility(); break; + + case nameof(UnselectedLabelColor): + case nameof(UnselectedIconColor): + case nameof(SelectedTabColor): + case nameof(IsSelected): + UpdateColors(); + break; } } @@ -110,5 +120,11 @@ private void UpdateTextVisibility() Icon.VerticalOptions = LayoutOptions.Center; } } + + private void UpdateColors() + { + IconText.TextColor = IsSelected ? SelectedTabColor : UnselectedLabelColor; + ImageEffect.SetTintColor(Icon, IsSelected ? SelectedTabColor : UnselectedIconColor); + } } } \ No newline at end of file diff --git a/Tabs/Tabs/UnderlinedTabItem.xaml b/Tabs/Tabs/UnderlinedTabItem.xaml index eae94d4..40875db 100644 --- a/Tabs/Tabs/UnderlinedTabItem.xaml +++ b/Tabs/Tabs/UnderlinedTabItem.xaml @@ -1,10 +1,11 @@  - + @@ -26,36 +27,29 @@ - + - - + - + \ No newline at end of file diff --git a/Tabs/Tabs/UnderlinedTabItem.xaml.cs b/Tabs/Tabs/UnderlinedTabItem.xaml.cs index 774b54d..ca536b7 100644 --- a/Tabs/Tabs/UnderlinedTabItem.xaml.cs +++ b/Tabs/Tabs/UnderlinedTabItem.xaml.cs @@ -58,6 +58,12 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName case nameof(UnderlineAllTab): UpdateUnderlineAllTab(); break; + + case nameof(UnselectedLabelColor): + case nameof(SelectedTabColor): + case nameof(IsSelected): + UpdateColors(); + break; } } @@ -100,5 +106,11 @@ private void UpdateMargin() ? new Thickness(Underline.Margin.Left - Margin.Left, 0, Underline.Margin.Right - Margin.Right, 0) : new Thickness(0); } + + private void UpdateColors() + { + InnerLabel.TextColor = IsSelected ? SelectedTabColor : UnselectedLabelColor; + Underline.Color = SelectedTabColor; + } } } \ No newline at end of file