Coder Social home page Coder Social logo

maheshmnj / navbar_router Goto Github PK

View Code? Open in Web Editor NEW
29.0 4.0 5.0 42.96 MB

A Navbar widget for advanced usecases to improve user experience and save your time.

Home Page: https://docs.maheshjamdade.com/navbar_router/

License: MIT License

Kotlin 0.02% Swift 0.26% Objective-C 0.01% Dart 29.25% CMake 2.53% C++ 2.96% C 0.20% HTML 61.40% Ruby 0.38% CSS 3.01%
bottomnavigationbar flutter hacktoberfest package widget

navbar_router's Introduction

navbar_router v0.7.4

Flutter Platform Badge Pub codecov Build MIT License Badge

Floating Navbar

Checkout our extensive docs to learn more about this package, the inspiration behind it and how to use it.

Adding a BottomNavigationBar to your app?

NavbarRouter is a complete package to handle all your BottomNavigationBar needs. It provides a simplest api to achieve the advanced features of BottomNavigationBar making the user experience of your app much better. You only need to specify the NavbarItems and the routes for each NavbarItem and NavbarRouter will take care of the rest.

Most of the features which this package provides are mainly to improve the user experience by handling the smallest things possible.

See the demo app here

Key Features

  • Choose between different NavigationBar types.
  • Remembers navigation history of Navbar (Android).
  • Persist Navbar when pushing routes
  • Support for nested navigation.
  • Intercept back button press to handle app exits (Android).
  • Fade smoothly between NavbarDestinations
  • show different icons for selected and unselected NavbarItems.
  • Consistent API for all types of Navbar.
  • Programmatically control state of bottom navbar from any part of widget tree e.g change index, hide/show bottom navbar,push/pop routes of a specific tab etc
  • Show Snackbar messages on top of Navbar with a single line of code.
  • persist state across bottom navbar tabs.
  • Jump to base route from a deep nested route with a single tap(same as instagram).
  • Adapatable to different device Sizes.
  • Supports badges on the NavbarItems.

Supports mulitple NavbarTypes

You can choose between different NavbarTypes using the NavbarDecoration.navbarType property. This allows you to choose between the default NavbarType.standard and NavbarType.notched NavbarTypes.

NavbarType.standard (default) NavbarType.notched
Standard Navbar Notched Navbar
NavbarType.material3 NavbarType.floating
Material3 Navbar Floating Navbar

Heres a sample app built using this package to see how it works.

video demo of the sample app

navbar_route demo

This package will help you save atleast 50% lines of code in half the time required to implement the above features. Heres the same sample app without the package which requires around 800 lines of code.

Installation

Run from the root of your flutter project.

  flutter pub add navbar_router

Example

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);

  List<NavbarItem> items = [
    NavbarItem(Icons.home_outlined, 'Home',
        backgroundColor: mediumPurple,
        selectedIcon: Icon(
          Icons.home,
          size: 26,
        )),
    NavbarItem(Icons.shopping_bag_outlined, 'Products',
        backgroundColor: Colors.orange,
        selectedIcon: Icon(
          Icons.shopping_bag,
          size: 26,
        )),
    NavbarItem(Icons.person_outline, 'Me',
        backgroundColor: Colors.teal,
        selectedIcon: Icon(
          Icons.person,
          size: 26,
        )),
  ];

  final Map<int, Map<String, Widget>> _routes = const {
    0: {
      '/': HomeFeeds(),
      FeedDetail.route: FeedDetail(),
    },
    1: {
      '/': ProductList(),
      ProductDetail.route: ProductDetail(),
    },
    2: {
      '/': UserProfile(),
      ProfileEdit.route: ProfileEdit(),
    },
  };

  @override
  Widget build(BuildContext context) {
    return NavbarRouter(
      errorBuilder: (context) {
        return const Center(child: Text('Error 404'));
      },
      onBackButtonPressed: (isExiting) {
        return isExiting;
      },
      destinationAnimationCurve: Curves.fastOutSlowIn,
      destinationAnimationDuration: 600,
      decoration:
          NavbarDecoration(navbarType: BottomNavigationBarType.shifting),
      destinations: [
        for (int i = 0; i < items.length; i++)
          DestinationRouter(
            navbarItem: items[i],
            destinations: [
              for (int j = 0; j < _routes[i]!.keys.length; j++)
                Destination(
                  route: _routes[i]!.keys.elementAt(j),
                  widget: _routes[i]!.values.elementAt(j),
                ),
            ],
            initialRoute: _routes[i]!.keys.first,
          ),
      ],
    );
  }
}

