Fix TabViewItem loading

Fix showModal not on full screen
This commit is contained in:
Hristo Hristov
2017-12-11 15:19:08 +02:00
parent 0abfb1493c
commit a416fa4fb6
4 changed files with 27 additions and 25 deletions

View File

@ -141,14 +141,20 @@ function initializeDialogFragment() {
this.owner._dialogFragment = this;
this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0);
return new DialogImpl(this, this.getActivity(), this.getTheme());
const dialog = new DialogImpl(this, this.getActivity(), this.getTheme());
// adjust alignment based on fullscreen value.
this.owner.horizontalAlignment = this._fullscreen ? "stretch" : "center";
this.owner.verticalAlignment = this._fullscreen ? "stretch" : "middle";
return dialog;
}
public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View {
const owner = this.owner;
owner._setupUI(this.getActivity());
owner._isAddedToNativeVisualTree = true;
return this.owner.nativeViewProtected;
}

View File

@ -44,9 +44,6 @@ export class Page extends PageBase {
this.actionBar.update();
}
[actionBarHiddenProperty.getDefault](): boolean {
return undefined;
}
[actionBarHiddenProperty.setNative](value: boolean) {
this.updateActionBar();
}

View File

@ -30,7 +30,6 @@ export abstract class TabViewItemBase extends ViewBase implements TabViewItemDef
get title(): string {
return this._title;
}
set title(value: string) {
if (this._title !== value) {
this._title = value;
@ -69,6 +68,17 @@ export abstract class TabViewItemBase extends ViewBase implements TabViewItemDef
}
}
public loadView(view: ViewBase): void {
const tabView = this.parent as TabViewBase;
if (tabView && tabView.items) {
const index = tabView.items.indexOf(this);
// Don't load items until their fragments are instantiated.
if (index === tabView.selectedIndex && (<TabViewItemDefinition>this).canBeLoaded) {
super.loadView(view);
}
}
}
public abstract _update();
}
@ -135,11 +145,8 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
}
get _childrenCount(): number {
if (this.items) {
return this.items.length;
}
return 0;
const items = this.items;
return items ? items.length : 0;
}
public eachChild(callback: (child: ViewBase) => boolean) {
@ -151,15 +158,6 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
}
}
public loadView(view: ViewBase): void {
const item = view as TabViewItem;
const index = this.items.indexOf(item);
if (index === this.selectedIndex && item.canBeLoaded) {
super.loadView(item);
}
// Don't load items until their fragments are instantiated.
}
public eachChildView(callback: (child: View) => boolean) {
const items = this.items;
if (items) {
@ -193,17 +191,18 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
const oldItem = items[oldIndex];
if (oldItem) {
this.unloadView(oldItem);
oldItem.unloadView(oldItem.view);
}
const newItem = items[newIndex];
if (newItem && !newItem.isLoaded && this.isLoaded) {
this.loadView(newItem);
if (newItem && this.isLoaded) {
newItem.loadView(newItem.view);
}
this.notify(<SelectedIndexChangedEventData>{ eventName: TabViewBase.selectedIndexChangedEvent, object: this, oldIndex, newIndex });
}
}
export interface TabViewBase {
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any);

View File

@ -173,8 +173,8 @@ function initializeNativeClasses() {
const tab = this.owner;
const items = tab.items;
const newItem = items ? items[position] : null;
if (newItem && !newItem.isLoaded && tab.isLoaded) {
tab.loadView(newItem);
if (newItem && tab.isLoaded) {
newItem.loadView(newItem.view);
}
}
}