blob: abd8f24ffdcdcf62635fcadfc1b1ea77a6251fe1 (
plain)
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
|
using System.ComponentModel;
using System.Drawing;
using UIKit;
namespace Xamarin.Forms.Platform.iOS
{
public class ActivityIndicatorRenderer : ViewRenderer<ActivityIndicator, UIActivityIndicatorView>
{
protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
{
if (e.NewElement != null)
{
if (Control == null)
{
SetNativeControl(new UIActivityIndicatorView(RectangleF.Empty) { ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray });
}
UpdateColor();
UpdateIsRunning();
}
base.OnElementChanged(e);
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == ActivityIndicator.ColorProperty.PropertyName)
UpdateColor();
else if (e.PropertyName == ActivityIndicator.IsRunningProperty.PropertyName)
UpdateIsRunning();
}
void UpdateColor()
{
Control.Color = Element.Color == Color.Default ? null : Element.Color.ToUIColor();
}
void UpdateIsRunning()
{
if (Element.IsRunning)
Control.StartAnimating();
else
Control.StopAnimating();
}
}
}
|