Features Breakdown

Remembers NavigationBar history (for Android Devices)

When the selected NavbarItem is at the root of the navigation stack, pressing the Back button (On Android) will by default trigger app exit.

For instance:

Your app has three tabs and you navigate from Tab1 -> Tab2 -> Tab3

  • BackButtonBehavior.exit (default) when you press Back Button (on Tab3) your app will exit

  • BackButtonBehavior.rememberHistory, This will switch the navbar current index to the last selected NavbarItem (Tab 2) from the navbarHistory.

You can read more about this feature here.

Fading between NavbarDestinations

You can have smooth Transitions between NavbarDestinations by setting the destinationAnimationCurve and destinationAnimationDuration properties.

defaults to

  destinationAnimationCurve: Curves.fastOutSlowIn,
  destinationAnimationDuration: 300,

Hide or show bottomNavigationBar

You can hide or show bottom navigationBar with a single line of code from anywhere in the widget tree. This allows you to handle useCases like scroll down to hide the navbar or hide the navbar on opening the drawer.

 NavbarNotifier.hideBottomNavBar = true;
Hide/show navbar on scroll Hide/show navbar on drawer open/close Consistent behavior across all Navbars
ezgif com-video-to-gif

Show Snackbar

You can show a snackbar on top of the navbar by using the NavbarNotifier.showSnackBar method.

snackbar

NavbarNotifier.showSnackBar(
  context,
  "This is shown on top of the Floating Action Button",
  /// offset from bottom of the screen
  bottom: state.hasFloatingActionButton ? 0 : kNavbarHeight,
);

And hide it using the NavbarNotifier.hideSnackBar method.

NavbarNotifier.hideSnackBar(context);

Intercept BackButton press events (Android)

navbar_router provides a onBackButtonPressed callback to intercept events from android back button, giving you the ability to handle app exits so as to prevent abrupt app exits without users consent. (or you might want to implement double press back button to exit). This callback method must return true to exit the app and false other wise.

sample code implementing double press back button to exit

onBackButtonPressed: (isExitingApp) {
  if (isExitingApp) {
    newTime = DateTime.now();
    int difference = newTime.difference(oldTime).inMilliseconds;
    oldTime = newTime;
    if (difference < 1000) {
      hideSnackBar();
      return isExitingApp;
    } else {
      showSnackBar();
      return false;
    }
  } else {
    return isExitingApp;
    }
  },

Adds Support for Animated Navbar Badges

image

ScreenRecording2024-04-24at09 32 06-ezgif com-crop

NavbarItem(Icons.home_outlined, 'Home',
      backgroundColor: colors[0],
      selectedIcon: const Icon(
        Icons.home,
        size: 26,
      ),
      badge: const NavbarBadge(
        badgeText: "11",
        showBadge: true,
      )),
  • Show or hide the badge using the NavbarNotifier.makeBadgeVisible and update using NavbarNotifier.updateBadge method from any part of the tree.

Adapatable to different device Sizes

 NavbarRouter(
   errorBuilder: (context) {
     return const Center(child: Text('Error 404'));
   },
   isDesktop: size.width > 600 ? true : false,
   decoration: NavbarDecoration(
     isExtended: size.width > 800 ? true : false,
     navbarType: BottomNavigationBarType.shifting),
   ...
   ...
);

For detailed description of all the features and properties please visit the documentation

Curious how the navbar_router works?

Read more in a medium blog post for detailed explanation.

Youtube: Heres a discussion I had with Allen Wyma from Flying high with Fluter regarding this package.

Contribution

Contributions are welcome! for more details on how to contribute, please see the contributing guide

navbar_router's People

Contributors

bebaoboy avatar imgbotapp avatar maheshmnj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

navbar_router's Issues

Use type `Widget` instead of `IconData` for class `NavbarItem`

Is your feature request related to a problem? Please describe.
Use of iconData restricts user to provide 1 icon, however, in its uses at NavigationRailDestination and BottomNavigationBarItem, it can accept Widget data type.

