mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 09:47:55 +00:00
Implemented Navigation to these screens:
- Home - Scene - Smart - profile Converted to state based Provider
This commit is contained in:
@@ -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});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user