diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..491e1924 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "cSpell.words": [ + "Bilal", + "Cherepanov", + "neumorphic", + "Neumorphism", + "Shahid" + ] +} \ No newline at end of file diff --git a/lib/models/persisten-bottom-nav-item.widget.dart b/lib/models/persistent-bottom-nav-item.widget.dart similarity index 97% rename from lib/models/persisten-bottom-nav-item.widget.dart rename to lib/models/persistent-bottom-nav-item.widget.dart index d769afad..1609ded7 100644 --- a/lib/models/persisten-bottom-nav-item.widget.dart +++ b/lib/models/persistent-bottom-nav-item.widget.dart @@ -35,7 +35,7 @@ class PersistentBottomNavBarItem { ///If you want custom behavior on a press of a NavBar item like display a modal screen, you can declare your logic here. /// - ///NOTE: This will override the default tab switiching behavior for this particular item. + ///NOTE: This will override the default tab switching behavior for this particular item. final Function(BuildContext?)? onPressed; ///Use it when you want to run some code when user presses the NavBar when on the initial screen of that respective tab. The inspiration was taken from the native iOS navigation bar behavior where when performing similar operation, you taken to the top of the list. diff --git a/lib/models/persistent-nav-bar-scaffold.widget.dart b/lib/models/persistent-nav-bar-scaffold.widget.dart index cab956ef..528dd727 100644 --- a/lib/models/persistent-nav-bar-scaffold.widget.dart +++ b/lib/models/persistent-nav-bar-scaffold.widget.dart @@ -316,10 +316,10 @@ class _TabSwitchingViewState extends State<_TabSwitchingView> key = UniqueKey(); } - _initAniamtionControllers(); + _initAnimationControllers(); } - _initAniamtionControllers() { + _initAnimationControllers() { if (widget.screenTransitionAnimation!.animateTabTransition) { _animationControllers = List.filled(widget.tabCount!, null); @@ -490,13 +490,13 @@ class _TabSwitchingViewState extends State<_TabSwitchingView> _animationValue = MediaQuery.of(context).size.width; if (_tabCount != widget.tabCount) { _tabCount = widget.tabCount; - _initAniamtionControllers(); + _initAnimationControllers(); } if (widget.screenTransitionAnimation!.animateTabTransition && _animationControllers.first!.duration != widget.screenTransitionAnimation!.duration || _animationCurve != widget.screenTransitionAnimation!.curve) { - _initAniamtionControllers(); + _initAnimationControllers(); } if (_showAnimation != widget.screenTransitionAnimation!.animateTabTransition) { diff --git a/lib/models/route-settings.model.dart b/lib/models/route-settings.model.dart index fa552481..138b1cc2 100644 --- a/lib/models/route-settings.model.dart +++ b/lib/models/route-settings.model.dart @@ -46,7 +46,7 @@ class RouteAndNavigatorSettings { } } -class CutsomWidgetRouteAndNavigatorSettings { +class CustomWidgetRouteAndNavigatorSettings { final String? defaultTitle; final Map? routes; @@ -61,7 +61,7 @@ class CutsomWidgetRouteAndNavigatorSettings { final List>? navigatorKeys; - const CutsomWidgetRouteAndNavigatorSettings({ + const CustomWidgetRouteAndNavigatorSettings({ this.defaultTitle, this.routes, this.onGenerateRoute, @@ -71,7 +71,7 @@ class CutsomWidgetRouteAndNavigatorSettings { this.navigatorKeys, }); - CutsomWidgetRouteAndNavigatorSettings copyWith({ + CustomWidgetRouteAndNavigatorSettings copyWith({ String? defaultTitle, Map? routes, RouteFactory? onGenerateRoute, @@ -80,7 +80,7 @@ class CutsomWidgetRouteAndNavigatorSettings { List? navigatorObservers, List>? navigatorKeys, }) { - return CutsomWidgetRouteAndNavigatorSettings( + return CustomWidgetRouteAndNavigatorSettings( defaultTitle: defaultTitle ?? this.defaultTitle, routes: routes ?? this.routes, onGenerateRoute: onGenerateRoute ?? this.onGenerateRoute, diff --git a/lib/persistent-tab-view.dart b/lib/persistent-tab-view.dart index 559cfd88..ff16360b 100644 --- a/lib/persistent-tab-view.dart +++ b/lib/persistent-tab-view.dart @@ -5,7 +5,6 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart' show CupertinoApp; //Main TabView Widget part 'persistent-tab-view.widget.dart'; @@ -13,7 +12,7 @@ part 'persistent-tab-view.widget.dart'; //Models part 'models/persistent-nav-bar-scaffold.widget.dart'; part 'models/persistent-bottom-nav-bar.widget.dart'; -part 'models/persisten-bottom-nav-item.widget.dart'; +part 'models/persistent-bottom-nav-item.widget.dart'; part 'models/persistent-bottom-nav-bar-styles.widget.dart'; part 'models/neumorphic-properties.widget.dart'; part 'models/tab-view.widget.dart'; @@ -30,7 +29,7 @@ part 'utils/navigator-functions.utils.dart'; //Animations part 'animations/animations.dart'; -//Neuomorphic-Card +//Neumorphic-Card part 'neumorphic-package-by-serge-software/neumorphic-card.dart'; //Styles diff --git a/lib/persistent-tab-view.widget.dart b/lib/persistent-tab-view.widget.dart index 9b359c62..8decf6ef 100644 --- a/lib/persistent-tab-view.widget.dart +++ b/lib/persistent-tab-view.widget.dart @@ -58,7 +58,7 @@ class PersistentTabView extends PersistentTabViewBase { final bool hideNavigationBarWhenKeyboardShows; - ///Hides the navigation bar with an transition animation. Use it in conjuction with [Provider](https://pub.dev/packages/provider) for better results. + ///Hides the navigation bar with an transition animation. Use it in conjunction with [Provider](https://pub.dev/packages/provider) for better results. final bool? hideNavigationBar; final BuildContext context; @@ -72,6 +72,7 @@ class PersistentTabView extends PersistentTabViewBase { this.margin = EdgeInsets.zero, this.backgroundColor = CupertinoColors.white, ValueChanged? onItemSelected, + bool manuallyHandelPageChange = false, NeumorphicProperties? neumorphicProperties, this.floatingActionButton, NavBarPadding padding = const NavBarPadding.all(null), @@ -108,6 +109,7 @@ class PersistentTabView extends PersistentTabViewBase { navBarHeight: navBarHeight, backgroundColor: backgroundColor, onItemSelected: onItemSelected, + manuallyHandelPageChange: manuallyHandelPageChange, neumorphicProperties: neumorphicProperties, floatingActionButton: floatingActionButton, resizeToAvoidBottomInset: resizeToAvoidBottomInset, @@ -128,6 +130,10 @@ class PersistentTabView extends PersistentTabViewBase { "screens and items length should be same. If you are using the onPressed callback function of 'PersistentBottomNavBarItem', enter a dummy screen like Container() in its place in the screens"); assert(items!.length >= 2 && items.length <= 6, "NavBar should have at least 2 or maximum 6 items (Except for styles 15-18)"); + assert( + (manuallyHandelPageChange && onItemSelected != null) || + !manuallyHandelPageChange, + "You have to provide onItemSelected callback when yuo set manuallyHandelPageChange to be true"); } PersistentTabView.custom( @@ -144,8 +150,8 @@ class PersistentTabView extends PersistentTabViewBase { this.selectedTabScreenContext, this.hideNavigationBarWhenKeyboardShows = true, this.backgroundColor = CupertinoColors.white, - CutsomWidgetRouteAndNavigatorSettings routeAndNavigatorSettings = - const CutsomWidgetRouteAndNavigatorSettings(), + CustomWidgetRouteAndNavigatorSettings routeAndNavigatorSettings = + const CustomWidgetRouteAndNavigatorSettings(), this.confineInSafeArea = true, this.onWillPop, this.stateManagement = true, @@ -201,6 +207,9 @@ class PersistentTabViewBase extends StatefulWidget { ///Callback when page or tab change is detected. final ValueChanged? onItemSelected; + ///Disables the automatic page change done before `onItemSelected` is called, You will handel the page change manually inside `onItemSelected`. + final bool? manuallyHandelPageChange; + ///Specifies the curve properties of the NavBar. final NavBarDecoration? decoration; @@ -270,13 +279,13 @@ class PersistentTabViewBase extends StatefulWidget { ///This controls the animation properties of the items of the NavBar. final ItemAnimationProperties? itemAnimationProperties; - ///Hides the navigation bar with an transition animation. Use it in conjuction with [Provider](https://pub.dev/packages/provider) for better results. + ///Hides the navigation bar with an transition animation. Use it in conjunction with [Provider](https://pub.dev/packages/provider) for better results. final bool? hideNavigationBar; ///Define navigation bar route name and settings here. /// ///If you want to programmatically pop to initial screen on a specific use this route name when popping. - final CutsomWidgetRouteAndNavigatorSettings? routeAndNavigatorSettings; + final CustomWidgetRouteAndNavigatorSettings? routeAndNavigatorSettings; final bool? isCustomWidget; @@ -301,6 +310,7 @@ class PersistentTabViewBase extends StatefulWidget { this.items, this.backgroundColor, this.onItemSelected, + this.manuallyHandelPageChange, this.decoration, this.padding, this.navBarStyle, @@ -593,14 +603,16 @@ class _PersistentTabViewState extends State { widget.popAllScreensOnTapOfSelectedTab ?? true, onItemSelected: widget.onItemSelected != null ? (int index) { - if (_controller!.index != _previousIndex) { - _previousIndex = _controller!.index; - } - if ((widget.popAllScreensOnTapOfSelectedTab ?? true) && - _previousIndex == index) { - popAllScreens(); + if (!widget.manuallyHandelPageChange!) { + if (_controller!.index != _previousIndex) { + _previousIndex = _controller!.index; + } + if ((widget.popAllScreensOnTapOfSelectedTab ?? true) && + _previousIndex == index) { + popAllScreens(); + } + _controller!.index = index; } - _controller!.index = index; widget.onItemSelected!(index); } : (int index) {