Describe the solution you'd like
Using Widget data type instead.

Navbar should be able to add/remove tabs dynamically.

Usecase
Assume that a navbar has notifications tab, and the notifications tab needs to be shown only for loggedIn users and hidden for other users. In such cases we should be able to add or remove a tab conditionally.

[Proposal] Improve the docs

This issue tracks a request to improve the documentation for this package. This issue will be marked as closed when all the below conditions are met.

  • Publish docs using docs.page
  • Include examples for different use cases.
  • Keep readme.md clear and concise.
  • Add a link to detailed documentation in the readme.md.
  • Update the medium blogpost as per the current state of the package.
  • Add a showcase section showing the apps that use NavbarRouter.
  • Add a link to edit the docs

Improve the Demo app

The example app should be rebuilt to showCase the capabilities of NavbarRouter.

  • Build a simple expenses Management app
  • App works completely offline
  • Set up github actions for CD on netlfiy
  • Add Links to Repo and Docs

Unexpected Blackout Transition Animation in NavBarRouter

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
Switch between pages

Expected behavior
Smooth and subtle transition between routes without any blackout animation.

Screenshots

Screenrecorder-2023-11-29-14-44-29-217.online-video-cutter.com.mp4

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: Redmi note 13
  • OS: Android 13

Additional info:
Each of the four main routes has a separate scaffold with an app bar and body. Additionally, I couldn't reproduce the snackbar functionality when exiting the app to prompt before closing. Currently, my app closes directly without displaying any snackbar.

here's the main.dart file:

// ignore_for_file: public_member_api_docs, sort_constructors_first
// ignore_for_file: camel_case_types
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'dart:async';
import 'package:navbar_router/navbar_router.dart';
import 'package:cluedin_app/screens/Events/events.dart';
import 'package:cluedin_app/screens/homescreen.dart';
import 'package:cluedin_app/screens/login_page.dart';
import 'package:cluedin_app/screens/Notifications/notification_page.dart';
import 'package:cluedin_app/screens/Profile/profile.dart';
import 'package:cluedin_app/widgets/themes.dart';

import 'firebase_options.dart';
import 'utils/globals.dart';

Future<void> backgroundHandler(RemoteMessage message) async {
 if (message.notification != null) {
   // Show a notification and handle tap events
   print("handling a background notification");
 }
}

// FlutterLocalNotificationsPlugin notificationsPlugin =
//     FlutterLocalNotificationsPlugin();

void main() async {
 SystemChrome.setPreferredOrientations([
   DeviceOrientation.portraitUp,
   DeviceOrientation.portraitDown,
 ]);
 WidgetsFlutterBinding.ensureInitialized();
 await Firebase.initializeApp(
   name: "CluedIn",
   options: DefaultFirebaseOptions.currentPlatform,
 );
 await Hive.initFlutter();
 await Hive.openBox('userBox');

 bool isLoggedIn = Hive.box('userBox').get('isLoggedIn', defaultValue: false);

 FirebaseMessaging.onBackgroundMessage(backgroundHandler);
 runApp(myApp(isLoggedIn: isLoggedIn));
}

class myApp extends StatelessWidget {
 final bool isLoggedIn;
 myApp({
   Key? key,
   required this.isLoggedIn,
 }) : super(key: key);
 final GlobalKey<NavigatorState> navigatorKey =
     GlobalKey(debugLabel: "Main Navigator"); //

 @override
 Widget build(BuildContext context) {
   return MaterialApp(
       navigatorKey: navigatorKey,
       scaffoldMessengerKey: snackbarKey,
       themeMode: ThemeMode.light,
       debugShowCheckedModeBanner: false,
       theme: MyTheme.lightTheme(context),
       darkTheme: MyTheme.darkTheme(context),
       // home: HomePage(),
       // home: MyPhone(),
       home: isLoggedIn ? HomePage() : LoginPage()
       // initialRoute: isLoggedIn ? HomePage() : LoginPage();
       );
 }
}

class HomePage extends StatelessWidget {
 HomePage({Key? key}) : super(key: key);

