import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/device_setting/bloc/setting_bloc_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:syncrow_web/web_layout/default_container.dart';

class RemoveDeviceWidget extends StatelessWidget {
  const RemoveDeviceWidget({
    super.key,
    required SettingDeviceBloc bloc,
  }) : _bloc = bloc;

  final SettingDeviceBloc _bloc;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: double.infinity,
      child: InkWell(
        onTap: () {
          showDialog(
            context: context,
            builder: (context) {
              return AlertDialog(
                title: Text(
                  'Remove Device',
                  style: context.textTheme.bodyMedium!.copyWith(
                    fontWeight: FontWeight.w700,
                    color: ColorsManager.red,
                  ),
                ),
                content: Text(
                  'Are you sure you want to remove this device?',
                  style: context.textTheme.bodyMedium!.copyWith(
                    color: ColorsManager.grayColor,
                  ),
                ),
                actions: [
                  TextButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                    child: Text(
                      'Cancel',
                      style: context.textTheme.bodyMedium!.copyWith(
                        color: ColorsManager.grayColor,
                      ),
                    ),
                  ),
                  TextButton(
                    onPressed: () {
                      _bloc.add(SettingBlocDeleteDevice());
                      Navigator.of(context).pop();
                    },
                    child: Text(
                      'Remove',
                      style: context.textTheme.bodyMedium!.copyWith(
                        color: ColorsManager.red,
                      ),
                    ),
                  ),
                ],
              );
            },
          );
        },
        child: DefaultContainer(
          padding: const EdgeInsets.all(25),
          child: Center(
            child: Text(
              'Remove Device',
              style: context.textTheme.bodyMedium!.copyWith(
                  fontSize: 14,
                  color: ColorsManager.red,
                  fontWeight: FontWeight.w700),
            ),
          ),
        ),
      ),
    );
  }
}
