FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(ios-action-bar): NavigationButton cannot be hidden by ADjenkov · Pull Request #5451 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 11 additions & 1 deletion tns-core-modules/ui/action-bar/action-bar-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 });
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export class AndroidActionBarSettings implements AndroidActionBarSettingsDefinit
}

export class NavigationButton extends ActionItem {
//
}

export class ActionBar extends ActionBarBase {
Expand Down
7 changes: 6 additions & 1 deletion tns-core-modules/ui/action-bar/action-bar.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 10 additions & 2 deletions tns-core-modules/ui/action-bar/action-bar.ios.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

Back | FazBrowse Home | New Git URL