 List<NavbarItem> items = [
   NavbarItem(
     Icons.home,
     'Home',
   ),
   NavbarItem(
     Icons.notifications,
     'Notifications',
   ),
   NavbarItem(Icons.explore, 'Explore'),
   NavbarItem(Icons.person, 'Profile'),
 ];

 final Map<int, Map<String, Widget>> _routes = {
   0: {
     '/': HomeScreen(),
   },
   1: {
     '/': NotificationPage(),
   },
   2: {
     '/': MyEvents(),
   },
   3: {
     '/': MyProfile(),
   },
 };

 DateTime oldTime = DateTime.now();
 DateTime newTime = DateTime.now();

 @override
 Widget build(BuildContext context) {
   return NavbarRouter(
     errorBuilder: (context) {
       return const Center(child: Text('Error 404'));
     },
     onBackButtonPressed: (isExitingApp) {
       if (isExitingApp) {
         newTime = DateTime.now();
         int difference = newTime.difference(oldTime).inMilliseconds;
         oldTime = newTime;
         if (difference < 1000) {
           NavbarNotifier.hideSnackBar(context);
           return isExitingApp;
         } else {
           final state = Scaffold.of(context);
           NavbarNotifier.showSnackBar(
             context,
             "Tap back button again to exit",
             bottom: state.hasFloatingActionButton ? 0 : kNavbarHeight,
           );
           return false;
         }
       } else {
         return isExitingApp;
       }
     },
     destinationAnimationCurve: Curves.fastOutSlowIn,
     destinationAnimationDuration: 600,
     decoration: NavbarDecoration(
         backgroundColor: const Color.fromRGBO(251, 251, 252, 1),
         selectedIconTheme: const IconThemeData(color: Colors.black),
         navbarType: BottomNavigationBarType.fixed,
         // elevation: 18,
         selectedLabelTextStyle: const TextStyle(color: Colors.black),
         enableFeedback: true),
     destinations: [
       for (int i = 0; i < items.length; i++)
         DestinationRouter(
           navbarItem: items[i],
           destinations: [
             for (int j = 0; j < _routes[i]!.keys.length; j++)
               Destination(
                 route: _routes[i]!.keys.elementAt(j),
                 widget: _routes[i]!.values.elementAt(j),
               ),
           ],
           // initialRoute: _routes[i]!.keys.first,
         ),
     ],
   );
 }
}

// ignore_for_file: prefer_const_constructors

Link to my project repo:
https://github.com/tushar4303/CluedIn-Flutter

Link to individual four pages:
https://github.com/tushar4303/CluedIn-Flutter/blob/main/lib/screens/homescreen.dart
https://github.com/tushar4303/CluedIn-Flutter/blob/main/lib/screens/Notifications/notification_page.dart
https://github.com/tushar4303/CluedIn-Flutter/blob/main/lib/screens/Profile/profile.dart
https://github.com/tushar4303/CluedIn-Flutter/blob/main/lib/screens/Events/events.dart

Update new NavigationRail APIs

Is your feature request related to a problem? Please describe.
As Flutter goes beyond mobile and the mobile manufacturers are building devices of different form factors curved, foldable and dual display devices, The viewport size is highly dynamic.

Describe the solution you'd like
Integrate Drawer with a configurable breakpoint to switch from navbar or Just make the existing NavigationRail Expandable along with all the new APIs

Navbar Height is too much on Android and IOS

Describe the bug
Investigate the bottom nav bar height in material specs

To Reproduce
Steps to reproduce the behavior:

  1. Run the example app on an Android
  2. check the navbar height

Expected behavior
Height should match the standard material guidelines

Screenshots

Pixel 7 Xiaomi k20 pro
flutter_03 flutter_01

Support for custom NavigationBar

This issue is similar to #8

Is your feature request related to a problem? Please describe.

Although NavbarRouter adds support for different NavigationBars going forward, users have different design specs for their apps which prevents them from using this package. We should Add support for a custom NavigationBar which users should implement from NavbarBase and pass to NavbarRouter this will allow users to add their own NavigationBar and yet use all the features of this package.

Describe the solution you'd like
Perhaps we should add a NavbarRouter.custom constructor which also takes in NavBarBase as a parameter to support this request.

Snackbar does not show up in example app

Describe the bug

This piece of code in example app does not work

