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

fix(bottom-navigation): crash when tab selected with no item by ADjenkov · Pull Request #7527 · NativeScript/NativeScript · GitHub

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

Filter by extension

Filter by extension .java  (2) .ts  (3) All 2 file types 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
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 @@ -216,8 +216,9 @@ private void setupItem(LinearLayout ll, TextView textView,ImageView imgView, Tab
lp.weight = 1;
}

public void onTap(int position) {
public boolean onTap(int position) {
// to be overridden in JS
return true;
}

public void onSelectedPositionChange(int position, int prevPosition) {
Expand Down Expand Up @@ -269,8 +270,9 @@ private class TabClickListener implements OnClickListener {
public void onClick(View v) {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
if (v == mTabStrip.getChildAt(i)) {
onTap(i);
setSelectedPosition(i);
if (onTap(i)) {
setSelectedPosition(i);
}
return;
}
}
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 @@ -301,8 +301,9 @@ private void setupItem(LinearLayout ll, TextView textView,ImageView imgView, Tab
}
}

public void onTap(int position) {
public boolean onTap(int position) {
// to be overridden in JS
return true;
}

public void onSelectedPositionChange(int position, int prevPosition) {
Expand Down Expand Up @@ -429,8 +430,9 @@ private class TabClickListener implements OnClickListener {
public void onClick(View v) {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
if (v == mTabStrip.getChildAt(i)) {
onTap(i);
mViewPager.setCurrentItem(i);
if (onTap(i)) {
mViewPager.setCurrentItem(i);
}
return;
}
}
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 @@ -118,17 +118,23 @@ function initializeNativeClasses() {
owner.selectedIndex = position;
}

public onTap(position: number): void {
public onTap(position: number): boolean {
const owner = this.owner;
if (!owner) {
return;
return false;
}

const tabStripItems = owner.tabStrip && owner.tabStrip.items;

if (position >= 0 && tabStripItems[position]) {
tabStripItems[position]._emit(TabStripItem.tapEvent);
}

if (!owner.items[position]) {
return false;
}

return true;
}
}

Expand Down
10 changes: 8 additions & 2 deletions tns-core-modules/ui/tabs/tabs.android.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 @@ -259,17 +259,23 @@ function initializeNativeClasses() {
}
}

public onTap(position: number): void {
public onTap(position: number): boolean {
const owner = this.owner;
if (!owner) {
return;
return false;
}

const tabStripItems = owner.tabStrip && owner.tabStrip.items;

if (position >= 0 && tabStripItems[position]) {
tabStripItems[position]._emit(TabStripItem.tapEvent);
}

if (!owner.items[position]) {
return false;
}

return true;
}
}

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 @@ -410,7 +410,7 @@
setTabTextFontSize(fontSize: number): void;
getTabTextFontSize(): number;

onTap(position: number): void;
onTap(position: number): boolean;
onSelectedPositionChange(position: number, prevPosition: number): void ;
setSelectedPosition(position: number): void;
setItems(items: Array<TabItemSpec>): void;
Expand Down

Back | FazBrowse Home | New Git URL