summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-04-19 01:01:58 -0600
committerJason Smith <jason.smith@xamarin.com>2016-04-19 00:01:58 -0700
commita98f3fb2aae3c5b6a3fa5140e51f51ec67843a49 (patch)
tree654fa47cbd3cc889061466939630dcd5133cc837 /Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
parent89a50d4bc1f4aaf83d5f92a28c2a7a96282cc0d3 (diff)
downloadxamarin-forms-a98f3fb2aae3c5b6a3fa5140e51f51ec67843a49.tar.gz
xamarin-forms-a98f3fb2aae3c5b6a3fa5140e51f51ec67843a49.tar.bz2
xamarin-forms-a98f3fb2aae3c5b6a3fa5140e51f51ec67843a49.zip
Add TextColor Property to Picker, TimePicker, DatePicker (#84)
* Add TextColor property to TimePicker Add TextColor page to TimePicker gallery Add TimePicker color toggling to color toggle test page Split color toggle tests up among tabs * Implement TimePicker.TextColor in iOS * Implement TimePicker.TextColor for WinRT tablet * Add IsEnabled=false tests to DefaultColorToggleTest Button and TimePicker Consolidate ColorStates array Fix IsEnabled changing color bug on iOS * Implement TimePicker.TextColor for WP8 * Add TextColor property to DatePicker Add DatePicker section to DefaultColorToggleTest Impement DatePicker.TextColor for WP8 * Implement DatePicker.TextColor for WinRT/UWP/Windows Phone 8.1 * Implement DatePicker.TextColor for iOS * Add TextColor to DatePicker Gallery Page * Implement DatePicker.TextColor for Android * Add Picker Gallery page for TextColor Implement Picker.TextColor on Android Consolidate TextColor management for Button, Picker, DatePicker, TimePicker Implement * Add untracked TextColorSwitcher Implement Picker.TextColor in iOS * Implement Picker.TextColor in WinRT/UWP/Windows Phone 8.1 Remove Pioker Loaded handlers in Dispose * Implement Picker.TextColor in WP8 * Removed unused field Update ignored warnings * Update docs * Use nameof() for BindableProperties * Cleanup * Fix custom renderer crashes for classes using TextColorSwitcher * Correct property name references * Fix typo and 'if' formatting * Add missing else
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs21
1 files changed, 3 insertions, 18 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
index 43f042b1..7247361a 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
@@ -13,7 +13,7 @@ namespace Xamarin.Forms.Platform.Android
public class ButtonRenderer : ViewRenderer<Button, AButton>, AView.IOnAttachStateChangeListener
{
ButtonDrawable _backgroundDrawable;
- ColorStateList _buttonDefaulTextColors;
+ TextColorSwitcher _textColorSwitcher;
Drawable _defaultDrawable;
float _defaultFontSize;
Typeface _defaultTypeface;
@@ -78,7 +78,7 @@ namespace Xamarin.Forms.Platform.Android
button.SetOnClickListener(ButtonClickListener.Instance.Value);
button.Tag = this;
SetNativeControl(button);
-
+ _textColorSwitcher = new TextColorSwitcher(button.TextColors);
button.AddOnAttachStateChangeListener(this);
}
}
@@ -255,22 +255,7 @@ namespace Xamarin.Forms.Platform.Android
void UpdateTextColor()
{
- Color color = Element.TextColor;
-
- if (color.IsDefault)
- {
- if (_buttonDefaulTextColors == null)
- return;
-
- NativeButton.SetTextColor(_buttonDefaulTextColors);
- }
- else
- {
- _buttonDefaulTextColors = _buttonDefaulTextColors ?? Control.TextColors;
-
- // Set the new enabled state color, preserving the default disabled state color
- NativeButton.SetTextColor(color.ToAndroidPreserveDisabled(_buttonDefaulTextColors));
- }
+ _textColorSwitcher?.UpdateTextColor(Control, Element.TextColor);
}
class ButtonClickListener : Object, IOnClickListener