diff --git a/nativescript-core/ui/tabs/tabs-common.ts b/nativescript-core/ui/tabs/tabs-common.ts index 56f3f2ad9..d12374504 100644 --- a/nativescript-core/ui/tabs/tabs-common.ts +++ b/nativescript-core/ui/tabs/tabs-common.ts @@ -43,4 +43,7 @@ tabsPositionProperty.register(TabsBase); export type IOSTabBarItemsAlignment = "leading" | "justified" | "center" | "centerSelected"; export const iOSTabBarItemsAlignmentProperty = new Property({ name: "iOSTabBarItemsAlignment", defaultValue: "justified" }); -iOSTabBarItemsAlignmentProperty.register(TabsBase); \ No newline at end of file +iOSTabBarItemsAlignmentProperty.register(TabsBase); + +export const iOSAnimationEnabledProperty = new Property({ name: "iOSAnimationEnabled", defaultValue: true, valueConverter: booleanConverter }); +iOSAnimationEnabledProperty.register(TabsBase); diff --git a/nativescript-core/ui/tabs/tabs.ios.ts b/nativescript-core/ui/tabs/tabs.ios.ts index e22132fa7..dd28ddf1f 100644 --- a/nativescript-core/ui/tabs/tabs.ios.ts +++ b/nativescript-core/ui/tabs/tabs.ios.ts @@ -463,6 +463,7 @@ export class Tabs extends TabsBase { public _defaultItemBackgroundColor: UIColor; private _selectedItemColor: Color; private _unSelectedItemColor: Color; + public iOSAnimationEnabled: boolean; constructor() { super(); @@ -1102,7 +1103,7 @@ export class Tabs extends TabsBase { // do not make layout changes while the animation is in progress https://stackoverflow.com/a/47031524/613113 this.visitFrames(item, frame => frame._animationInProgress = true); - this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => { + invokeOnRunLoop( () => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, this.iOSAnimationEnabled, (finished: boolean) => { this.visitFrames(item, frame => frame._animationInProgress = false); if (finished) { // HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606 @@ -1112,10 +1113,10 @@ export class Tabs extends TabsBase { this._setCanBeLoaded(value); this._loadUnloadTabItems(value); } - }); + })); if (this.tabBarItems && this.tabBarItems.length && this.viewController && this.viewController.tabBar) { - this.viewController.tabBar.setSelectedItemAnimated(this.tabBarItems[value], true); + this.viewController.tabBar.setSelectedItemAnimated(this.tabBarItems[value], this.iOSAnimationEnabled); } // TODO: // (this._ios)._willSelectViewController = this._ios.viewControllers[value]; @@ -1140,7 +1141,6 @@ export class Tabs extends TabsBase { [tabStripProperty.getDefault](): TabStrip { return null; } - [tabStripProperty.setNative](value: TabStrip) { this.setViewControllers(this.items); selectedIndexProperty.coerce(this); @@ -1149,7 +1149,6 @@ export class Tabs extends TabsBase { [swipeEnabledProperty.getDefault](): boolean { return true; } - [swipeEnabledProperty.setNative](value: boolean) { if (this.viewController && this.viewController.scrollView) { this.viewController.scrollView.scrollEnabled = value; @@ -1165,7 +1164,6 @@ export class Tabs extends TabsBase { return (alignment.charAt(0).toLowerCase() + alignment.substring(1)); } - [iOSTabBarItemsAlignmentProperty.setNative](value: IOSTabBarItemsAlignment) { if (!this.viewController || !this.viewController.tabBar) { return; @@ -1219,4 +1217,4 @@ export class Tabs extends TabsBase { this.viewController.tabBar.unselectedItemTintColor = this._unSelectedItemColor.ios; } } -} \ No newline at end of file +}