import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:nomo/config/theme/theme_extensions/theme_extension.dart'; import '../../config/translations/strings_enum.dart'; import '../widgets/submit_btn.dart'; class ErrorDialog { static void show({ String? title, String? message, String? buttonText, VoidCallback? onPressed, }) { Get.generalDialog( pageBuilder: (context, animation, secondaryAnimation) { return AnimatedBuilder( animation: animation, builder: (context, child) { return Transform.scale( scale: Tween(begin: 0.3, end: 1.0) .animate( CurvedAnimation( parent: animation, curve: Curves.elasticOut, ), ) .value, child: Transform.translate( offset: Offset( 0, Tween(begin: 100, end: 0) .animate( CurvedAnimation( parent: animation, curve: Curves.easeOutCubic, ), ) .value, ), child: Opacity( opacity: animation.value, child: WillPopScope( onWillPop: () async => false, child: Dialog( backgroundColor: Get.reactiveTheme.highlightColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), // side: BorderSide(color: Palette.white.withOpacity(0.12)), ), child: Container( padding: const EdgeInsets.all(24), decoration: BoxDecoration( color: Get.reactiveTheme.highlightColor, borderRadius: BorderRadius.circular(16), ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title ?? Strings.failed.tr, style: TextStyle( color: Get .reactiveTheme .textTheme .bodyLarge! .color, fontSize: 18.sp, fontWeight: FontWeight.w600, ), ), 8.verticalSpaceFromWidth, Text( message ?? Strings.unknownError.tr, style: TextStyle( color: Get.reactiveTheme.hintColor, fontSize: 12.sp, ), textAlign: TextAlign.start, ), 16.verticalSpaceFromWidth, SubmitButton( onPressed: () { Navigator.of(Get.context!).pop(); onPressed?.call(); }, text: buttonText ?? Strings.ok.tr, // 自定义文本 ), ], ), ), ), ), ), ), ); }, ); }, barrierDismissible: false, ); } }