Merge pull request #3844 from NativeScript/list-picker-coerse

List picker coerse
This commit is contained in:
Alexander Vakrilov
2017-03-21 17:00:14 +02:00
committed by GitHub
3 changed files with 6 additions and 1 deletions

View File

@@ -46,7 +46,6 @@ export const itemsProperty = new Property<ListPickerBase, any[] | ItemsSource>({
name: "items", valueChanged: (target, oldValue, newValue) => {
let getItem = newValue && (<ItemsSource>newValue).getItem;
target.isItemsSource = typeof getItem === "function";
selectedIndexProperty.coerce(target);
}
});
itemsProperty.register(ListPickerBase);

View File

@@ -137,6 +137,9 @@ export class ListPicker extends ListPickerBase {
let maxValue = value && value.length > 0 ? value.length - 1 : 0;
this.android.setMaxValue(maxValue);
this._fixNumberPickerRendering();
// Coerce selected index after we have set items to native view.
selectedIndexProperty.coerce(this);
}
get [colorProperty.native](): { wheelColor: number, textColor: number } {

View File

@@ -46,6 +46,9 @@ export class ListPicker extends ListPickerBase {
}
set [itemsProperty.native](value: any[] | ItemsSource) {
this.ios.reloadAllComponents();
// Coerce selected index after we have set items to native view.
selectedIndexProperty.coerce(this);
}
get [backgroundColorProperty.native](): UIColor {