quickConfirm function

Future<bool> quickConfirm({
  1. required BuildContext context,
  2. TextStyle textStyle = const TextStyle(color: Colors.white),
  3. Color backgroundColor = Colors.black,
  4. Widget? title,
  5. Widget? content,
  6. EdgeInsets? inputFieldPadding,
  7. EdgeInsets? inputFieldMargin,
  8. Language? language,
  9. Color? overlayColor,
  10. Text? confirmText,
})

Implementation

Future<bool> quickConfirm({
  required BuildContext context,
  TextStyle textStyle = const TextStyle(
    color: Colors.white,
  ),
  Color backgroundColor = Colors.black,
  Widget? title,
  Widget? content,
  EdgeInsets? inputFieldPadding,
  EdgeInsets? inputFieldMargin,
  Language? language,
  Color? overlayColor,
  Text? confirmText,
})async{
  //Confirm a certain action
  bool? actionConfirmed = await showDialog(
    context: context,
    builder: (context)=> AlertDialog(
      title: title,
      content: content,
      actions: [
        TextButton(
         onPressed: (){
           Navigator.pop(context,false);
         },
         child: TranslatableText(
           options: [
             TranslateOption(language: Languages.english, text: "cancel"),
             TranslateOption(language: Languages.spanish, text: "cancelar"),
           ],
           displayLanguage: language ?? Languages.english,
          ),
          style: ButtonStyle(
            overlayColor: MaterialStateProperty.all(backgroundColor),
          ),
        ),
        TextButton(
         onPressed: (){
           Navigator.pop(context,true);
         },
         child: confirmText ?? TranslatableText(
           options: [
             TranslateOption(language: Languages.english, text: "Ok"),
             TranslateOption(language: Languages.spanish, text: "De acuerdo"),
           ],
           displayLanguage: language ?? Languages.english,
           style: textStyle,
          ),
          style: ButtonStyle(
            backgroundColor: MaterialStateProperty.all(backgroundColor),
            overlayColor: overlayColor == null ? null : MaterialStateProperty.all(overlayColor.withOpacity(0.5)),
          ),
        ),
      ],
    ),
  );
  return actionConfirmed ?? false;
}