Coder Social home page Coder Social logo

Comments (3)

maheshmnj avatar maheshmnj commented on August 20, 2024

Hi, @tushar4303, Thanks for filing the issue. I think this is the same issue as #6 I need to reinvestigate how fade transition works. Meanwhile please follow up on that issue, I know it has been quite a while since it hasn't been solved. I will try my best to solve it within a week.

Closing as duplicate of the linked issue. Incase you disagree, please feel free to write in the comments and I would be happy to rereview.

from navbar_router.

tushar4303 avatar tushar4303 commented on August 20, 2024

Certainly! Here's a reply you can use:

Hi @maheshmnj ,

Thank you for your prompt response and for linking the related issue #6. I'll keep an eye on that to stay updated on the progress.

In the meantime, I'll explore using the AnimatedSwitcher as suggested in the mentioned issue. Additionally, I have a question regarding implementing a feature in v0.3.3. I'm using four main pages as the base route, and subpages inside them are pushed using navigator.pushNamed. I want the back button behavior to navigate back to the home page when pressed on any of the four pages (similar to Instagram), and on a double tap on the home page, I should exit the app.

I tried the code from the documentation, but it didn't work as expected. Could you please provide guidance or share a code snippet for achieving this behavior?

Thanks again for your assistance!

from navbar_router.

maheshmnj avatar maheshmnj commented on August 20, 2024

@tushar4303 to pop to base route from a deeply nested route from any tab you just have to pass shouldPopToBaseRoute: true to navbar_router (true by default) so you don't have to explicitly do anything to achieve that behavior.

for handling the double press backbutton to exit you have to implement your custom logic in onBackButtonPressed

onBackButtonPressed: A function which defines whether it is the root Navigator or not. if the method returns true then the Navigator is at the base of the navigator stack

Heres the implementation from the example app

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

 onBackButtonPressed: (isExitingApp) {
          if (isExitingApp) {
            newTime = DateTime.now();
           // time difference between consecutive taps
            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;
          }
        },

You can see both of those features in action by running the example app. Let me know if any of that doesn't work as intended.

from navbar_router.

Related Issues (20)

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.