mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00

AC Cubit Add New Devices Cubit Arch will be used Devices Cubit (for devices categories, and devices page) { AC cubit, Lights cubit. ... } Replaced AssetsManager with Assets Class (auto generated)
67 lines
2.0 KiB
Dart
67 lines
2.0 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/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 int pageIndex = 0;
|
|
|
|
int get getPageIndex => pageIndex;
|
|
|
|
Map<String, List<Widget>> appBarActions = {
|
|
'Home': [],
|
|
'Scene': [],
|
|
'Smart': [],
|
|
'Profile': [],
|
|
};
|
|
|
|
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(),
|
|
];
|
|
|
|
Widget get currentPage => NavCubit().pages[pageIndex];
|
|
|
|
void updatePageIndex(int index, BuildContext context) {
|
|
emit(NavChangePage());
|
|
pageIndex = index;
|
|
}
|
|
}
|
|
|
|
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,
|
|
);
|
|
}
|