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 AcknowledgeWorkDialog extends StatelessWidget {
  final String? title;
  final String? message;
  final String? okTitle;
  final VoidCallback onSave;
  final VoidCallback onDiscard;

  const AcknowledgeWorkDialog(
      {Key? key, this.title, this.message = "To prevent the risk of losing your changes, Please confirm Save or Discard", this.okTitle, required this.onSave, required this.onDiscard})
      : 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,
            Row(
              children: [
                AppFilledButton(
                  label: "Discard",
                  buttonColor: Colors.white54,
                  textColor: AppColor.red30,
                  height: 40,
                  showBorder: true,
                  onPressed: () {
                    Navigator.of(context).pop();
                    onDiscard();
                  },
                ).expanded,
                16.width,
                AppFilledButton(
                  label: "Save",
                  onPressed: () {
                    Navigator.of(context).pop();
                    onSave();
                  },
                  height: 40,
                  buttonColor: AppColor.green70,
                ).expanded,
              ],
            ),
          ],
        ),
      ),
    );
  }
}
