mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
105 lines
4.2 KiB
Dart
105 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
|
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart';
|
|
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
|
|
class RoutinesView extends StatefulWidget {
|
|
const RoutinesView({super.key});
|
|
|
|
@override
|
|
State<RoutinesView> createState() => _RoutinesViewState();
|
|
}
|
|
|
|
class _RoutinesViewState extends State<RoutinesView> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
|
builder: (context, state) {
|
|
if (state.createRoutineView) {
|
|
return const CreateNewRoutineView();
|
|
}
|
|
return Row(
|
|
children: [
|
|
Expanded(child: SpaceTreeView(
|
|
onSelect: () {
|
|
context.read<RoutineBloc>()
|
|
..add(const LoadScenes())
|
|
..add(const LoadAutomation());
|
|
},
|
|
)),
|
|
Expanded(
|
|
flex: 4,
|
|
child: ListView(children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
height: MediaQuery.sizeOf(context).height,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Create New Routines",
|
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
color: ColorsManager.grayColor,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
RoutineViewCard(
|
|
onTap: () {
|
|
if (context.read<SpaceTreeBloc>().state.selectedCommunities.length == 1 &&
|
|
context.read<SpaceTreeBloc>().state.selectedSpaces.length == 1) {
|
|
context.read<RoutineBloc>().add(
|
|
(ResetRoutineState()),
|
|
);
|
|
BlocProvider.of<RoutineBloc>(context).add(
|
|
const CreateNewRoutineViewEvent(createRoutineView: true),
|
|
);
|
|
} else {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
context.read<SpaceTreeBloc>().state.selectedSpaces.isEmpty
|
|
? 'Please select a space'
|
|
: 'Please select only one space to proceed'),
|
|
),
|
|
);
|
|
// CustomSnackBar.redSnackBar(
|
|
// context.read<SpaceTreeBloc>().state.selectedSpaces.isEmpty
|
|
// ? 'Please select a space'
|
|
// : 'Please select only one space to proceed');
|
|
}
|
|
},
|
|
icon: Icons.add,
|
|
textString: '',
|
|
),
|
|
const SizedBox(
|
|
height: 15,
|
|
),
|
|
const Expanded(child: FetchRoutineScenesAutomation()),
|
|
],
|
|
),
|
|
),
|
|
]),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|