mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00

We want webpack's uglification to mangle function and class names but that's what the current implementation of the CSS in {N} relys on to get the CSS type for each view when targeted by CSS type selectors. The implementation is changed a little so now the CSS type can be set directly on the prototype of each View class or for TS, through decorator. BREAKING CHANGES: Extending classes requires marking the derived class with @CSSType The root classes are not marked with CSSType and classes derived from ViewBase and View will continue to work as expected. More concrete view classes (Button, Label, etc.) are marked with @CSSType now and store their cssType on the prototype suppressing the previous implementation that looked up the class function name. So clien classes that derive from one of our @CSSType decorated classes will now have to be marked with @CSSType.
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { Progress as ProgressDefinition } from ".";
|
|
import { View, Property, CoercibleProperty, CSSType } from "../core/view";
|
|
|
|
export * from "../core/view";
|
|
|
|
@CSSType("Progress")
|
|
export class ProgressBase extends View implements ProgressDefinition {
|
|
public value: number;
|
|
public maxValue: number;
|
|
// 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);
|
|
// }
|
|
}
|
|
|
|
ProgressBase.prototype.recycleNativeView = "auto";
|
|
|
|
/**
|
|
* Represents the observable property backing the value property of each Progress instance.
|
|
*/
|
|
export const valueProperty = new CoercibleProperty<ProgressBase, number>({
|
|
name: "value",
|
|
defaultValue: 0,
|
|
coerceValue: (t, v) => {
|
|
return v < 0 ? 0 : Math.min(v, t.maxValue)
|
|
},
|
|
valueConverter: (v) => parseInt(v)
|
|
});
|
|
valueProperty.register(ProgressBase);
|
|
|
|
/**
|
|
* Represents the observable property backing the maxValue property of each Progress instance.
|
|
*/
|
|
export const maxValueProperty = new Property<ProgressBase, number>({
|
|
name: "maxValue",
|
|
defaultValue: 100,
|
|
valueChanged: (target, oldValue, newValue) => {
|
|
valueProperty.coerce(target);
|
|
},
|
|
valueConverter: (v) => parseInt(v)
|
|
});
|
|
maxValueProperty.register(ProgressBase);
|