mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 08:54:54 +00:00
Refactor DefaultNavBar widget to update page index on item tap. Update ServerFailure class to handle 400 status code with list of errors.
53 lines
1.8 KiB
Dart
53 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
|
import 'package:syncrow_app/generated/assets.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
class DefaultNavBar extends StatelessWidget {
|
|
const DefaultNavBar({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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();
|
|
// }
|
|
|
|
HomeCubit.getInstance().updatePageIndex(index);
|
|
},
|
|
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,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|