Implemented Navigation to these screens:

- Home
- Scene
- Smart
- profile

Converted to state based Provider
This commit is contained in:
Mohammad Salameh
2024-02-14 15:49:06 +03:00
parent 3f1f8e72b3
commit 4d8a2655e1
22 changed files with 146 additions and 116 deletions
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:syncrow_app/features/home/provider/provider.dart';
import '../home/home_provider.dart';
class DefaultNavBar extends StatelessWidget {
const DefaultNavBar({
@@ -9,50 +10,21 @@ class DefaultNavBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (BuildContext context) => HomeProvider(),
child: BottomNavigationBar(
onTap: (int index) {
context.read<HomeProvider>().updatePageIndex(index, context);
},
currentIndex: context.watch<HomeProvider>().pageIndex,
selectedIconTheme: const IconThemeData(
color: Colors.black,
),
selectedLabelStyle: const TextStyle(
color: Colors.black,
),
items: const [
BottomNavigationBarItem(
icon: Icon(
Icons.home_outlined,
color: Colors.grey,
),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(
Icons.view_in_ar,
color: Colors.grey,
),
label: 'Scene',
),
BottomNavigationBarItem(
icon: Icon(
Icons.smart_toy_outlined,
color: Colors.grey,
),
label: 'Smart',
),
BottomNavigationBarItem(
icon: Icon(
Icons.account_circle,
color: Colors.grey,
),
label: 'Account',
),
],
),
return Consumer<HomeProvider>(
builder: (context, provider, child) {
return BottomNavigationBar(
onTap: (int index) => provider.updatePageIndex(index, context),
currentIndex: HomeProvider.pageIndex,
selectedItemColor: Colors.black,
unselectedItemColor: Colors.grey,
elevation: 10,
items: provider.bottomNavItems,
);
},
);
}
}
class DefaultBottomNavBarItem extends BottomNavigationBarItem {
DefaultBottomNavBarItem({required super.icon});
}