import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/device_managment/curtain_module/bloc/curtain_module_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

class CalibrateCompletedDialog extends StatelessWidget {
  final BuildContext parentContext;
  final String deviceId;
  const CalibrateCompletedDialog({
    super.key,
    required this.parentContext,
    required this.deviceId,
  });

  @override
  Widget build(_) {
    return AlertDialog(
      backgroundColor: ColorsManager.whiteColors,
      contentPadding: EdgeInsets.zero,
      content: SizedBox(
        height: 250,
        width: 400,
        child: Column(
          children: [
            Expanded(
              child: Column(
                children: [
                  Padding(
                    padding: const EdgeInsets.all(10),
                    child: Text(
                      'Calibration Completed',
                      style: TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.bold,
                        color: ColorsManager.dialogBlueTitle,
                      ),
                    ),
                  ),
                  const SizedBox(height: 5),
                  const Divider(
                    indent: 10,
                    endIndent: 10,
                  ),
                ],
              ),
            ),
            Expanded(
              child: SvgPicture.asset(Assets.completedDoneIcon),
            ),
            Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  const Divider(
                    indent: 10,
                    endIndent: 10,
                  ),
                  InkWell(
                    onTap: () {
                      parentContext.read<CurtainModuleBloc>().add(
                            FetchCurtainModuleStatusEvent(
                              deviceId: deviceId,
                            ),
                          );
                      Navigator.of(parentContext).pop();
                      Navigator.of(parentContext).pop();
                    },
                    child: Container(
                      height: 40,
                      width: double.infinity,
                      alignment: Alignment.center,
                      child: const Text(
                        'Close',
                        style: TextStyle(
                          color: ColorsManager.grayBorder,
                        ),
                      ),
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
