showCommonDialog function

Future<bool?> showCommonDialog({
  1. required BuildContext context,
  2. String? title,
  3. String? content,
  4. String? positiveContent,
  5. String? navigateContent,
  6. bool showNavigate = true,
})

Implementation

Future<bool?> showCommonDialog(
    {required BuildContext context,
    String? title,
    String? content,
    String? positiveContent,
    String? navigateContent,
    bool showNavigate = true}) async {
  assert(title != null || content != null);
  return showCupertinoDialog(
      context: context,
      barrierDismissible: true,
      builder: (BuildContext context) {
        return CupertinoAlertDialog(
          title: title != null
              ? Text(
                  title,
                  style: const TextStyle(fontSize: 17),
                )
              : null,
          content: content != null
              ? Text(
                  content,
                  style: const TextStyle(
                      fontSize: 13, color: CommonColors.color_333333),
                )
              : null,
          actions: [
            if (showNavigate)
              CupertinoDialogAction(
                  onPressed: () {
                    Navigator.of(context).pop(false);
                  },
                  child: Text(
                    navigateContent ?? S.of(context).cancel,
                    style: const TextStyle(
                        fontSize: 17, color: CommonColors.color_666666),
                  )),
            CupertinoDialogAction(
                onPressed: () {
                  Navigator.of(context).pop(true);
                },
                child: Text(
                  positiveContent ?? S.of(context).sure,
                  style: const TextStyle(
                      fontSize: 17, color: CommonColors.color_007aff),
                ))
          ],
        );
      });
}