This repository was 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
/
Copy pathViewRenderer.cs
87 lines (69 loc) · 1.78 KB
/
ViewRenderer.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using NativeView = Gtk.Widget;
namespace Xamarin.Forms.Platform.GTK
{
public abstract class ViewRenderer : ViewRenderer<View, NativeView>
{
}
public abstract class ViewRenderer<TView, TNativeView> : VisualElementRenderer<TView, TNativeView>
where TView : View where TNativeView : NativeView
{
private string _defaultAccessibilityLabel;
private string _defaultAccessibilityHint;
protected override void Dispose(bool disposing)
{
if (Control != null)
{
Control.Destroy();
Control = null;
}
base.Dispose(disposing);
}
protected override void OnElementChanged(ElementChangedEventArgs<TView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
UpdateBackgroundColor();
}
}
protected override void SetNativeControl(TNativeView view)
{
base.SetNativeControl(view);
Add(view);
}
protected override void SetAccessibilityHint()
{
if (Control == null)
{
base.SetAccessibilityHint();
return;
}
if (Element == null)
return;
if (_defaultAccessibilityHint == null)
_defaultAccessibilityHint = Control.Accessible.Name;
var helpText = (string)Element.GetValue(AutomationProperties.HelpTextProperty) ?? _defaultAccessibilityHint;
if (!string.IsNullOrEmpty(helpText))
{
Control.Accessible.Name = helpText;
}
}
protected override void SetAccessibilityLabel()
{
if (Control == null)
{
base.SetAccessibilityLabel();
return;
}
if (Element == null)
return;
if (_defaultAccessibilityLabel == null)
_defaultAccessibilityLabel = Control.Accessible.Description;
var name = (string)Element.GetValue(AutomationProperties.NameProperty) ?? _defaultAccessibilityLabel;
if (!string.IsNullOrEmpty(name))
{
Control.Accessible.Description = name;
}
}
}
}