Files
syncrow-app/lib/features/app_layout/bloc/nav_cubit.dart
Mohammad Salameh 42051bb977 Fixed the overflow in the login screen, the page is scrollable.
- Fixed Scrolling wasent working in login screen
- Changed Home page to indexed based view instead of PageView
2024-03-19 13:29:12 +03:00

168 lines
4.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/app_bar_home_dropdown.dart';
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
import 'package:syncrow_app/features/devices/view/widgets/devices_view_body.dart';
import 'package:syncrow_app/features/menu/view/menu_view.dart';
import 'package:syncrow_app/features/scene/view/scene_view.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import '../../../generated/assets.dart';
part 'nav_state.dart';
class NavCubit extends Cubit<NavState> {
NavCubit() : super(NavInitial());
static NavCubit of(context) => BlocProvider.of<NavCubit>(context);
static clear() {
pageIndex = 0;
}
static int pageIndex = 0;
static Map<String, List<Widget>> appBarActions = {
'Dashboard': [
IconButton(
icon: const Icon(
Icons.add,
size: 25,
),
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(ColorsManager.textPrimaryColor),
),
onPressed: () {},
),
],
'Devices': [
// IconButton(
// icon: Image.asset(
// Assets.iconsFilter,
// height: 20,
// width: 20,
// ),
// onPressed: () {},
// ),
IconButton(
icon: const Icon(
Icons.add,
size: 25,
),
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(ColorsManager.textPrimaryColor),
),
onPressed: () {},
),
IconButton(
icon: const Icon(
Icons.more_vert,
size: 25,
),
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(ColorsManager.textPrimaryColor),
),
onPressed: () {},
),
],
'Routine': [
// IconButton(
// icon: Image.asset(
// Assets.iconsFilter,
// height: 20,
// width: 20,
// ),
// onPressed: () {},
// ),
IconButton(
icon: const Icon(
Icons.add,
size: 25,
),
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(ColorsManager.textPrimaryColor),
),
onPressed: () {},
),
IconButton(
icon: const Icon(
Icons.more_vert,
size: 25,
),
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(ColorsManager.textPrimaryColor),
),
onPressed: () {},
),
],
'Menu': [
IconButton(
icon: SvgPicture.asset(
Assets.iconsScan,
height: 20,
width: 20,
),
onPressed: () {},
),
],
};
static Map<String, Widget?> appBarLeading = {
'Dashboard': const AppBarHomeDropdown(),
'Devices': const AppBarHomeDropdown(),
'Routine': const AppBarHomeDropdown(),
'Menu': Padding(
padding: const EdgeInsets.only(left: 15),
child: Image.asset(
Assets.imagesLogoHorizontal,
height: 15,
width: 100,
fit: BoxFit.scaleDown,
),
),
};
var bottomNavItems = [
defaultBottomNavBarItem(icon: Assets.iconsDashboard, label: 'Dashboard'),
// defaultBottomNavBarItem(icon: Assets.iconslayout, label: 'Layout'),
defaultBottomNavBarItem(icon: Assets.iconsDevices, label: 'Devices'),
defaultBottomNavBarItem(icon: Assets.iconsRoutines, label: 'Routine'),
defaultBottomNavBarItem(icon: Assets.iconsMenu, label: 'Menu'),
];
final List<Widget> pages = [
const DashboardView(),
// const LayoutPage(),
const DevicesViewBody(),
const SceneView(),
const MenuView(),
];
void updatePageIndex(int index) {
pageIndex = index;
emit(NavChangePage());
}
}
BottomNavigationBarItem defaultBottomNavBarItem(
{required String icon, required String label}) {
return BottomNavigationBarItem(
icon: SvgPicture.asset(icon),
activeIcon: SvgPicture.asset(
icon.replaceAll('.svg', '-fill.svg'),
colorFilter: const ColorFilter.mode(
ColorsManager.primaryColor,
BlendMode.srcIn,
),
),
label: label,
);
}