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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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