mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 09:45:25 +00:00
push get scenes and automation
This commit is contained in:
42
lib/pages/routiens/widgets/scenes_and_automations.dart
Normal file
42
lib/pages/routiens/widgets/scenes_and_automations.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class ScenesAndAutomations extends StatelessWidget {
|
||||
const ScenesAndAutomations({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => RoutineBloc()
|
||||
..add(
|
||||
LoadScenes(spaceId),
|
||||
)
|
||||
..add(
|
||||
LoadAutomation(spaceId),
|
||||
),
|
||||
child: BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, state) {
|
||||
if (state.scenes.isNotEmpty || state.automations.isNotEmpty) {
|
||||
var scenes = [...state.scenes, ...state.automations];
|
||||
return Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: scenes
|
||||
.map((scene) => DraggableCard(
|
||||
imagePath: Assets.logo,
|
||||
title: scene.name ?? '',
|
||||
))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user