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/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';

class LocalAuthFailedDialog extends StatelessWidget {
  final String? title;
  final String? message;
  final String? okTitle;
  final String? retryBtnText;
  final String? loginBtnText;
  final VoidCallback onRetry;
  final VoidCallback onLogin;

  const LocalAuthFailedDialog(
      {Key? key, this.title, this.message = "Authentication Failed, Please try again or login", this.okTitle, required this.onRetry, required this.onLogin, this.retryBtnText, this.loginBtnText})
      : 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: [
            const Text(
              "Confirm",
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black87, height: 35 / 24, letterSpacing: -0.96),
            ).paddingOnly(top: 16, bottom: 8),
            message != null ? message!.heading5(context).custom(color: AppColor.neutral50) : const SizedBox(),
            28.height,
            Column(
              children: [
                AppFilledButton(
                  label: retryBtnText ?? "Retry",
                  fontSize: 18,
                  onPressed: () {
                    Navigator.of(context).pop();
                    onRetry();
                  },
                  buttonColor: AppColor.primary90,
                ),
                16.height,
                AppFilledButton(
                  label: loginBtnText ?? "Login",
                  buttonColor: Colors.white54,
                  textColor: AppColor.black10,
                  height: 42,
                  showBorder: true,
                  onPressed: () {
                    Navigator.of(context).pop();
                    onLogin();
                  },
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
