push adding the selected functiond and device to then container

This commit is contained in:
ashrafzarkanisala
2024-11-23 01:39:05 +03:00
parent 53eb18c075
commit 5e91d7c03a
7 changed files with 32 additions and 20 deletions

View File

@ -13,11 +13,15 @@ class DeviceDialogHelper {
final functions = data['functions'] as List<DeviceFunction>;
try {
await _getDialogForDeviceType(
final result = await _getDialogForDeviceType(
context,
data['productType'],
functions,
);
if (result != null) {
return result;
}
} catch (e) {
debugPrint('Error: $e');
}
@ -25,23 +29,22 @@ class DeviceDialogHelper {
return null;
}
static Future<void> _getDialogForDeviceType(
static Future<Map<String, dynamic>?> _getDialogForDeviceType(
BuildContext context,
String productType,
List<DeviceFunction> functions,
) async {
switch (productType) {
case 'AC':
await ACHelper.showACFunctionsDialog(context, functions);
break;
return ACHelper.showACFunctionsDialog(context, functions);
case '1G':
await OneGangSwitchHelper.showSwitchFunctionsDialog(context, functions);
break;
return OneGangSwitchHelper.showSwitchFunctionsDialog(
context, functions);
case '2G':
await TwoGangSwitchHelper.showSwitchFunctionsDialog(context, functions);
break;
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
context, functions);
case '3G':
await ThreeGangSwitchHelper.showSwitchFunctionsDialog(
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
context, functions);
break;
}