Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed page changing from outside & Fixed all the typos #284

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"cSpell.words": [
"Bilal",
"Cherepanov",
"neumorphic",
"Neumorphism",
"Shahid"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions lib/models/persistent-nav-bar-scaffold.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ class _TabSwitchingViewState extends State<_TabSwitchingView>
key = UniqueKey();
}

_initAniamtionControllers();
_initAnimationControllers();
}

_initAniamtionControllers() {
_initAnimationControllers() {
if (widget.screenTransitionAnimation!.animateTabTransition) {
_animationControllers =
List<AnimationController?>.filled(widget.tabCount!, null);
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions lib/models/route-settings.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RouteAndNavigatorSettings {
}
}

class CutsomWidgetRouteAndNavigatorSettings {
class CustomWidgetRouteAndNavigatorSettings {
final String? defaultTitle;

final Map<String, WidgetBuilder>? routes;
Expand All @@ -61,7 +61,7 @@ class CutsomWidgetRouteAndNavigatorSettings {

final List<GlobalKey<NavigatorState>>? navigatorKeys;

const CutsomWidgetRouteAndNavigatorSettings({
const CustomWidgetRouteAndNavigatorSettings({
this.defaultTitle,
this.routes,
this.onGenerateRoute,
Expand All @@ -71,7 +71,7 @@ class CutsomWidgetRouteAndNavigatorSettings {
this.navigatorKeys,
});

CutsomWidgetRouteAndNavigatorSettings copyWith({
CustomWidgetRouteAndNavigatorSettings copyWith({
String? defaultTitle,
Map<String, WidgetBuilder>? routes,
RouteFactory? onGenerateRoute,
Expand All @@ -80,7 +80,7 @@ class CutsomWidgetRouteAndNavigatorSettings {
List<NavigatorObserver>? navigatorObservers,
List<GlobalKey<NavigatorState>>? navigatorKeys,
}) {
return CutsomWidgetRouteAndNavigatorSettings(
return CustomWidgetRouteAndNavigatorSettings(
defaultTitle: defaultTitle ?? this.defaultTitle,
routes: routes ?? this.routes,
onGenerateRoute: onGenerateRoute ?? this.onGenerateRoute,
Expand Down
5 changes: 2 additions & 3 deletions lib/persistent-tab-view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ 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';

//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';
Expand All @@ -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
Expand Down
36 changes: 24 additions & 12 deletions lib/persistent-tab-view.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -72,6 +72,7 @@ class PersistentTabView extends PersistentTabViewBase {
this.margin = EdgeInsets.zero,
this.backgroundColor = CupertinoColors.white,
ValueChanged<int>? onItemSelected,
bool manuallyHandelPageChange = false,
NeumorphicProperties? neumorphicProperties,
this.floatingActionButton,
NavBarPadding padding = const NavBarPadding.all(null),
Expand Down Expand Up @@ -108,6 +109,7 @@ class PersistentTabView extends PersistentTabViewBase {
navBarHeight: navBarHeight,
backgroundColor: backgroundColor,
onItemSelected: onItemSelected,
manuallyHandelPageChange: manuallyHandelPageChange,
neumorphicProperties: neumorphicProperties,
floatingActionButton: floatingActionButton,
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
Expand All @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -201,6 +207,9 @@ class PersistentTabViewBase extends StatefulWidget {
///Callback when page or tab change is detected.
final ValueChanged<int>? 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;

Expand Down Expand Up @@ -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;

Expand All @@ -301,6 +310,7 @@ class PersistentTabViewBase extends StatefulWidget {
this.items,
this.backgroundColor,
this.onItemSelected,
this.manuallyHandelPageChange,
this.decoration,
this.padding,
this.navBarStyle,
Expand Down Expand Up @@ -593,14 +603,16 @@ class _PersistentTabViewState extends State<PersistentTabView> {
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) {
Expand Down