import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:krow/core/presentation/styles/kw_box_decorations.dart';
import 'package:krow/core/presentation/styles/kw_text_styles.dart';
import 'package:krow/core/presentation/styles/theme.dart';
import 'package:krow/core/presentation/widgets/ui_kit/kw_button.dart';

class DisputeInfoDialog extends StatefulWidget {
  final String reason;
  final String details;
  final String? supportNote;

  const DisputeInfoDialog(
      {super.key,
      required this.reason,
      required this.details,
      required this.supportNote});

  static Future<Map<String, dynamic>?> showCustomDialog(BuildContext context,
      {required String reason,
      required String details,
      required String? supportNote}) async {
    return await showDialog<Map<String, dynamic>>(
      context: context,
      builder: (context) => DisputeInfoDialog(
          reason: reason, details: details, supportNote: supportNote),
    );
  }

  @override
  State<DisputeInfoDialog> createState() => _DisputeInfoDialogState();
}

class _DisputeInfoDialogState extends State<DisputeInfoDialog> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        decoration: KwBoxDecorations.white24,
        margin: const EdgeInsets.all(16),
        padding: const EdgeInsets.all(24),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text(
                  'Dispute Details',
                  style: AppTextStyles.headingH3,
                )
              ],
            ),
            Gap(24),
            Text(
              'The reason why the invoice is being disputed:',
              style: AppTextStyles.bodySmallReg
                  .copyWith(color: AppColors.blackGray),
            ),
            Gap(2),
            Text(
              widget.reason,
              style: AppTextStyles.bodyMediumMed
                  .copyWith(color: AppColors.blackGray),
            ),
            Divider(
              color: AppColors.grayTintStroke,
              height: 24,
            ),
            Text('Status',
                style: AppTextStyles.bodySmallReg
                    .copyWith(color: AppColors.blackGray)),
            Gap(2),
            Text('Under Review',
                style: AppTextStyles.bodyMediumMed
                    .copyWith(color: AppColors.primaryBlue)),
            Gap(12),
            Text(
              'Additional Details',
              style: AppTextStyles.bodySmallReg
                  .copyWith(color: AppColors.blackGray),
            ),
            Gap(2),
            Text(
              widget.details,
              style: AppTextStyles.bodyMediumMed,
            ),
            if (widget.supportNote?.isNotEmpty ?? false) ...[
              const Gap(12),
              Text(
                'Support Note',
                style: AppTextStyles.bodySmallReg
                    .copyWith(color: AppColors.blackGray),
              ),
              Gap(2),
              Text(
                widget.supportNote ?? '',
                style: AppTextStyles.bodyMediumMed,
              ),
            ],
            const Gap(24),
            KwButton.primary(
              label: 'Back to Invoice',
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        ),
      ),
    );
  }
}
