Repository navigation
Expand file tree
/
Copy pathprogress.ios.ts
More file actions
82 lines (65 loc) · 2.78 KB
/
Copy pathprogress.ios.ts
File metadata and controls
82 lines (65 loc) · 2.78 KB
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
import common = require("./progress-common");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
import style = require("ui/styling/style");
import view = require("ui/core/view");
function onValuePropertyChanged(data: dependencyObservable.PropertyChangeData) {
var progress = <Progress>data.object;
progress.ios.progress = data.newValue / progress.maxValue;
}
function onMaxValuePropertyChanged(data: dependencyObservable.PropertyChangeData) {
var progress = <Progress>data.object;
progress.ios.progress = progress.value / data.newValue;
}
// register the setNativeValue callbacks
(<proxy.PropertyMetadata>common.Progress.valueProperty.metadata).onSetNativeValue = onValuePropertyChanged;
(<proxy.PropertyMetadata>common.Progress.maxValueProperty.metadata).onSetNativeValue = onMaxValuePropertyChanged;
global.moduleMerge(common, exports);
export class Progress extends common.Progress {
private _ios: UIProgressView;
constructor() {
super();
this._ios = new UIProgressView();
}
get ios(): UIProgressView {
return this._ios;
}
}
export class ProgressStyler implements style.Styler {
//Text color methods
private static setColorProperty(view: view.View, newValue: any) {
var bar = <UIProgressView>view.ios;
bar.progressTintColor = newValue;
}
private static resetColorProperty(view: view.View, nativeValue: any) {
var bar = <UIProgressView>view.ios;
bar.progressTintColor = nativeValue;
}
private static getNativeColorValue(view: view.View): any {
var bar = <UIProgressView>view.ios;
return bar.progressTintColor;
}
private static setBackgroundColorProperty(view: view.View, newValue: any) {
var bar = <UIProgressView>view.ios;
bar.trackTintColor = newValue;
}
private static resetBackgroundColorProperty(view: view.View, nativeValue: any) {
var bar = <UIProgressView>view.ios;
bar.trackTintColor = nativeValue;
}
private static getBackgroundColorProperty(view: view.View): any {
var bar = <UIProgressView>view.ios;
return bar.trackTintColor;
}
public static registerHandlers() {
style.registerHandler(style.colorProperty, new style.StylePropertyChangedHandler(
ProgressStyler.setColorProperty,
ProgressStyler.resetColorProperty,
ProgressStyler.getNativeColorValue), "Progress");
style.registerHandler(style.backgroundColorProperty, new style.StylePropertyChangedHandler(
ProgressStyler.setBackgroundColorProperty,
ProgressStyler.resetBackgroundColorProperty,
ProgressStyler.getBackgroundColorProperty), "Progress");
}
}
ProgressStyler.registerHandlers();