import 'package:flutter/material.dart';
import 'package:remever/common/resources.dart';
import 'package:remever/common/widgets/typography.dart';
import 'package:remever/common/widgets/wspace.dart';
import 'package:remever/components/extensions/context.dart';
import 'package:remever/gen/assets.gen.dart';
import 'package:remever/widgets/primary_button.dart';

class AlertInfoDialog extends StatelessWidget {
  const AlertInfoDialog({
    super.key,
    this.acceptTitle = '',
    this.declineTitle = '',
    this.title = '',
  });

  final String? title;
  final String? acceptTitle;
  final String? declineTitle;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 16).r,
      child: Stack(
        children: <Widget>[
          Column(
            children: <Widget>[
              const HSpace(32),
              _buildDanger(),
              const HSpace(24),
              AppTypography(
                title!,
                type: Medium16px(),
                maxLines: 3,
                textAlign: TextAlign.center,
              ),
              const HSpace(24),
              Material(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    PrimaryButton(
                      width: 170,
                      height: 52,
                      color: AppColors.danger,
                      onTap: () => Navigator.pop(context, true),
                      child: AppTypography(
                        acceptTitle!,
                        type: Medium14px(),
                        color: AppColors.white,
                      ),
                    ),
                    PrimaryButton(
                      width: 170,
                      height: 52,
                      color: AppColors.primary,
                      onTap: () => Navigator.pop(context, false),
                      child: AppTypography(
                        declineTitle!,
                        type: Medium14px(),
                        color: AppColors.white,
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
          Align(
            alignment: Alignment.topRight,
            child: Padding(
              padding: const EdgeInsets.only(top: 16).r,
              child: GestureDetector(
                onTap: () => Navigator.pop(context),
                child: SizedBox.square(
                  dimension: 24.r,
                  child: DecoratedBox(
                    decoration: const BoxDecoration(
                      shape: BoxShape.circle,
                      color: AppColors.gray_bg,
                    ),
                    child: Assets.icons.typeClose.image(
                      color: AppColors.disabled,
                    ),
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildDanger() {
    return SizedBox.square(
      dimension: 56.r,
      child: DecoratedBox(
        decoration: BoxDecoration(
          shape: BoxShape.circle,
          color: const Color(0xFFFFE4E6).withOpacity(0.4),
        ),
        child: Center(
          child: Assets.icons.typeDanger.image(height: 24.h, width: 24.w),
        ),
      ),
    );
  }
}
