forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterialTimePickerRenderer.cs
60 lines (47 loc) · 1.7 KB
/
MaterialTimePickerRenderer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#if __ANDROID_28__
using Android.Content;
using Android.Views;
using Android.Widget;
using Xamarin.Forms;
using Xamarin.Forms.Material.Android;
using Xamarin.Forms.Platform.Android;
using AView = Android.Views.View;
namespace Xamarin.Forms.Material.Android
{
public class MaterialTimePickerRenderer : TimePickerRendererBase<MaterialPickerTextInputLayout>
{
MaterialPickerTextInputLayout _textInputLayout;
MaterialPickerEditText _textInputEditText;
public MaterialTimePickerRenderer(Context context) : base(MaterialContextThemeWrapper.Create(context))
{
}
protected override EditText EditText => _textInputEditText;
protected override AView ControlUsedForAutomation => EditText;
protected override MaterialPickerTextInputLayout CreateNativeControl()
{
LayoutInflater inflater = LayoutInflater.FromContext(Context);
var view = inflater.Inflate(Resource.Layout.MaterialPickerTextInput, null);
_textInputLayout = (MaterialPickerTextInputLayout)view;
_textInputEditText = _textInputLayout.FindViewById<MaterialPickerEditText>(Resource.Id.materialformsedittext);
return _textInputLayout;
}
protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
{
base.OnElementChanged(e);
_textInputLayout.SetHint(string.Empty, Element);
UpdateBackgroundColor();
}
protected override void UpdateBackgroundColor()
{
if (_textInputLayout == null)
return;
_textInputLayout.BoxBackgroundColor = MaterialColors.CreateEntryFilledInputBackgroundColor(Element.BackgroundColor, Element.TextColor);
}
protected override void UpdateTextColor() => ApplyTheme();
void ApplyTheme()
{
_textInputLayout?.ApplyTheme(Element.TextColor, Color.Default);
}
}
}
#endif