import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/common/custom_dialog.dart';
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';

class DeleteSceneWidget extends StatelessWidget {
  const DeleteSceneWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        const SizedBox(
          height: 10,
        ),
        GestureDetector(
          onTap: () async {
            await showCustomDialog(
                context: context,
                message: 'Are you sure you want to delete this scene?',
                actions: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      InkWell(
                        onTap: () {
                          Navigator.of(context).pop();
                        },
                        child: Container(
                          alignment: AlignmentDirectional.center,
                          child: Text(
                            'Cancel',
                            style: Theme.of(context).textTheme.bodyMedium!.copyWith(
                                  color: ColorsManager.textGray,
                                ),
                          ),
                        ),
                      ),
                      Container(width: 1, height: 50, color: ColorsManager.greyColor),
                      InkWell(
                        onTap: () {
                          context.read<RoutineBloc>().add(const DeleteScene());
                          Navigator.of(context).pop();
                          Navigator.of(context).pop();
                        },
                        child: Container(
                          alignment: AlignmentDirectional.center,
                          child: Text(
                            'Confirm',
                            style: Theme.of(context).textTheme.bodyMedium!.copyWith(
                                  color: ColorsManager.primaryColorWithOpacity,
                                ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ]);
          },
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Icon(
                Icons.delete,
                color: ColorsManager.red,
              ),
              const SizedBox(
                width: 2,
              ),
              Text(
                'Delete',
                style: Theme.of(context).textTheme.bodyMedium!.copyWith(
                      color: ColorsManager.red,
                    ),
              ),
            ],
          ),
        ),
        const SizedBox(
          height: 10,
        ),
      ],
    );
  }
}
