mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 16:54:55 +00:00
initialized Application theme
This commit is contained in:
80
lib/features/home/bloc/home_cubit.dart
Normal file
80
lib/features/home/bloc/home_cubit.dart
Normal file
@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../profile/view/profile_view.dart';
|
||||
import '../../scene/view/scene_view.dart';
|
||||
import '../../smart/view/smart_view.dart';
|
||||
import '../model/device_model.dart';
|
||||
import '../view/widgets/home_view_body.dart';
|
||||
|
||||
part 'home_state.dart';
|
||||
|
||||
class HomeCubit extends Cubit<HomeState> {
|
||||
HomeCubit() : super(HomeInitial()) {
|
||||
getDevices();
|
||||
}
|
||||
|
||||
//TODO separate the navigation logic to another cubit
|
||||
static HomeCubit get(context) => BlocProvider.of(context);
|
||||
|
||||
static int pageIndex = 0;
|
||||
|
||||
var devices = <DeviceModel>[];
|
||||
|
||||
Future<List<DeviceModel>> getDevices() async {
|
||||
emit(HomeLoading());
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
emit(HomeSuccess());
|
||||
|
||||
return devices = [];
|
||||
}
|
||||
|
||||
Map<String, List<Widget>> appBarActions = {
|
||||
'Home': [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.mic),
|
||||
onPressed: () {},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add_circle),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
'Scene': [],
|
||||
'Smart': [],
|
||||
'Profile': [],
|
||||
};
|
||||
|
||||
var bottomNavItems = [
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home_outlined),
|
||||
label: 'Home',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.check_box_outlined),
|
||||
label: 'Scene',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.view_in_ar),
|
||||
label: 'Smart',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.account_circle),
|
||||
label: 'Profile',
|
||||
),
|
||||
];
|
||||
|
||||
final List<Widget> pages = [
|
||||
const HomeViewBody(),
|
||||
const SceneView(),
|
||||
const SmartPage(),
|
||||
const ProfileView(),
|
||||
];
|
||||
|
||||
static Widget get currentPage => HomeCubit().pages[pageIndex];
|
||||
|
||||
void updatePageIndex(int index, BuildContext context) {
|
||||
emit(HomeChangeIndex());
|
||||
pageIndex = index;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user