romanejaquez / home_automation_app

32 stars 6 forks source link

Routing detection issue #2

Open rebazjabar opened 3 months ago

rebazjabar commented 3 months ago

Hello Dear when i try click the button to navigate to new Page i use GoRouter.of(Utils.tabNav.currentContext!).go('/rooms'); the function is work it navigate to the route it show the new destination page but the Icon on the BottomBar will not swap to new page it remain on the selected icon , please how to fix that ?

romanejaquez commented 4 weeks ago

hey @rebazjabar so you're trying to perform the navigation away from the navigation bar (i.e. using GoRouter in another context). If you want to navigate to the Rooms Page while at the same time update the bottom bar icon so it changes, you must mark the item as selected in the bottom bar programmatically. I just updated the code and added a new method in the BottomBarViewModel:

markBottomBarItemSelectedByRoute(String route)

So you should do it like this now:

First, navigate to your page:

GoRouter.of(Utils.tabNav.currentContext!).go('/rooms') => you should say also instead go(RoomsPage.route).

Then, update the bottom bar item with the same route:

ref.read(bottomBarVMProvider.notifier).markBottomBarItemSelectedByRoute(RoomsPage.route);

And you should be good to go.

rebazjabar commented 4 weeks ago

i really apriciated you deserve gold medal. i hope you will add localization for this project as soon as posible thanks