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/gateway/gateway_dialog.dart';

abstract final class GatewayHelper {
  const GatewayHelper._();

  static Future<Map<String, dynamic>?> showGatewayFunctionsDialog({
    required BuildContext context,
    required List<DeviceFunction> functions,
    required String? uniqueCustomId,
    required List<DeviceFunctionData> deviceSelectedFunctions,
    required AllDevicesModel? device,
    required String dialogType,
  }) async {
    return showDialog(
      context: context,
      builder: (context) => BlocProvider<FunctionBloc>(
        create: (context) => FunctionBloc()
          ..add(
            InitializeFunctions(deviceSelectedFunctions),
          ),
        child: GatewayDialog(
          uniqueCustomId: uniqueCustomId,
          functions: functions,
          deviceSelectedFunctions: deviceSelectedFunctions,
          device: device,
          dialogType:dialogType,
        ),
      ),
    );
  }
}
