This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
MaterialFormsEditTextBase.cs
59 lines (51 loc) · 1.74 KB
/
MaterialFormsEditTextBase.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
using System;
using Android.Content;
using Android.Graphics;
using Android.Views;
#if __ANDROID_29__
using Google.Android.Material.TextField;
#else
using Android.Support.Design.Widget;
#endif
using Android.Runtime;
using Android.Util;
using Xamarin.Forms.Platform.Android;
using ARect = Android.Graphics.Rect;
namespace Xamarin.Forms.Material.Android
{
public class MaterialFormsEditTextBase : TextInputEditText, IDescendantFocusToggler
{
DescendantFocusToggler _descendantFocusToggler;
public MaterialFormsEditTextBase(Context context) : base(context)
{
MaterialFormsEditTextManager.Init(this);
}
protected MaterialFormsEditTextBase(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
MaterialFormsEditTextManager.Init(this);
}
public MaterialFormsEditTextBase(Context context, IAttributeSet attrs) : base(context, attrs)
{
MaterialFormsEditTextManager.Init(this);
}
public MaterialFormsEditTextBase(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
{
MaterialFormsEditTextManager.Init(this);
}
protected override void Dispose(bool disposing)
{
if (disposing)
MaterialFormsEditTextManager.Dispose(this);
base.Dispose(disposing);
}
bool IDescendantFocusToggler.RequestFocus(global::Android.Views.View control, Func<bool> baseRequestFocus)
{
_descendantFocusToggler = _descendantFocusToggler ?? new DescendantFocusToggler();
return _descendantFocusToggler.RequestFocus(this, baseRequestFocus);
}
public override bool RequestFocus(FocusSearchDirection direction, ARect previouslyFocusedRect)
{
return (this as IDescendantFocusToggler).RequestFocus(this, () => base.RequestFocus(direction, previouslyFocusedRect));
}
}
}