mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(ios-action-bar): NavigationButton cannot be hidden if navigating with transition (#5451)
This commit is contained in:

committed by
Alexander Vakrilov

parent
4898c33a04
commit
c54e069f57
@ -299,6 +299,12 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition {
|
|||||||
this.actionView = value;
|
this.actionView = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public _onVisibilityChanged(visibility: string) {
|
||||||
|
if (this.actionBar) {
|
||||||
|
this.actionBar.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public eachChild(callback: (child: ViewBase) => boolean) {
|
public eachChild(callback: (child: ViewBase) => boolean) {
|
||||||
if (this._actionView) {
|
if (this._actionView) {
|
||||||
callback(this._actionView);
|
callback(this._actionView);
|
||||||
@ -323,13 +329,17 @@ function onItemChanged(item: ActionItemBase, oldValue: string, newValue: string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onVisibilityChanged(item: ActionItemBase, oldValue: string, newValue: string) {
|
||||||
|
item._onVisibilityChanged(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
export const textProperty = new Property<ActionItemBase, string>({ name: "text", defaultValue: "", valueChanged: onItemChanged });
|
export const textProperty = new Property<ActionItemBase, string>({ name: "text", defaultValue: "", valueChanged: onItemChanged });
|
||||||
textProperty.register(ActionItemBase);
|
textProperty.register(ActionItemBase);
|
||||||
|
|
||||||
export const iconProperty = new Property<ActionItemBase, string>({ name: "icon", valueChanged: onItemChanged });
|
export const iconProperty = new Property<ActionItemBase, string>({ name: "icon", valueChanged: onItemChanged });
|
||||||
iconProperty.register(ActionItemBase);
|
iconProperty.register(ActionItemBase);
|
||||||
|
|
||||||
export const visibilityProperty = new Property({ name: "visibility", defaultValue: "visible", valueChanged: onItemChanged });
|
export const visibilityProperty = new Property({ name: "visibility", defaultValue: "visible", valueChanged: onVisibilityChanged });
|
||||||
visibilityProperty.register(ActionItemBase);
|
visibilityProperty.register(ActionItemBase);
|
||||||
|
|
||||||
export const flatProperty = new Property<ActionBarBase, boolean>({ name: "flat", defaultValue: false, valueConverter: booleanConverter });
|
export const flatProperty = new Property<ActionBarBase, boolean>({ name: "flat", defaultValue: false, valueConverter: booleanConverter });
|
||||||
|
@ -103,7 +103,6 @@ export class AndroidActionBarSettings implements AndroidActionBarSettingsDefinit
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NavigationButton extends ActionItem {
|
export class NavigationButton extends ActionItem {
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ActionBar extends ActionBarBase {
|
export class ActionBar extends ActionBarBase {
|
||||||
|
@ -239,7 +239,12 @@ export interface AndroidActionBarSettings {
|
|||||||
* Represents the navigation (a.k.a. "back") button.
|
* Represents the navigation (a.k.a. "back") button.
|
||||||
*/
|
*/
|
||||||
export class NavigationButton extends ActionItem {
|
export class NavigationButton extends ActionItem {
|
||||||
|
//@private
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_navigationItem?: any
|
||||||
|
//@endprivate
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
@ -44,7 +44,14 @@ export class ActionItem extends ActionItemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NavigationButton extends ActionItem {
|
export class NavigationButton extends ActionItem {
|
||||||
|
_navigationItem: UINavigationItem;
|
||||||
|
|
||||||
|
public _onVisibilityChanged(visibility: string): void {
|
||||||
|
if (this._navigationItem) {
|
||||||
|
const visible: boolean = visibility === "visible";
|
||||||
|
this._navigationItem.setHidesBackButtonAnimated(!visible, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ActionBar extends ActionBarBase {
|
export class ActionBar extends ActionBarBase {
|
||||||
@ -158,7 +165,8 @@ export class ActionBar extends ActionBarBase {
|
|||||||
|
|
||||||
// Set back button visibility
|
// Set back button visibility
|
||||||
if (this.navigationButton) {
|
if (this.navigationButton) {
|
||||||
navigationItem.setHidesBackButtonAnimated(!isVisible(this.navigationButton), true);
|
this.navigationButton._navigationItem = navigationItem;
|
||||||
|
navigationItem.setHidesBackButtonAnimated(!isVisible(this.navigationButton), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate action items
|
// Populate action items
|
||||||
|
Reference in New Issue
Block a user