import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/applicationDemo/enums/otp_method.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';

class OtpMethodSelectionDialog extends StatelessWidget {
  final Function(OtpMethod method) onMethodSelected;

  const OtpMethodSelectionDialog({
    Key? key,
    required this.onMethodSelected,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.white,
      shape: const RoundedRectangleBorder(),
      insetPadding: const EdgeInsets.only(left: 21, right: 21),
      child: Padding(
        padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Expanded(
                  child: InfoHeader16Widget("Information").paddingOnly(top: 16),
                ),
                IconButton(
                  padding: EdgeInsets.zero,
                  icon: const Icon(Icons.close),
                  color: Colors.black87,
                  constraints: const BoxConstraints(),
                  onPressed: () => Navigator.pop(context),
                )
              ],
            ),
            "Choose a method to receive the OTP".bodyText(context),
            28.height,
            Row(
              children: [
                Expanded(
                  child: AppFilledButton(
                    label: OtpMethod.sms.value,
                    onPressed: () {
                      Navigator.pop(context);
                      onMethodSelected(OtpMethod.sms);
                    },
                    textColor: Colors.white,
                  ),
                ),
                16.width,
                Expanded(
                  child: AppFilledButton(
                    label: OtpMethod.email.value,
                    onPressed: () {
                      Navigator.pop(context);
                      onMethodSelected(OtpMethod.email);
                    },
                    textColor: Colors.white,
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
