Files
syncrow-web/lib/pages/routiens/helper/dialog_helper/device_dialog_helper.dart
2024-11-22 16:55:30 +03:00

50 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/routiens/helper/ac_helper.dart';
import 'package:syncrow_web/pages/routiens/helper/one_gang_switch_helper.dart';
import 'package:syncrow_web/pages/routiens/helper/three_gang_switch_helper.dart';
import 'package:syncrow_web/pages/routiens/helper/two_gang_switch_helper.dart';
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
class DeviceDialogHelper {
static Future<Map<String, dynamic>?> showDeviceDialog(
BuildContext context,
Map<String, dynamic> data,
) async {
final functions = data['functions'] as List<DeviceFunction>;
try {
await _getDialogForDeviceType(
context,
data['productType'],
functions,
);
} catch (e) {
debugPrint('Error: $e');
}
return null;
}
static Future<void> _getDialogForDeviceType(
BuildContext context,
String productType,
List<DeviceFunction> functions,
) async {
switch (productType) {
case 'AC':
await ACHelper.showACFunctionsDialog(context, functions);
break;
case '1G':
await OneGangSwitchHelper.showSwitchFunctionsDialog(context, functions);
break;
case '2G':
await TwoGangSwitchHelper.showSwitchFunctionsDialog(context, functions);
break;
case '3G':
await ThreeGangSwitchHelper.showSwitchFunctionsDialog(
context, functions);
break;
}
}
}