NavbarNotifier.showSnackBar(
                context,
                "Tap back button again to exit",
                bottom: state.hasFloatingActionButton ? 0 : kNavbarHeight,
              );

Add horizontal Swipe gesture to change tabs

Is your feature request related to a problem? Please describe.
Add a horizontal Swipe Gesture to change the tabs, This should be configurable with a swippable parameter, We should also investigate if this does not interfere when the UI contains a horizontal scrollable or a draggable widget

Additional context
Add any other context or screenshots about the feature request here.

WillPopScope' is deprecated and shouldn't be used. Use PopScope instead.

mahesh@Maheshs-MacBook-Air-M1-3 navbar_router % flutter analyze
Analyzing navbar_router...                                              

   info • 'WillPopScope' is deprecated and shouldn't be used. Use PopScope instead. This feature was deprecated after v3.12.0-1.0.pre •
          lib/src/navbar_router.dart:341:12 • deprecated_member_use
   info • 'WillPopScope.new' is deprecated and shouldn't be used. Use PopScope instead. This feature was deprecated after v3.12.0-1.0.pre •
          lib/src/navbar_router.dart:341:12 • deprecated_member_use

Expected behavior
No warnings

Screenshots

Additional context

https://docs.flutter.dev/release/breaking-changes/android-predictive-back

Pass arguments to widgets when Navigating via named routes

Figure out a way to pass arguments received in onGenerateRoute to respective widget

 onGeneratedRoute: (RouteSettings settings) {
      print(settings.arguments);
      WidgetBuilder? builder = widget.errorBuilder;
      final nestedLength = widget.destinations[i].length;
       for (int j = 0; j < nestedLength; j++) {
           if (widget.destinations[i][j].path == settings.name) {
                builder = (BuildContext _) => widget.destinations[i][j].widget;
           }
       }
         return MaterialPageRoute(
             builder: builder!, settings: settings);
 }),

I am facing a weird issue, and not sure if its a bug related to state

Describe the bug
When i switch pages some of the options from page 1 gets shown in page 2, or sometimes all the options are replaced with options in page 1 and vice versa and it gets back to normal when i refresh the page.

Earlier i thought this must have been a problem with the data source (json get in this case) but since this is only happening partially, i.e only the options or sometimes the cards itself and even half of the options when are actually hardcoded into ui is displayed in different page.

So i couldn't exactly figure out what exactly the issue was

To Reproduce
Steps to reproduce the behavior:

  1. Open the app
  2. Change screens
  3. Go back to a different screen (happens occasionally)
  4. Or close the app and relaunch it from recent apps (from memory) and on refresh everything gets back to normal

Expected behavior
Options and the posts to be displayed on their respective page, but somehow it gets mixed in this case

Screenshots

This is the correct layout of notifications

But in this case its listing options from events page (technical, sports, cultural)

This is the actual layout of events page

But in this case, the first option (hard coded on which is supposed to show when i tap technical) shows up but rest of the options are from notifications page

The same happens with posts too sometimes

Desktop:

  • OS: windows 11
  • Browser Edge

Smartphone:

  • Device: Redmi note 11
  • OS: Android 12

Additional context
I tried rebuilding, flutter clean etc but this issue persists.

Stacking a widget on top of an existing navigation stack with the wrong navbar item highlighted

Describe the bug
When the notifications are sent from Firebase fcm, the tap event of the notification is expected to navigate to the notification page. That is happening correctly, however the navbar item that is being highlighted is not in accordance with the widget being shown since the notification page is shown on top of the homepage and requires a double tap to go back to the homepage, which is actually correct for how this package should behave. However, my application has 4 screens: home, notification, explore, and profile, where the 1st screen is home followed by notification, but on tapping homepage, the notification page is displayed with homepage being highlighted. So is there a solution wherein on tapping the notification, the second navbar item is highlighted, i.e., the notifications page?

To Reproduce
Steps to reproduce the behavior:

  1. click on the notification
  2. the app opens with homepage being replaced with notification while the homepage navbar icon is highlighted
  3. double tap on homeicon to go back to homepage

Expected behavior
Not exactly expected, since this is actually how this package intends to work however iIrequest you to please provide a workaround or a solution to my problem if possible.

Screen recording

WhatsApp.Video.2023-03-10.at.00.27.17.mp4

