mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Fix TabViewItem loading
Fix showModal not on full screen
This commit is contained in:
@ -141,14 +141,20 @@ function initializeDialogFragment() {
|
|||||||
this.owner._dialogFragment = this;
|
this.owner._dialogFragment = this;
|
||||||
this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0);
|
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 {
|
public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View {
|
||||||
const owner = this.owner;
|
const owner = this.owner;
|
||||||
owner._setupUI(this.getActivity());
|
owner._setupUI(this.getActivity());
|
||||||
owner._isAddedToNativeVisualTree = true;
|
owner._isAddedToNativeVisualTree = true;
|
||||||
|
|
||||||
return this.owner.nativeViewProtected;
|
return this.owner.nativeViewProtected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,6 @@ export class Page extends PageBase {
|
|||||||
this.actionBar.update();
|
this.actionBar.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
[actionBarHiddenProperty.getDefault](): boolean {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||||
this.updateActionBar();
|
this.updateActionBar();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ export abstract class TabViewItemBase extends ViewBase implements TabViewItemDef
|
|||||||
get title(): string {
|
get title(): string {
|
||||||
return this._title;
|
return this._title;
|
||||||
}
|
}
|
||||||
|
|
||||||
set title(value: string) {
|
set title(value: string) {
|
||||||
if (this._title !== value) {
|
if (this._title !== value) {
|
||||||
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();
|
public abstract _update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +145,8 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
|
|||||||
}
|
}
|
||||||
|
|
||||||
get _childrenCount(): number {
|
get _childrenCount(): number {
|
||||||
if (this.items) {
|
const items = this.items;
|
||||||
return this.items.length;
|
return items ? items.length : 0;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public eachChild(callback: (child: ViewBase) => boolean) {
|
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) {
|
public eachChildView(callback: (child: View) => boolean) {
|
||||||
const items = this.items;
|
const items = this.items;
|
||||||
if (items) {
|
if (items) {
|
||||||
@ -193,17 +191,18 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
|
|||||||
|
|
||||||
const oldItem = items[oldIndex];
|
const oldItem = items[oldIndex];
|
||||||
if (oldItem) {
|
if (oldItem) {
|
||||||
this.unloadView(oldItem);
|
oldItem.unloadView(oldItem.view);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newItem = items[newIndex];
|
const newItem = items[newIndex];
|
||||||
if (newItem && !newItem.isLoaded && this.isLoaded) {
|
if (newItem && this.isLoaded) {
|
||||||
this.loadView(newItem);
|
newItem.loadView(newItem.view);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.notify(<SelectedIndexChangedEventData>{ eventName: TabViewBase.selectedIndexChangedEvent, object: this, oldIndex, newIndex });
|
this.notify(<SelectedIndexChangedEventData>{ eventName: TabViewBase.selectedIndexChangedEvent, object: this, oldIndex, newIndex });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TabViewBase {
|
export interface TabViewBase {
|
||||||
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
|
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
|
||||||
on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any);
|
on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any);
|
||||||
|
@ -173,8 +173,8 @@ function initializeNativeClasses() {
|
|||||||
const tab = this.owner;
|
const tab = this.owner;
|
||||||
const items = tab.items;
|
const items = tab.items;
|
||||||
const newItem = items ? items[position] : null;
|
const newItem = items ? items[position] : null;
|
||||||
if (newItem && !newItem.isLoaded && tab.isLoaded) {
|
if (newItem && tab.isLoaded) {
|
||||||
tab.loadView(newItem);
|
newItem.loadView(newItem.view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user