feat(tabview): add androidSwipeEnabled property (#6652)

This commit is contained in:
Manol Donev
2018-12-04 15:35:15 +02:00
committed by GitHub
parent 5b5fd9a0b7
commit 0b239d7a0a
5 changed files with 39 additions and 1 deletions

View File

@ -24,6 +24,7 @@ export function loadExamples() {
examples.set("tab-view-bottom-position", "tab-view/tab-view-bottom-position"); examples.set("tab-view-bottom-position", "tab-view/tab-view-bottom-position");
examples.set("issue-5470", "tab-view/issue-5470"); 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-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"); examples.set("tab-view-icon-title-placement", "tab-view/icon-title-placement");
return examples; return examples;
} }

View File

@ -0,0 +1,24 @@
<Page cssFile="~/ui-tests-app/css/test.css" loaded="onLoaded">
<TabView androidSwipeEnabled="false">
<TabView.items>
<TabViewItem title="Tab 1">
<TabViewItem.view>
<Label text="Label 1" />
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="Tab 2">
<TabViewItem.view>
<Label text="Label 2" />
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="Tab 3">
<TabViewItem.view>
<Label text="Label 3" />
</TabViewItem.view>
</TabViewItem>
</TabView.items>
</TabView>
</Page>

View File

@ -2,7 +2,7 @@
import { import {
View, ViewBase, Style, Property, CssProperty, CoercibleProperty, View, ViewBase, Style, Property, CssProperty, CoercibleProperty,
Color, isIOS, AddArrayFromBuilder, AddChildFromBuilder, EventData, CSSType, Color, isIOS, AddArrayFromBuilder, AddChildFromBuilder, EventData, CSSType,
traceWrite, traceCategories, traceMessageType traceWrite, traceCategories, traceMessageType, booleanConverter
} from "../core/view"; } from "../core/view";
export * from "../core/view"; export * from "../core/view";
@ -95,6 +95,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
public selectedIndex: number; public selectedIndex: number;
public androidOffscreenTabLimit: number; public androidOffscreenTabLimit: number;
public androidTabsPosition: "top" | "bottom"; public androidTabsPosition: "top" | "bottom";
public androidSwipeEnabled: boolean;
public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate"; public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate";
get androidSelectedTabHighlightColor(): Color { get androidSelectedTabHighlightColor(): Color {
@ -252,6 +253,9 @@ androidOffscreenTabLimitProperty.register(TabViewBase);
export const androidTabsPositionProperty = new Property<TabViewBase, "top" | "bottom">({ name: "androidTabsPosition", defaultValue: "top" }); export const androidTabsPositionProperty = new Property<TabViewBase, "top" | "bottom">({ name: "androidTabsPosition", defaultValue: "top" });
androidTabsPositionProperty.register(TabViewBase); androidTabsPositionProperty.register(TabViewBase);
export const androidSwipeEnabledProperty = new Property<TabViewBase, boolean>({ name: "androidSwipeEnabled", defaultValue: true, valueConverter: booleanConverter });
androidSwipeEnabledProperty.register(TabViewBase);
export const tabTextFontSizeProperty = new CssProperty<Style, number>({ name: "tabTextFontSize", cssName: "tab-text-font-size", valueConverter: (v) => parseFloat(v) }); export const tabTextFontSizeProperty = new CssProperty<Style, number>({ name: "tabTextFontSize", cssName: "tab-text-font-size", valueConverter: (v) => parseFloat(v) });
tabTextFontSizeProperty.register(Style); tabTextFontSizeProperty.register(Style);

View File

@ -437,6 +437,10 @@ export class TabView extends TabViewBase {
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.star));
viewPager.setLayoutParams(lp); viewPager.setLayoutParams(lp);
if (!this.androidSwipeEnabled) {
viewPager.setSwipePageEnabled(false);
}
} else { } 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.star));
nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto));

View File

@ -122,6 +122,11 @@ export class TabView extends View {
*/ */
androidTabsPosition: "top" | "bottom"; 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. * String value used when hooking to the selectedIndexChanged event.
*/ */