blob: 3709172026c737484fd023679abc88c6ce3da0bb (
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
58
59
60
61
62
63
64
65
66
67
|
using System.Drawing;
using System.ComponentModel;
#if __UNIFIED__
using UIKit;
#else
using MonoTouch.UIKit;
#endif
#if __UNIFIED__
using RectangleF = CoreGraphics.CGRect;
using SizeF = CoreGraphics.CGSize;
using PointF = CoreGraphics.CGPoint;
#else
using nfloat=System.Single;
using nint=System.Int32;
using nuint=System.UInt32;
#endif
namespace Xamarin.Forms.Platform.iOS
{
public class ProgressBarRenderer : ViewRenderer<ProgressBar, UIProgressView>
{
public override SizeF SizeThatFits(SizeF size)
{
// progress bar will size itself to be as wide as the request, even if its inifinite
// we want the minimum need size
var result = base.SizeThatFits(size);
return new SizeF(10, result.Height);
}
protected override void OnElementChanged(ElementChangedEventArgs<ProgressBar> e)
{
if (e.NewElement != null)
{
if (Control == null)
SetNativeControl(new UIProgressView(UIProgressViewStyle.Default));
UpdateProgress();
}
base.OnElementChanged(e);
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == ProgressBar.ProgressProperty.PropertyName)
UpdateProgress();
}
protected override void SetBackgroundColor(Color color)
{
base.SetBackgroundColor(color);
if (Control == null)
return;
Control.TrackTintColor = color != Color.Default ? color.ToUIColor() : null;
}
void UpdateProgress()
{
Control.Progress = (float)Element.Progress;
}
}
}
|