Files
Hristo Hristov 1d49f5f3c3 fix padding on text-view & text-field (#3758)
* fix padding on text-view & text-field
text-base is now snapshotable
view.android is now snapshotable

* createNativeView returns the nativeView for android
Fix image tests
Implement test for image loaded from res://
EffectivePaddings updated when nativeView have some from its native theme
2017-03-09 16:09:53 +02:00

83 lines
2.5 KiB
TypeScript

import {
Color, ProgressBase, valueProperty, maxValueProperty,
colorProperty, backgroundColorProperty, backgroundInternalProperty
} from "./progress-common";
export * from "./progress-common";
const R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL = 0x01010078;
export class Progress extends ProgressBase {
private _android: android.widget.ProgressBar;
public _createNativeView() {
const progressBar = this._android = new android.widget.ProgressBar(this._context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
return progressBar;
}
get android(): android.widget.ProgressBar {
return this._android;
}
get nativeView(): android.widget.ProgressBar {
return this._android;
}
get [valueProperty.native](): number {
return 0;
}
set [valueProperty.native](value: number) {
this._android.setProgress(value);
}
get [maxValueProperty.native](): number {
return 100;
}
set [maxValueProperty.native](value: number) {
this._android.setMax(value);
}
get [colorProperty.native](): android.graphics.drawable.Drawable {
return null;
}
set [colorProperty.native](value: Color) {
let progressDrawable = this._android.getProgressDrawable();
if (!progressDrawable) {
return;
}
if (value instanceof Color) {
progressDrawable.setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
} else {
progressDrawable.clearColorFilter();
}
}
get [backgroundColorProperty.native](): number {
return null;
}
set [backgroundColorProperty.native](value: Color) {
let progressDrawable = this._android.getProgressDrawable();
if (!progressDrawable) {
return;
}
if (progressDrawable instanceof android.graphics.drawable.LayerDrawable && progressDrawable.getNumberOfLayers() > 0) {
let backgroundDrawable = progressDrawable.getDrawable(0);
if (backgroundDrawable) {
if (value instanceof Color) {
backgroundDrawable.setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
} else {
backgroundDrawable.clearColorFilter();
}
}
}
}
get [backgroundInternalProperty.native](): number {
return null;
}
set [backgroundInternalProperty.native](value: Color) {
//
}
}