mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
57 lines
2.1 KiB
Dart
57 lines
2.1 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/helper/dialog_helper/device_dialog_helper.dart';
|
|
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
|
|
|
|
class IfContainer extends StatelessWidget {
|
|
const IfContainer({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
|
builder: (context, state) {
|
|
return DragTarget<Map<String, dynamic>>(
|
|
builder: (context, candidateData, rejectedData) {
|
|
return Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text('IF',
|
|
style:
|
|
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 16),
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: state.ifItems
|
|
.map((item) => DraggableCard(
|
|
key: Key(item['key']!),
|
|
imagePath: item['imagePath']!,
|
|
title: item['title']!,
|
|
))
|
|
.toList(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
onWillAccept: (data) => data != null,
|
|
onAccept: (data) async {
|
|
final result =
|
|
await DeviceDialogHelper.showDeviceDialog(context, data);
|
|
if (result != null) {
|
|
context.read<RoutineBloc>().add(AddToIfContainer(result));
|
|
} else if (!['AC', '1G', '2G', '3G']
|
|
.contains(data['productType'])) {
|
|
context.read<RoutineBloc>().add(AddToIfContainer(data));
|
|
}
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|