summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-04-19 07:01:58 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-04-19 07:01:58 (GMT)
commita98f3fb2aae3c5b6a3fa5140e51f51ec67843a49 (patch)
tree654fa47cbd3cc889061466939630dcd5133cc837 /Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
parent89a50d4bc1f4aaf83d5f92a28c2a7a96282cc0d3 (diff)
downloadxamarin-forms-a98f3fb2aae3c5b6a3fa5140e51f51ec67843a49.zip
xamarin-forms-a98f3fb2aae3c5b6a3fa5140e51f51ec67843a49.tar.gz
xamarin-forms-a98f3fb2aae3c5b6a3fa5140e51f51ec67843a49.tar.bz2
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/TimePickerRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
index cfa676d..010eda7 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Android.App;
+using Android.Content.Res;
using Android.Widget;
using ADatePicker = Android.Widget.DatePicker;
using ATimePicker = Android.Widget.TimePicker;
@@ -11,6 +12,7 @@ namespace Xamarin.Forms.Platform.Android
public class TimePickerRenderer : ViewRenderer<TimePicker, EditText>, TimePickerDialog.IOnTimeSetListener
{
AlertDialog _dialog;
+ TextColorSwitcher _textColorSwitcher;
public TimePickerRenderer()
{
@@ -36,17 +38,23 @@ namespace Xamarin.Forms.Platform.Android
textField.SetOnClickListener(TimePickerListener.Instance);
SetNativeControl(textField);
+ _textColorSwitcher = new TextColorSwitcher(textField.TextColors);
}
SetTime(e.NewElement.Time);
+ UpdateTextColor();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
- if (e.PropertyName == TimePicker.TimeProperty.PropertyName || e.PropertyName == TimePicker.FormatProperty.PropertyName)
+ if (e.PropertyName == TimePicker.TimeProperty.PropertyName ||
+ e.PropertyName == TimePicker.FormatProperty.PropertyName)
SetTime(Element.Time);
+
+ if (e.PropertyName == TimePicker.TextColorProperty.PropertyName)
+ UpdateTextColor();
}
internal override void OnFocusChangeRequested(object sender, VisualElement.FocusRequestArgs e)
@@ -78,6 +86,11 @@ namespace Xamarin.Forms.Platform.Android
Control.Text = DateTime.Today.Add(time).ToString(Element.Format);
}
+ void UpdateTextColor()
+ {
+ _textColorSwitcher?.UpdateTextColor(Control, Element.TextColor);
+ }
+
class TimePickerListener : Object, IOnClickListener
{
public static readonly TimePickerListener Instance = new TimePickerListener();