mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix: dont create an actionbar if not necessary (#8402)
* fix: dont create an actionbar if not necessary For now i kept the commented code so that you can see the change. Also i changed the android check to behave like iOS * rollback. we now try an make sure the actionbar is created only if needed * actually we should check for false
This commit is contained in:
@ -138,7 +138,7 @@ export class PageBase extends ContentView implements PageDefinition {
|
|||||||
|
|
||||||
public eachChildView(callback: (child: View) => boolean) {
|
public eachChildView(callback: (child: View) => boolean) {
|
||||||
super.eachChildView(callback);
|
super.eachChildView(callback);
|
||||||
if (this.actionBar) {
|
if (this.hasActionBar) {
|
||||||
callback(this.actionBar);
|
callback(this.actionBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,17 +45,30 @@ export class Page extends PageBase {
|
|||||||
@profile
|
@profile
|
||||||
public onLoaded() {
|
public onLoaded() {
|
||||||
super.onLoaded();
|
super.onLoaded();
|
||||||
if (this.actionBarHidden !== undefined) {
|
if (!this.hasActionBar && this.actionBarHidden !== true) {
|
||||||
|
// ensure actionBar is created
|
||||||
|
// but we only need to do that if the actionBarHidden is not hidden
|
||||||
|
this.actionBar = new ActionBar();
|
||||||
|
}
|
||||||
|
if (this.hasActionBar) {
|
||||||
this.updateActionBar();
|
this.updateActionBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateActionBar() {
|
private updateActionBar() {
|
||||||
this.actionBar.update();
|
// the test is actually to ensure the actionBar is created
|
||||||
|
// it will be created if not
|
||||||
|
if (this.actionBar) {
|
||||||
|
this.actionBar.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||||
this.updateActionBar();
|
// in case the actionBar is not created and actionBarHidden is changed to true
|
||||||
|
// the actionBar will be created by updateActionBar
|
||||||
|
if (!value || this.hasActionBar) {
|
||||||
|
this.updateActionBar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[statusBarStyleProperty.getDefault](): { color: number, systemUiVisibility: number } {
|
[statusBarStyleProperty.getDefault](): { color: number, systemUiVisibility: number } {
|
||||||
|
Reference in New Issue
Block a user