mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
SP-1276/ Show Configuration Pop-up on Drop.
This commit is contained in:
@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_sensor/ceiling_sensor_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||||
@ -49,7 +50,6 @@ class DeviceDialogHelper {
|
|||||||
final deviceSelectedFunctions =
|
final deviceSelectedFunctions =
|
||||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||||
|
|
||||||
|
|
||||||
switch (productType) {
|
switch (productType) {
|
||||||
case 'AC':
|
case 'AC':
|
||||||
return ACHelper.showACFunctionsDialog(
|
return ACHelper.showACFunctionsDialog(
|
||||||
@ -98,6 +98,16 @@ class DeviceDialogHelper {
|
|||||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
uniqueCustomId: data['uniqueCustomId'],
|
uniqueCustomId: data['uniqueCustomId'],
|
||||||
removeComparetors: removeComparetors);
|
removeComparetors: removeComparetors);
|
||||||
|
case 'CPS':
|
||||||
|
return CeilingSensorHelper.showCeilingSensorDialog(
|
||||||
|
context: context,
|
||||||
|
functions: functions,
|
||||||
|
device: data['device'],
|
||||||
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
|
uniqueCustomId: data['uniqueCustomId'],
|
||||||
|
dialogType: dialogType,
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||||
|
|
||||||
|
class CeilingSensorDialog extends StatelessWidget {
|
||||||
|
const CeilingSensorDialog({
|
||||||
|
required this.uniqueCustomId,
|
||||||
|
required this.functions,
|
||||||
|
required this.deviceSelectedFunctions,
|
||||||
|
required this.device,
|
||||||
|
required this.dialogType,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
final String? uniqueCustomId;
|
||||||
|
final List<DeviceFunction> functions;
|
||||||
|
final List<DeviceFunctionData> deviceSelectedFunctions;
|
||||||
|
final AllDevicesModel? device;
|
||||||
|
final String dialogType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
final selectedFunction = state.selectedFunction;
|
||||||
|
final selectedOperationName = state.selectedOperationName;
|
||||||
|
final selectedFunctionData = state.addedFunctions
|
||||||
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
|
orElse: () => DeviceFunctionData(
|
||||||
|
entityId: '',
|
||||||
|
functionCode: selectedFunction ?? '',
|
||||||
|
operationName: '',
|
||||||
|
value: null,
|
||||||
|
));
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
width: selectedFunction != null ? 600 : 360,
|
||||||
|
height: 450,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.only(top: 20),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const DialogHeader('Presence Sensor Condition'),
|
||||||
|
DialogFooter(
|
||||||
|
onCancel: () => Navigator.pop(context),
|
||||||
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
|
? () {
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
AddFunctionToRoutine(
|
||||||
|
state.addedFunctions, '{uniqueCustomId}'),
|
||||||
|
);
|
||||||
|
|
||||||
|
Navigator.pop(context, {
|
||||||
|
// 'deviceId': functions.first.deviceId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
isConfirmEnabled: selectedFunction != null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_sensor/ceiling_sensor_dialog.dart';
|
||||||
|
|
||||||
|
abstract final class CeilingSensorHelper {
|
||||||
|
const CeilingSensorHelper._();
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>?> showCeilingSensorDialog({
|
||||||
|
required BuildContext context,
|
||||||
|
required String? uniqueCustomId,
|
||||||
|
required List<DeviceFunction> functions,
|
||||||
|
required List<DeviceFunctionData> deviceSelectedFunctions,
|
||||||
|
required AllDevicesModel? device,
|
||||||
|
required String dialogType,
|
||||||
|
}) {
|
||||||
|
return showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => BlocProvider(
|
||||||
|
create: (context) => FunctionBloc()
|
||||||
|
..add(
|
||||||
|
InitializeFunctions(deviceSelectedFunctions),
|
||||||
|
),
|
||||||
|
child: CeilingSensorDialog(
|
||||||
|
uniqueCustomId: uniqueCustomId,
|
||||||
|
functions: functions,
|
||||||
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
|
device: device,
|
||||||
|
dialogType: dialogType,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user