mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
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(
|
|
const LoadScenes(spaceId),
|
|
)
|
|
..add(
|
|
const 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.asMap().entries.map((entry) {
|
|
final scene = entry.value;
|
|
return DraggableCard(
|
|
imagePath: Assets.logo,
|
|
title: scene.name,
|
|
);
|
|
}).toList(),
|
|
);
|
|
}
|
|
return const Center(child: CircularProgressIndicator());
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|