diff --git a/apps/app/ui-tests-app/tab-view/main-page.ts b/apps/app/ui-tests-app/tab-view/main-page.ts index ae3f6a4cf..57c80f6d7 100644 --- a/apps/app/ui-tests-app/tab-view/main-page.ts +++ b/apps/app/ui-tests-app/tab-view/main-page.ts @@ -24,6 +24,7 @@ export function loadExamples() { examples.set("tab-view-bottom-position", "tab-view/tab-view-bottom-position"); examples.set("issue-5470", "tab-view/issue-5470"); examples.set("tab-view-tab-text-font-size", "tab-view/tab-view-tab-text-font-size"); + examples.set("tab-view-android-swipe", "tab-view/tab-view-android-swipe"); examples.set("tab-view-icon-title-placement", "tab-view/icon-title-placement"); return examples; } diff --git a/apps/app/ui-tests-app/tab-view/tab-view-android-swipe.xml b/apps/app/ui-tests-app/tab-view/tab-view-android-swipe.xml new file mode 100644 index 000000000..389c43127 --- /dev/null +++ b/apps/app/ui-tests-app/tab-view/tab-view-android-swipe.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tns-core-modules/ui/tab-view/tab-view-common.ts b/tns-core-modules/ui/tab-view/tab-view-common.ts index 53eacbad9..e2a25ce34 100644 --- a/tns-core-modules/ui/tab-view/tab-view-common.ts +++ b/tns-core-modules/ui/tab-view/tab-view-common.ts @@ -2,7 +2,7 @@ import { View, ViewBase, Style, Property, CssProperty, CoercibleProperty, Color, isIOS, AddArrayFromBuilder, AddChildFromBuilder, EventData, CSSType, - traceWrite, traceCategories, traceMessageType + traceWrite, traceCategories, traceMessageType, booleanConverter } from "../core/view"; export * from "../core/view"; @@ -95,6 +95,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom public selectedIndex: number; public androidOffscreenTabLimit: number; public androidTabsPosition: "top" | "bottom"; + public androidSwipeEnabled: boolean; public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate"; get androidSelectedTabHighlightColor(): Color { @@ -252,6 +253,9 @@ androidOffscreenTabLimitProperty.register(TabViewBase); export const androidTabsPositionProperty = new Property({ name: "androidTabsPosition", defaultValue: "top" }); androidTabsPositionProperty.register(TabViewBase); +export const androidSwipeEnabledProperty = new Property({ name: "androidSwipeEnabled", defaultValue: true, valueConverter: booleanConverter }); +androidSwipeEnabledProperty.register(TabViewBase); + export const tabTextFontSizeProperty = new CssProperty({ name: "tabTextFontSize", cssName: "tab-text-font-size", valueConverter: (v) => parseFloat(v) }); tabTextFontSizeProperty.register(Style); diff --git a/tns-core-modules/ui/tab-view/tab-view.android.ts b/tns-core-modules/ui/tab-view/tab-view.android.ts index c88133342..8b89422d6 100644 --- a/tns-core-modules/ui/tab-view/tab-view.android.ts +++ b/tns-core-modules/ui/tab-view/tab-view.android.ts @@ -437,6 +437,10 @@ export class TabView extends TabViewBase { nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); viewPager.setLayoutParams(lp); + + if (!this.androidSwipeEnabled) { + viewPager.setSwipePageEnabled(false); + } } else { nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); diff --git a/tns-core-modules/ui/tab-view/tab-view.d.ts b/tns-core-modules/ui/tab-view/tab-view.d.ts index 759cb8229..720e01462 100644 --- a/tns-core-modules/ui/tab-view/tab-view.d.ts +++ b/tns-core-modules/ui/tab-view/tab-view.d.ts @@ -122,6 +122,11 @@ export class TabView extends View { */ androidTabsPosition: "top" | "bottom"; + /** + * Gets or sets a value indicating whether swipe gesture is enabled for Android. + */ + androidSwipeEnabled: boolean; + /** * String value used when hooking to the selectedIndexChanged event. */