Desktop (please complete the following information):

  • OS: Windows 11

  • Browser Microsoft Edge

  • Device: Redmi note 11

  • OS: android 12

is there an approach where when i tap on the notification i go to notification page with the same icon being highlighted?

btw here is the code:

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        navigatorKey: navigatorKey,
        scaffoldMessengerKey: snackbarKey,
        themeMode: ThemeMode.light,
        debugShowCheckedModeBanner: false,
        theme: MyTheme.lightTheme(context),
        darkTheme: MyTheme.darkTheme(context),
        // home: HomePage(),
        // home: MyPhone(),
        home: isLoggedIn ? HomePage() : LoginPage()
        // initialRoute: isLoggedIn ? HomePage() : LoginPage();
        );
  }
}

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);

  List<NavbarItem> items = [
    NavbarItem(
      Icons.home,
      'Home',
    ),
    NavbarItem(
      Icons.notifications,
      'Notifications',
    ),
    NavbarItem(Icons.explore, 'Explore'),
    NavbarItem(Icons.person, 'Profile'),
  ];

  final Map<int, Map<String, Widget>> _routes = {
    0: {
      '/': HomeScreen(),
    },
    1: {
      '/': NotificationPage(),
    },
    2: {
      '/': MyEvents(),
    },
    3: {
      '/': MyProfile(),
    },
  };

  @override
  Widget build(BuildContext context) {
    return NavbarRouter(
      errorBuilder: (context) {
        return const Center(child: Text('Error 404'));
      },
      onBackButtonPressed: (isExiting) {
        return isExiting;
      },
      destinationAnimationCurve: Curves.fastOutSlowIn,
      destinationAnimationDuration: 700,
      decoration: NavbarDecoration(
          backgroundColor: const Color.fromRGBO(251, 251, 252, 1),
          selectedIconTheme: const IconThemeData(color: Colors.black),
          navbarType: BottomNavigationBarType.fixed,
          elevation: 18,
          selectedLabelTextStyle: const TextStyle(color: Colors.black),
          enableFeedback: true),
      destinations: [
        for (int i = 0; i < items.length; i++)
          DestinationRouter(
            navbarItem: items[i],
            destinations: [
              for (int j = 0; j < _routes[i]!.keys.length; j++)
                Destination(
                  route: _routes[i]!.keys.elementAt(j),
                  widget: _routes[i]!.values.elementAt(j),
                ),
            ],
            // initialRoute: _routes[i]!.keys.first,
          ),
      ],
    );
  }
}

// ignore_for_file: prefer_const_constructors`

and the part to push notificationpage to the stack:

FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
      if (message.notification != null) {
        print('idhar: click hua');
        // Notifications notification = Notifications.fromMap(message.data);
        print(message.data);

        Navigator.of(context).push(
          MaterialPageRoute(builder: (context) => const NotificationPage()),
        );
      }
    });

Investigate offstage widgets

Describe the bug
Widgets that are offstage (not in view) should not gain in pointer or focus, One way to fix this is by using ignorePointer for !currentindex.

Also when the focus is regained the state should remain unchanged.

Refactor NavbarNotifier apis

Describe the bug

Some of the methods of NavbarNotifier are not required to be exposed to client
e.g Don't expose onBackButtonPressed

  • Don't expose NavbarNotifier properties to outside world
  • Add a method to programmatically push a route in any index of navbar

Support different NavigationBars to choose from

Hello and thank you for this great package full of highly requested features.

For most modern apps one would need a custom BottomNavigationBar that would cater to his/her needs, unfortunately navbar_router doesn't support different navbar types for example let's say I wanna use this BottomNavigationBar from this package : https://pub.dev/packages/circular_bottom_navigation , it's currently impossible since navbar_router tries to build upon the default BottomNavigationBar which is quite limited , so maybe you would consider adding the ability to pass the whole BottomNavigationBar widget as parameter instead of a set of decoration parameters in order to lift this limitation ?

Something like what this package provides would be awesome; https://pub.dev/packages/bottom_nav_layout#different-bottom-bars

For a better navigation/experience you might wanna consider adding some sort of visited tabs history in order to manage back button navigation for Android, apps like instagram,netflix ... handle the navigation history by keeping track of the order in which the user visits different tabs such a feature would be a perfect addition to your package, for inspiration take a look at the solution implemented in this one : ttps://pub.dev/packages/bottom_nav_layout#page-back-stack

