mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
77 lines
2.8 KiB
Dart
77 lines
2.8 KiB
Dart
// lib/pages/routiens/widgets/then_container.dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/routiens/bloc/routine_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';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
class ThenContainer extends StatelessWidget {
|
|
const ThenContainer({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
|
builder: (context, state) {
|
|
return DragTarget<Map<String, dynamic>>(
|
|
builder: (context, candidateData, rejectedData) {
|
|
return SingleChildScrollView(
|
|
child: Container(
|
|
padding: const EdgeInsets.all(16),
|
|
width: double.infinity,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text('THEN',
|
|
style: TextStyle(
|
|
fontSize: 18, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 16),
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: state.thenItems
|
|
.map((item) => DraggableCard(
|
|
// key: Key(item['key']!),
|
|
imagePath: item['imagePath']!,
|
|
title: item['title']!,
|
|
deviceData: item,
|
|
))
|
|
.toList(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
onWillAccept: (data) => data != null,
|
|
onAccept: (data) async {
|
|
final uniqueCustomId = const Uuid().v4();
|
|
data['uniqueCustomId'] = uniqueCustomId;
|
|
final result =
|
|
await DeviceDialogHelper.showDeviceDialog(context, data);
|
|
// if (result != null) {
|
|
// for (var function in routineBloc.state.selectedFunctions) {
|
|
// routineBloc.add(AddToThenContainer(
|
|
// {
|
|
// 'item': function,
|
|
// 'imagePath': data['imagePath'],
|
|
// 'title': data['name'],
|
|
|
|
// }
|
|
// ));
|
|
// }
|
|
// }
|
|
if (result != null) {
|
|
context.read<RoutineBloc>().add(AddToThenContainer(data));
|
|
} else if (!['AC', '1G', '2G', '3G']
|
|
.contains(data['productType'])) {
|
|
context.read<RoutineBloc>().add(AddToThenContainer(data));
|
|
}
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|