definitions fixed

This commit is contained in:
Erjan Gavalji
2015-03-03 10:34:40 +02:00
parent a03ce4ca1d
commit cc829e0152
705 changed files with 321431 additions and 148812 deletions

2
ui/progress/package.json Normal file
View File

@@ -0,0 +1,2 @@
{ "name" : "progress",
"main" : "progress.js" }

View File

@@ -0,0 +1,45 @@
import definition = require("ui/progress");
import view = require("ui/core/view");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
export class Progress extends view.View implements definition.Progress {
public static valueProperty = new dependencyObservable.Property(
"value",
"Progress",
new proxy.PropertyMetadata(0, dependencyObservable.PropertyMetadataSettings.AffectsLayout)
);
public static maxValueProperty = new dependencyObservable.Property(
"maxValue",
"Progress",
new proxy.PropertyMetadata(100, dependencyObservable.PropertyMetadataSettings.AffectsLayout)
);
constructor() {
super();
this.maxValue = 100;
this.value = 0;
}
get maxValue(): number {
return this._getValue(Progress.maxValueProperty);
}
set maxValue(newMaxValue: number) {
this._setValue(Progress.maxValueProperty, newMaxValue);
// Adjust value if needed.
if (this.value > newMaxValue) {
this.value = newMaxValue;
}
}
get value(): number {
return this._getValue(Progress.valueProperty);
}
set value(value: number) {
value = Math.min(value, this.maxValue);
this._setValue(Progress.valueProperty, value);
}
}

View File

@@ -0,0 +1,41 @@
import common = require("ui/progress/progress-common");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
function onValuePropertyChanged(data: dependencyObservable.PropertyChangeData) {
var progress = <Progress>data.object;
if (!progress.android) {
return;
}
progress.android.setProgress(data.newValue);
}
function onMaxValuePropertyChanged(data: dependencyObservable.PropertyChangeData) {
var progress = <Progress>data.object;
if (!progress.android) {
return;
}
progress.android.setMax(data.newValue);
}
// register the setNativeValue callbacks
(<proxy.PropertyMetadata>common.Progress.valueProperty.metadata).onSetNativeValue = onValuePropertyChanged;
(<proxy.PropertyMetadata>common.Progress.maxValueProperty.metadata).onSetNativeValue = onMaxValuePropertyChanged;
// merge the exports of the common file with the exports of this file
declare var exports;
require("utils/module-merge").merge(common, exports);
export class Progress extends common.Progress {
private _android: android.widget.ProgressBar;
public _createUI() {
this._android = new android.widget.ProgressBar(this._context, null, (<any>android).R.attr.progressBarStyleHorizontal);
}
get android(): android.widget.ProgressBar {
return this._android;
}
}

42
ui/progress/progress.d.ts vendored Normal file
View File

@@ -0,0 +1,42 @@
/**
* Contains the Progress class, which represents a component capable of showing progress.
*/
declare module "ui/progress" {
import view = require("ui/core/view");
import dependencyObservable = require("ui/core/dependency-observable");
/**
* Represents a progress component.
*/
export class Progress extends view.View {
/**
* Represents the observable property backing the value property of each Progress instance.
*/
public static valueProperty: dependencyObservable.Property;
/**
* Represents the observable property backing the maxValue property of each Progress instance.
*/
public static maxValueProperty: dependencyObservable.Property;
/**
* Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS.
*/
android: android.widget.ProgressBar;
/**
* Gets the native iOS [UIProgressView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIProgressView_Class/) that represents the user interface for this component. Valid only when running on iOS.
*/
ios: UIProgressView;
/**
* Gets or sets a progress current value.
*/
value: number;
/**
* Gets or sets a progress max value.
*/
maxValue: number;
}
}

View File

@@ -0,0 +1,35 @@
import common = require("ui/progress/progress-common");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
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;
// merge the exports of the common file with the exports of this file
declare var exports;
require("utils/module-merge").merge(common, exports);
export class Progress extends common.Progress {
private _ios: UIProgressView;
constructor() {
super();
this._ios = new UIProgressView();
}
get ios(): UIProgressView {
return this._ios;
}
}