import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/curtain_module/bloc/curtain_module_bloc.dart';
import 'package:syncrow_web/pages/device_managment/curtain_module/widgets/curtain_movment_widget.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
import 'package:syncrow_web/services/batch_control_devices_service.dart';
import 'package:syncrow_web/services/control_device_service.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

class CurtainModuleBatchView extends StatelessWidget {
  final List<String> devicesIds;
  const CurtainModuleBatchView({
    super.key,
    required this.devicesIds,
  });

  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (context) => CurtainModuleBloc(
          controlDeviceService: RemoteControlDeviceService(),
          batchControlDevicesService: RemoteBatchControlDevicesService())
        ..add(CurtainModuleFetchBatchStatusEvent(devicesIds)),
      child: _buildStatusControls(context),
    );
  }

  Widget _buildStatusControls(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only(left: 30),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ControlCurtainMovementWidget(
            devicesId: devicesIds,
          ),
          const SizedBox(
            height: 10,
          ),
          SizedBox(
            height: 120,
            // width: 350,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                // Expanded(
                // child:
                FactoryResetWidget(
                  callFactoryReset: () {
                    context.read<CurtainModuleBloc>().add(
                          CurtainModuleFactoryReset(
                            deviceId: devicesIds.first,
                            factoryReset:
                                FactoryResetModel(devicesUuid: devicesIds),
                          ),
                        );
                  },
                ),
                // ),
                // Expanded(
                //   child: IconNameStatusContainer(
                //     isFullIcon: false,
                //     name: 'Firmware Update',
                //     icon: Assets.firmware,
                //     onTap: () {},
                //     status: false,
                //     textColor: ColorsManager.blackColor,
                //   ),
                // )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
