mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
definitions fixed
This commit is contained in:
2
ui/progress/package.json
Normal file
2
ui/progress/package.json
Normal file
@@ -0,0 +1,2 @@
|
||||
{ "name" : "progress",
|
||||
"main" : "progress.js" }
|
||||
45
ui/progress/progress-common.ts
Normal file
45
ui/progress/progress-common.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
41
ui/progress/progress.android.ts
Normal file
41
ui/progress/progress.android.ts
Normal 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
42
ui/progress/progress.d.ts
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
35
ui/progress/progress.ios.ts
Normal file
35
ui/progress/progress.ios.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user