mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
initialized Routine Page
This commit is contained in:
66
lib/features/app_layout/bloc/nav_cubit.dart
Normal file
66
lib/features/app_layout/bloc/nav_cubit.dart
Normal file
@ -0,0 +1,66 @@
|
||||
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/layout/view/layout_view.dart';
|
||||
import 'package:syncrow_app/features/profile/view/profile_view.dart';
|
||||
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/assets_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.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: IconsManager.dashboard, label: 'Dashboard'),
|
||||
defaultBottomNavBarItem(icon: IconsManager.layout, label: 'Layout'),
|
||||
defaultBottomNavBarItem(icon: IconsManager.devices, label: 'Devices'),
|
||||
defaultBottomNavBarItem(icon: IconsManager.routine, label: 'Routine'),
|
||||
defaultBottomNavBarItem(icon: IconsManager.menu, label: 'Menu'),
|
||||
];
|
||||
|
||||
final List<Widget> pages = [
|
||||
const DashboardView(),
|
||||
const LayoutPage(),
|
||||
const DevicesViewBody(),
|
||||
const SceneView(),
|
||||
const ProfileView(),
|
||||
];
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user