Support for badges on the NavbarItem

Is your feature request related to a problem? Please describe.
Users would like to show a notification badge on a NavbarItem

Describe the solution you'd like
NavbarItem should have a property to show a red dot on top

Elevation doesn't work on the NavBarDecoration

The background behind the navigation bar and the bottom nav bar are both white in my UI, which makes it really hard to notice the navbar's starting point and the elevation doesn't seem to work in order to add the shadow to the navbar

Steps to reproduce the behavior:

  1. Changing value on the elevation property doesn't make ui shadow show up

Expected behavior
A shadow should have appeared at the top of the NavBar

Screenshots

Smartphone (please complete the following information):

  • Device: [Redmi Note 11]
  • OS: [Android ]
  • Version [12]

Can we have linkbased routing / deep linking and routeguard as a feature in the upcoming version?

I am working on an app for my college where I want to pass url parameters in Notification Details route let's say the messageID, and i did try a few other options like auto route but they didn't have much flexibility in having different scaffolds for different pages with persistent bottom navigation bar which made me switch to this package.

In my case I wish to send user to that particular notification with all the details on the on_click event which i guess would be possible with url parameters where i can pass the individual message id in the payload like notifications/notificationDetails:messageId, please correct me if I am wrong.
Also, it would be really grateful if you can point me to the right resource as I am still new to flutter and have a lot more to explore

As I already mentioned, I have tried go router and auto route but find them a bit complex when i wanted to have a different scaffold and persistent bottom navbar.

Also, route guard feature would be a great addition too.

[Android] Remember route history

copied from #8

For a better navigation/experience you might wanna consider adding some sort of visited tabs history in order to manage back button navigation for Android, apps like instagram,netflix ... handle the navigation history by keeping track of the order in which the user visits different tabs such a feature would be a perfect addition to your package, for inspiration take a look at the solution implemented in this one : ttps://pub.dev/packages/bottom_nav_layout#page-back-stack

Showcase your beautiful app on Navbar Router docs

navbar_router was built to make it easy to add navigation bars capability along with the ability to achieve complex features that help streamline a great user experience with minimal code. In an effort to showcase the power of navbar_router and hear what developers have to say we have launched a navbar_router showcase page where you can showcase your beautiful app to navbar_router community.

If you are an Indie App Developer or a Company using navbar_router and want to showcase your Beautiful App, Please consider dropping your app details so that we can add it to the navbar_router docs.

To Reproduce
Your entry should have a following format

  1. Your App/brand cover image
  2. Playstore/AppStore Url
  3. Web app/Website Url (Optional)
  4. Your thoughts on navbar_router (Optional)

Note: Generally your entry will be published on showcase within 24 hours. If it takes longer than the estimated time, Please do not hesitate to ping me @maheshmnj on this thread.

didUpdateWidget() does not take into account changes in navbar items

Describe the bug
When the NavBarRouter object is given new items during build process (after a setstate() call for example), _NavbarRouterState does not rebuild its keys and items members, resulting in showing incorrect text.

To Reproduce
In my case, since I implemented a dynamic language change in my whole app, the NavBarRouter ctor in my RootPageState build method is given new text that is ignored.

Expected behavior
NavBarRouter should always reset its items and keys members in didUpdateWidget() without condition to take into account any change in widget items.

I made a "local" fix by commenting a few lines in _NavbarRouterState.didUpdateWidget() (navbar_router.dart) :

void didUpdateWidget(covariant NavbarRouter oldWidget) {
    /// update animation
    if (widget.destinationAnimationCurve !=
            oldWidget.destinationAnimationCurve ||
        widget.destinationAnimationDuration !=
            oldWidget.destinationAnimationDuration) {
      initAnimation();
    }
    // HERE IS THE FIX (no condition for items/keys reset)
    //if (widget.destinations.length != oldWidget.destinations.length ||
    //        widget.type != oldWidget.type) {
          NavbarNotifier.length = widget.destinations.length;
          clearInitialization();
          initialize();
    //}
    super.didUpdateWidget(oldWidget);
  }

Thank you for your work :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.