mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 10:07:55 +00:00
Refactor DefaultNavBar widget build method
Remove unnecessary BlocProvider and DevicesCubit logic from DefaultNavBar widget build method, simplify code structure.
This commit is contained in:
@@ -13,44 +13,37 @@ class DefaultNavBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => DevicesCubit.getInstance(),
|
||||
child: BlocBuilder<DevicesCubit, DevicesState>(
|
||||
builder: (context, state) {
|
||||
return BlocBuilder<HomeCubit, HomeState>(
|
||||
builder: (context, state) {
|
||||
var cubit = HomeCubit.getInstance();
|
||||
return SizedBox(
|
||||
height: Constants.bottomNavBarHeight,
|
||||
child: BottomNavigationBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
onTap: (int index) {
|
||||
cubit.updatePageIndex(index);
|
||||
if (DevicesCubit.getInstance().chosenCategoryView != null) {
|
||||
DevicesCubit.getInstance()
|
||||
.clearCategoriesSelection(context);
|
||||
}
|
||||
if (HomeCubit.getInstance().selectedRoom != null) {
|
||||
HomeCubit.getInstance().unselectRoom();
|
||||
}
|
||||
},
|
||||
currentIndex: HomeCubit.pageIndex,
|
||||
selectedItemColor: ColorsManager.primaryColor,
|
||||
selectedLabelStyle: const TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 10,
|
||||
),
|
||||
showUnselectedLabels: true,
|
||||
unselectedItemColor: Colors.grey,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
elevation: 0,
|
||||
items: HomeCubit.bottomNavItems,
|
||||
),
|
||||
);
|
||||
return BlocBuilder<HomeCubit, HomeState>(
|
||||
builder: (context, state) {
|
||||
var cubit = HomeCubit.getInstance();
|
||||
return SizedBox(
|
||||
height: Constants.bottomNavBarHeight,
|
||||
child: BottomNavigationBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
onTap: (int index) {
|
||||
cubit.updatePageIndex(index);
|
||||
// if (DevicesCubit.getInstance().chosenCategoryView != null) {
|
||||
// DevicesCubit.getInstance()
|
||||
// .clearCategoriesSelection(context);
|
||||
// }
|
||||
if (HomeCubit.getInstance().selectedRoom != null) {
|
||||
HomeCubit.getInstance().unselectRoom();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
currentIndex: HomeCubit.pageIndex,
|
||||
selectedItemColor: ColorsManager.primaryColor,
|
||||
selectedLabelStyle: const TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 10,
|
||||
),
|
||||
showUnselectedLabels: true,
|
||||
unselectedItemColor: Colors.grey,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
elevation: 0,
|
||||
items: HomeCubit.bottomNavItems,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user