| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,5 +21,6 @@ export function loadExamples() { | |||
| 21 | 21 | examples.set("tab-view-icons", "tab-view/tab-view-icon"); | |
| 22 | 22 | examples.set("tab-view-icon-change", "tab-view/tab-view-icon-change"); | |
| 23 | 23 | examples.set("text-transform", "tab-view/text-transform"); | |
| 24 | + examples.set("tab-view-bottom-position","tab-view/tab-view-bottom-position"); | ||
| 24 | 25 | return examples; | |
| 25 | 26 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + <Page> | ||
| 2 | + <TabView androidTabsPosition="bottom"> | ||
| 3 | + <TabView.items> | ||
| 4 | + <TabViewItem title="First"> | ||
| 5 | + <TabViewItem.view> | ||
| 6 | + <GridLayout> | ||
| 7 | + <Label text="First View" verticalAlignment="center" horizontalAlignment="center"/> | ||
| 8 | + </GridLayout> | ||
| 9 | + </TabViewItem.view> | ||
| 10 | + </TabViewItem> | ||
| 11 | + <TabViewItem title="Second"> | ||
| 12 | + <TabViewItem.view> | ||
| 13 | + <GridLayout> | ||
| 14 | + <Label text="Second View" verticalAlignment="center" horizontalAlignment="center"/> | ||
| 15 | + </GridLayout> | ||
| 16 | + </TabViewItem.view> | ||
| 17 | + </TabViewItem> | ||
| 18 | + </TabView.items> | ||
| 19 | + </TabView> | ||
| 20 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,6 +92,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom | |||
| 92 | 92 | public items: TabViewItemDefinition[]; | |
| 93 | 93 | public selectedIndex: number; | |
| 94 | 94 | public androidOffscreenTabLimit: number; | |
| 95 | + public androidTabsPosition: "top" | "bottom"; | ||
| 95 | 96 | public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate"; | |
| 96 | 97 | ||
| 97 | 98 | get androidSelectedTabHighlightColor(): Color { | |
@@ -177,7 +178,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom | |||
| 177 | 178 | if (!item.view) { | |
| 178 | 179 | throw new Error(`TabViewItem must have a view.`); | |
| 179 | 180 | } | |
| 180 | - | ||
| 181 | + | ||
| 181 | 182 | this._addView(item); | |
| 182 | 183 | }); | |
| 183 | 184 | } | |
@@ -249,6 +250,9 @@ export const androidOffscreenTabLimitProperty = new Property<TabViewBase, number | |||
| 249 | 250 | }); | |
| 250 | 251 | androidOffscreenTabLimitProperty.register(TabViewBase); | |
| 251 | 252 | ||
| 253 | + export const androidTabsPositionProperty = new Property<TabViewBase, "top" | "bottom">({ name: "androidTabsPosition", defaultValue: "top" }); | ||
| 254 | + androidTabsPositionProperty.register(TabViewBase); | ||
| 255 | + | ||
| 252 | 256 | export const tabTextColorProperty = new CssProperty<Style, Color>({ name: "tabTextColor", cssName: "tab-text-color", equalityComparer: Color.equals, valueConverter: (v) => new Color(v) }); | |
| 253 | 257 | tabTextColorProperty.register(Style); | |
| 254 | 258 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,8 +5,8 @@ import { | |||
| 5 | 5 | TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, | |
| 6 | 6 | tabTextColorProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, | |
| 7 | 7 | androidSelectedTabHighlightColorProperty, androidOffscreenTabLimitProperty, | |
| 8 | - fontSizeProperty, fontInternalProperty, View, layout, | ||
| 9 | - traceCategory, traceEnabled, traceWrite, Color | ||
| 8 | + fontSizeProperty, fontInternalProperty, View, layout, traceCategory, traceEnabled, | ||
| 9 | + traceWrite, Color | ||
| 10 | 10 | } from "./tab-view-common" | |
| 11 | 11 | import { textTransformProperty, TextTransform, getTransformedText } from "../text-base"; | |
| 12 | 12 | import { fromFileOrResource } from "../../image-source"; | |
@@ -367,36 +367,49 @@ export class TabView extends TabViewBase { | |||
| 367 | 367 | ||
| 368 | 368 | const context: android.content.Context = this._context; | |
| 369 | 369 | const nativeView = new org.nativescript.widgets.GridLayout(context); | |
| 370 | - nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); | ||
| 371 | - nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); | ||
| 372 | - | ||
| 370 | + const viewPager = new org.nativescript.widgets.TabViewPager(context); | ||
| 373 | 371 | const tabLayout = new org.nativescript.widgets.TabLayout(context); | |
| 372 | + const lp = new org.nativescript.widgets.CommonLayoutParams(); | ||
| 373 | + const primaryColor = ad.resources.getPaletteColor(PRIMARY_COLOR, context); | ||
| 374 | + let accentColor = getDefaultAccentColor(context); | ||
| 375 | + | ||
| 376 | + lp.row = 1; | ||
| 377 | + | ||
| 378 | + if (this.androidTabsPosition === "top") { | ||
| 379 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); | ||
| 380 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); | ||
| 381 | + | ||
| 382 | + viewPager.setLayoutParams(lp); | ||
| 383 | + } else { | ||
| 384 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); | ||
| 385 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); | ||
| 386 | + | ||
| 387 | + tabLayout.setLayoutParams(lp); | ||
| 388 | + viewPager.setSwipePageEnabled(false); | ||
| 389 | + // set completely transparent accent color for tab selected indicator. | ||
| 390 | + accentColor = 0x00FFFFFF; | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + nativeView.addView(viewPager); | ||
| 394 | + (<any>nativeView).viewPager = viewPager; | ||
| 395 | + | ||
| 396 | + const adapter = new PagerAdapter(this); | ||
| 397 | + viewPager.setAdapter(adapter); | ||
| 398 | + (<any>viewPager).adapter = adapter; | ||
| 399 | + | ||
| 374 | 400 | nativeView.addView(tabLayout); | |
| 375 | 401 | (<any>nativeView).tabLayout = tabLayout; | |
| 376 | 402 | ||
| 377 | 403 | setElevation(nativeView, tabLayout); | |
| 378 | 404 | ||
| 379 | - const accentColor = getDefaultAccentColor(context); | ||
| 380 | 405 | if (accentColor) { | |
| 381 | 406 | tabLayout.setSelectedIndicatorColors([accentColor]); | |
| 382 | 407 | } | |
| 383 | 408 | ||
| 384 | - const primaryColor = ad.resources.getPaletteColor(PRIMARY_COLOR, context); | ||
| 385 | 409 | if (primaryColor) { | |
| 386 | 410 | tabLayout.setBackgroundColor(primaryColor); | |
| 387 | 411 | } | |
| 388 | 412 | ||
| 389 | - const viewPager = new android.support.v4.view.ViewPager(context); | ||
| 390 | - const lp = new org.nativescript.widgets.CommonLayoutParams(); | ||
| 391 | - lp.row = 1; | ||
| 392 | - viewPager.setLayoutParams(lp); | ||
| 393 | - nativeView.addView(viewPager); | ||
| 394 | - (<any>nativeView).viewPager = viewPager; | ||
| 395 | - | ||
| 396 | - const adapter = new PagerAdapter(this); | ||
| 397 | - viewPager.setAdapter(adapter); | ||
| 398 | - (<any>viewPager).adapter = adapter; | ||
| 399 | - | ||
| 400 | 413 | return nativeView; | |
| 401 | 414 | } | |
| 402 | 415 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,6 +109,14 @@ export class TabView extends View { | |||
| 109 | 109 | */ | |
| 110 | 110 | androidOffscreenTabLimit: number; | |
| 111 | 111 | ||
| 112 | + /** | ||
| 113 | + * Gets or set the tabs vertical position. | ||
| 114 | + * Valid values are: | ||
| 115 | + * - top | ||
| 116 | + * - bottom | ||
| 117 | + */ | ||
| 118 | + androidTabsPosition: "top" | "bottom"; | ||
| 119 | + | ||
| 112 | 120 | /** | |
| 113 | 121 | * String value used when hooking to the selectedIndexChanged event. | |
| 114 | 122 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -371,6 +371,13 @@ | |||
| 371 | 371 | getItemCount(): number; | |
| 372 | 372 | } | |
| 373 | 373 | ||
| 374 | + export class TabViewPager extends android.support.v4.view.ViewPager { | ||
| 375 | + constructor(context: android.content.Context); | ||
| 376 | + constructor(context: android.content.Context, attrs: android.util.IAttributeSet); | ||
| 377 | + | ||
| 378 | + setSwipePageEnabled(enabled: boolean): void; | ||
| 379 | + } | ||
| 380 | + | ||
| 374 | 381 | export class TabItemSpec { | |
| 375 | 382 | title: string; | |
| 376 | 383 | iconId: number; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments