@nativescript/core
Version:
A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.
65 lines • 2.32 kB
JavaScript
import { ProgressBase, valueProperty, maxValueProperty } from './progress-common';
import { Color } from '../../color';
import { colorProperty, backgroundColorProperty, backgroundInternalProperty } from '../styling/style-properties';
import { AndroidHelper } from '../core/view';
export * from './progress-common';
const R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL = 0x01010078;
export class Progress extends ProgressBase {
createNativeView() {
return new android.widget.ProgressBar(this._context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
}
[valueProperty.getDefault]() {
return 0;
}
[valueProperty.setNative](value) {
this.nativeViewProtected.setProgress(value);
}
[maxValueProperty.getDefault]() {
return 100;
}
[maxValueProperty.setNative](value) {
this.nativeViewProtected.setMax(value);
}
[colorProperty.getDefault]() {
return null;
}
[colorProperty.setNative](value) {
const progressDrawable = this.nativeViewProtected.getProgressDrawable();
if (!progressDrawable) {
return;
}
if (value instanceof Color) {
AndroidHelper.setDrawableColor(value.android, progressDrawable);
}
else {
AndroidHelper.clearDrawableColor(progressDrawable);
}
}
[backgroundColorProperty.getDefault]() {
return null;
}
[backgroundColorProperty.setNative](value) {
const progressDrawable = this.nativeViewProtected.getProgressDrawable();
if (!progressDrawable) {
return;
}
if (progressDrawable instanceof android.graphics.drawable.LayerDrawable && progressDrawable.getNumberOfLayers() > 0) {
const backgroundDrawable = progressDrawable.getDrawable(0);
if (backgroundDrawable) {
if (value instanceof Color) {
AndroidHelper.setDrawableColor(value.android, backgroundDrawable);
}
else {
AndroidHelper.clearDrawableColor(backgroundDrawable);
}
}
}
}
[backgroundInternalProperty.getDefault]() {
return null;
}
[backgroundInternalProperty.setNative](value) {
//
}
}
//# sourceMappingURL=index.android.js.map