| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- 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<double>(begin: 0.3, end: 1.0)
- .animate(
- CurvedAnimation(
- parent: animation,
- curve: Curves.elasticOut,
- ),
- )
- .value,
- child: Transform.translate(
- offset: Offset(
- 0,
- Tween<double>(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,
- ),
- ),
- 16.verticalSpaceFromWidth,
- Text(
- message ?? Strings.unknownError.tr,
- style: TextStyle(
- color: Get.reactiveTheme.hintColor,
- fontSize: 14.sp,
- ),
- textAlign: TextAlign.start,
- ),
- 24.verticalSpaceFromWidth,
- SubmitButton(
- onPressed: () {
- Navigator.of(Get.context!).pop();
- onPressed?.call();
- },
- text: buttonText ?? Strings.ok.tr, // 自定义文本
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- ),
- );
- },
- );
- },
- barrierDismissible: false,
- );
- }
- }
|