auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

How to open Drawer programmatically in AutoTabsScaffold ?

Open ntfnd404 opened this issue 3 years ago • 6 comments

How to open Drawer programmatically in AutoTabsScaffold ? like a Scaffold.of(context).openDrawer()

ntfnd404 avatar Jan 24 '22 02:01 ntfnd404

Any updates @ntfnd404 ? I'm trying to use both bottomNavigationBuilder end drawer is there any trick here?

EnesKaraosman avatar Jan 28 '22 18:01 EnesKaraosman

AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold

Milad-Akarie avatar Jan 29 '22 07:01 Milad-Akarie

AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold

Actually my case scenario is like this;

I've AutoTabsScaffold and imagine in bottomNavigation I want to open drawer when nth item is tapped

What I've tried

In router.dart file

children: [
	AutoRoute(..) // other bottomNavigation tabs
	AutoRoute(
	  page: EmptyRouterPage,
	  name: 'DrawerTab',
	  path: RouterPath.drawer, // "drawer"
	  initial: true,
	  children: [
	    AutoRoute(
	      page: CalculatorScreen,
	      name: 'CalculatorScreen',
	      path: RouterPath.calculator,
	    )
	  ]
	)
]

//////
AutoTabsScaffold(
	extendBody: true,
	resizeToAvoidBottomInset: false,
	backgroundColor: Colors.transparent,
	endDrawer: const EndDrawer(),
	routes: const [
	  Tab1(),
	  Tab2(),
	  Tab3(),
	  Tab4(),
	  DrawerTab(),
	],
	bottomNavigationBuilder: (context, tabsRouter) =>
	    BottomBarApp(
	  onTabSelected: (index) {
	    switch (index) {
	      case 4:
	        Scaffold.of(context).openEndDrawer();
	        break;
	      default:
	    }
	    tabsRouter.setActiveIndex(index);
	  },
	  selectedIndex: tabsRouter.activeIndex,
	  color: const Color(0x47150C00),
	  selectedColor: Styleguide.primaryColor,
	  height: Dimension.bottomBarHeight,
	  items: [
	    ...
	  ],
	),
),

So DrawerTab here is actually a placeholder Route to contain pages (routes) exist in drawer,

Case1: If I select drawer tab, child routes is opened in Drawer and works as expected, but since DrawerTab's page is empty, when drawer (and it's related screens dismissed) is closed, there is empty page, so I need to actually stay in the bottom tab that I previously was before DrawerTab is selected.

Case2: If I do not set setActiveIndex for tabsRouter to avoid problem happens in Case1, this time child routes can not be navigated in Drawer (because DrawerTab is not activated)

Sorry for long question, but you have any suggestion? @Milad-Akarie

EnesKaraosman avatar Jan 29 '22 10:01 EnesKaraosman

AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold

@Milad-Akarie I'm sorry, I didn't put it correctly. How do I call '.openDrawer()' on AutoTabsScaffold which is in the root of the nested Scaffold. To open Drawer at the root one and not at the nested one

ntfnd404 avatar Feb 06 '22 11:02 ntfnd404

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar May 06 '22 08:05 github-actions[bot]

AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold

@Milad-Akarie I'm sorry, I didn't put it correctly. How do I call '.openDrawer()' on AutoTabsScaffold which is in the root of the nested Scaffold. To open Drawer at the root one and not at the nested one

@ntfnd404 I know it is late but check this out: https://github.com/Milad-Akarie/auto_route_library/issues/982#issuecomment-1172888706

Ruslanbek0809 avatar Jul 02 '22 13:07 Ruslanbek0809

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Dec 01 '22 08:12 github-actions[bot]