Code Monkey home page Code Monkey logo

Comments (4)

Milad-Akarie avatar Milad-Akarie commented on May 10, 2024

Hey @Bizz first for all, thanks for all the great tuts! keep them coming!
please help me understand what's going on here.
CupertinoTabView is just a wrapper for Navigator, is every tab you in your App a nested navigator?
if yes, are you trying to use the same router for all the nested navigators you have?

Where is this page JobEntriesPage supposed to show?

from auto_route_library.

bizz84 avatar bizz84 commented on May 10, 2024

@Milad-Akarie thank you.
Yes, my goal is to have nested navigators.
For context, this is an implementation of my code that doesn't use auto_route:

class CupertinoTabViewRoutes {
  static const jobEntriesPage = '/job-entries-page';
}
class CupertinoTabViewRouter {
  static Route generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case CupertinoTabViewRoutes.jobEntriesPage:
        final job = settings.arguments;
        return CupertinoPageRoute(
          builder: (_) => JobEntriesPage(job: job),
          settings: settings,
          fullscreenDialog: true,
        );
    }
    return null;
  }
}
class CupertinoHomeScaffold extends StatelessWidget {
  CupertinoHomeScaffold({
    Key key,
    @required this.currentTab,
    @required this.onSelectTab,
    @required this.widgetBuilders,
    @required this.navigatorKeys,
  }) : super(key: key);

  final TabItem currentTab;
  final ValueChanged<TabItem> onSelectTab;
  final Map<TabItem, WidgetBuilder> widgetBuilders;
  final Map<TabItem, GlobalKey<NavigatorState>> navigatorKeys;

  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        key: Key(Keys.tabBar),
        items: [
          _buildItem(TabItem.jobs),
          _buildItem(TabItem.entries),
          _buildItem(TabItem.account),
        ],
        onTap: (index) => onSelectTab(TabItem.values[index]),
      ),
      tabBuilder: (context, index) {
        final item = TabItem.values[index];
        return CupertinoTabView(
          navigatorKey: navigatorKeys[item],
          builder: (context) => widgetBuilders[item](context),
          onGenerateRoute: CupertinoTabViewRouter.generateRoute,
        );
      },
    );
  }

Would it make sense for me to have three ExtendedNavigator<Router>(router: Router())), instead of the current widgetBuilders?

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 10, 2024

@bizz84 Of course it would, like I said CupertinoTabView is just a wrapper for Navigator.

This's how I image your setup to be

 tabBuilder: (context, index) {
        final item = TabItem.values[index];
        return ExtendedNavigator(
          key: navigatorKeys[item]
          router: nestedRouters[item],
        );
      },

also If I understand your code correctly, the builder in CupertinoTabView is just responsible for building you initial page which simply could be your initial route. so you don't actually need the builder

from auto_route_library.

bizz84 avatar bizz84 commented on May 10, 2024

@Milad-Akarie that makes sense. Thanks for the explanation :)

from auto_route_library.

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.