mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +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;
|
||||
}
|
||||
|
||||
public _onVisibilityChanged(visibility: string) {
|
||||
if (this.actionBar) {
|
||||
this.actionBar.update();
|
||||
}
|
||||
}
|
||||
|
||||
public eachChild(callback: (child: ViewBase) => boolean) {
|
||||
if (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 });
|
||||
textProperty.register(ActionItemBase);
|
||||
|
||||
export const iconProperty = new Property<ActionItemBase, string>({ name: "icon", valueChanged: onItemChanged });
|
||||
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);
|
||||
|
||||
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 ActionBar extends ActionBarBase {
|
||||
|
@ -239,7 +239,12 @@ export interface AndroidActionBarSettings {
|
||||
* Represents the navigation (a.k.a. "back") button.
|
||||
*/
|
||||
export class NavigationButton extends ActionItem {
|
||||
|
||||
//@private
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_navigationItem?: any
|
||||
//@endprivate
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
@ -44,7 +44,14 @@ export class ActionItem extends ActionItemBase {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -82,7 +89,7 @@ export class ActionBar extends ActionBarBase {
|
||||
if (!navBar) {
|
||||
return { width: 0, height: 0 };
|
||||
}
|
||||
|
||||
|
||||
const frame = navBar.frame;
|
||||
const size = frame.size;
|
||||
const width = layout.toDevicePixels(size.width);
|
||||
@ -158,7 +165,8 @@ export class ActionBar extends ActionBarBase {
|
||||
|
||||
// Set back button visibility
|
||||
if (this.navigationButton) {
|
||||
navigationItem.setHidesBackButtonAnimated(!isVisible(this.navigationButton), true);
|
||||
this.navigationButton._navigationItem = navigationItem;
|
||||
navigationItem.setHidesBackButtonAnimated(!isVisible(this.navigationButton), false);
|
||||
}
|
||||
|
||||
// Populate action items
|
||||
|
Reference in New Issue
Block a user