|
1 | 1 | import { themer } from '@nativescript-community/ui-material-core';
|
2 |
| -import { Color, Device, Font, Frame, IOSHelper, ImageSource, Trace, Utils, View, ViewBase } from '@nativescript/core'; |
| 2 | +import { Color, Device, Font, Frame, IOSHelper, ImageSource, Property, Trace, Utils, View, ViewBase, booleanConverter } from '@nativescript/core'; |
3 | 3 | import { TabsBase, swipeEnabledProperty } from './tabs-common';
|
4 | 4 |
|
5 | 5 | import { getIconSpecSize, itemsProperty, selectedIndexProperty, tabStripProperty } from '@nativescript-community/ui-material-core/tab-navigation-base/tab-navigation-base';
|
@@ -424,7 +424,7 @@ function updateBackgroundPositions(tabStrip: TabStrip, tabStripItem: TabStripIte
|
424 | 424 | }
|
425 | 425 | let bgView = (tabStripItem as any).bgView;
|
426 | 426 | const index = tabStripItem._index;
|
427 |
| - const width = tabStrip.nativeView.frame.size.width / (tabStrip.items.filter(s=>s._index!== undefined).length); |
| 427 | + const width = tabStrip.nativeView.frame.size.width / tabStrip.items.filter((s) => s._index !== undefined).length; |
428 | 428 | const frame = CGRectMake(width * index, 0, width, tabStrip.nativeView.frame.size.width);
|
429 | 429 | if (!bgView) {
|
430 | 430 | bgView = UIView.alloc().initWithFrame(frame);
|
@@ -466,6 +466,12 @@ function updateTitleAndIconPositions(tabStripItem: TabStripItem, tabBarItem: UIT
|
466 | 466 | }
|
467 | 467 | }
|
468 | 468 |
|
| 469 | +export const iosCustomPositioningProperty = new Property<Tabs, boolean>({ |
| 470 | + name: 'iosCustomPositioning', |
| 471 | + defaultValue: false, |
| 472 | + |
| 473 | + valueConverter: booleanConverter |
| 474 | +}); |
469 | 475 | export class Tabs extends TabsBase {
|
470 | 476 | public nativeViewProtected: UIView;
|
471 | 477 | public selectedIndex: number;
|
@@ -494,6 +500,7 @@ export class Tabs extends TabsBase {
|
494 | 500 | public _animateNextChange = true;
|
495 | 501 | private _selectionIndicatorColor: Color;
|
496 | 502 | private _rippleColor: Color;
|
| 503 | + public iosCustomPositioning: boolean; |
497 | 504 |
|
498 | 505 | constructor() {
|
499 | 506 | super();
|
@@ -548,11 +555,15 @@ export class Tabs extends TabsBase {
|
548 | 555 | }
|
549 | 556 |
|
550 | 557 | public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
|
551 |
| - // |
| 558 | + if (this.iosCustomPositioning) { |
| 559 | + super.layoutNativeView(left, top, right, bottom); |
| 560 | + } |
552 | 561 | }
|
553 | 562 |
|
554 | 563 | public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
|
555 |
| - // |
| 564 | + if (this.iosCustomPositioning) { |
| 565 | + super._setNativeViewFrame(nativeView, frame); |
| 566 | + } |
556 | 567 | }
|
557 | 568 |
|
558 | 569 | public onSelectedIndexChanged(oldIndex: number, newIndex: number): void {
|
@@ -1295,3 +1306,4 @@ export class Tabs extends TabsBase {
|
1295 | 1306 | }
|
1296 | 1307 | }
|
1297 | 1308 | }
|
| 1309 | +iosCustomPositioningProperty.register(Tabs); |
0 commit comments