mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-14 09:17:37 +00:00
Added tab to run to if container
This commit is contained in:
@ -3,6 +3,7 @@ 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:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class IfContainer extends StatelessWidget {
|
||||
const IfContainer({super.key});
|
||||
@ -19,35 +20,49 @@ class IfContainer extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('IF',
|
||||
style:
|
||||
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
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']!,
|
||||
deviceData: item,
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
if (context.read<RoutineBloc>().isTabToRun)
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
DraggableCard(
|
||||
imagePath: Assets.tabToRun,
|
||||
title: 'Tab to run',
|
||||
deviceData: {},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!context.read<RoutineBloc>().isTabToRun)
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: state.ifItems
|
||||
.map((item) => DraggableCard(
|
||||
// key: Key(item['key']!),
|
||||
imagePath: item['imagePath'] ?? '',
|
||||
title: item['title'] ?? 'Tab to run',
|
||||
deviceData: item,
|
||||
))
|
||||
.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));
|
||||
if (!context.read<RoutineBloc>().isTabToRun) {
|
||||
if (data['deviceId'] == 'tab_to_run') {
|
||||
context.read<RoutineBloc>().add(AddToIfContainer(data, true));
|
||||
} else {
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(context, data);
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToIfContainer(result, false));
|
||||
} else if (!['AC', '1G', '2G', '3G'].contains(data['productType'])) {
|
||||
context.read<RoutineBloc>().add(AddToIfContainer(data, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
Reference in New Issue
Block a user