summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
blob: 04a69c6a89bb57997a0baf117be0a4e8f50e78b4 (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
49
50
51
52
53
54
55
56
57
using EProgressBar = ElmSharp.ProgressBar;
using EColor = ElmSharp.Color;

namespace Xamarin.Forms.Platform.Tizen
{
	public class ActivityIndicatorRenderer : ViewRenderer<ActivityIndicator, EProgressBar>
	{
		static readonly EColor s_defaultColor = EColor.Black;

		public ActivityIndicatorRenderer()
		{
			RegisterPropertyHandler(ActivityIndicator.ColorProperty, UpdateColor);
			RegisterPropertyHandler(ActivityIndicator.IsRunningProperty, UpdateIsRunning);
		}

		protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
		{
			if (Control == null)
			{
				var ac = new EProgressBar(Forms.Context.MainWindow)
				{
					Style = "process_medium",
					IsPulseMode = true,
				};
				SetNativeControl(ac);
			}

			if (e.OldElement != null)
			{
			}

			if (e.NewElement != null)
			{
			}

			base.OnElementChanged(e);
		}

		void UpdateColor()
		{
			Control.Color = (Element.Color == Color.Default) ? s_defaultColor : Element.Color.ToNative();
		}

		void UpdateIsRunning()
		{
			if (Element.IsRunning)
			{
				Control.PlayPulse();
			}
			else
			{
				Control.StopPulse();
			}
		}

	};
}