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

when click bottom navigation icon, navigator does not direct push to that screen. #3

Closed
ahmedmirza994 opened this issue Oct 12, 2019 · 10 comments

Comments

@ahmedmirza994
Copy link

`
import 'package:capp/scopped-model/main_model.dart';
import 'package:capp/screens/about_papertale_screen.dart';
import 'package:capp/screens/dashboard_screen.dart';
import 'package:custom_navigator/custom_navigator.dart';
import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
final MainModel model;

HomeScreen({this.model});

@OverRide
_HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State {
GlobalKey navigatorKey = GlobalKey();
int _currentIndex = 0;

@OverRide
Widget build(BuildContext context) {
final tabpages = [
DashboardScreen(
model: widget.model,
),
AboutPaperTaleScreen(
model: widget.model,
),
AboutPaperTaleScreen(
model: widget.model,
),
];
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white,
currentIndex: _currentIndex,
unselectedItemColor: Theme.of(context).primaryColor.withOpacity(0.5),
selectedItemColor: Theme.of(context).primaryColor,
items: _items,
onTap: (index) {
// if (index == 0) {
navigatorKey.currentState.maybePop();
// }
setState(() {
_currentIndex = index;
});
},
),
body: CustomNavigator(
navigatorKey: navigatorKey,
home: tabpages[_currentIndex],
pageRoute: PageRoutes.materialPageRoute,
),
);
}

final _items = [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.info_outline),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
title: Text(''),
),
];
}
`

when click on bottom bar icon, navigator pop the route but i want to direct push to desired screen

@ayham95
Copy link
Owner

ayham95 commented Oct 12, 2019

Can you please elaborate more about what you want to achieve?
Because it’s not quite clear.

@ahmedmirza994
Copy link
Author

Hi, I am using this on three menu items. When I visit multiple views on different menus the icon press is not respective to that (related to icon) view.

ezgif com-video-to-gif
check this, problem at the end of gif,

@ayham95
Copy link
Owner

ayham95 commented Oct 12, 2019

So you want multiple views on each menu item to stay active?

@ahmedmirza994
Copy link
Author

yes

@ahmedmirza994
Copy link
Author

the problem is when i switch one menu item to other menu item, the page under other menu item does not open directly, until it pops the all routes of first menu item

@ayham95
Copy link
Owner

ayham95 commented Oct 12, 2019

Oh, ok ok that’s a valid point.
Are you using CustomScaffold? Or the normal CustomNavigator?

@ahmedmirza994
Copy link
Author

i tried both, but the problem is same.

@ayham95
Copy link
Owner

ayham95 commented Oct 12, 2019

Ok, no problem man. I’ll push a fix right away.

@ahmedmirza994
Copy link
Author

yes please, i am working on production app and the problem need to be fixed as soon as possible

@ayham95
Copy link
Owner

ayham95 commented Oct 19, 2019

Solved! Use CustomScaffold i uploaded v0.3.0

@ayham95 ayham95 closed this as completed Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants