From db4978fbbd488dc5043ebb02242db5ab5f512026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 16 Jan 2024 16:52:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99toast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/tools/toast.dart | 122 --------------------------------- 1 file changed, 122 deletions(-) delete mode 100644 star_lock/lib/tools/toast.dart diff --git a/star_lock/lib/tools/toast.dart b/star_lock/lib/tools/toast.dart deleted file mode 100644 index 02047cf4..00000000 --- a/star_lock/lib/tools/toast.dart +++ /dev/null @@ -1,122 +0,0 @@ -/* -* 土司提示 -* author:付 -* */ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:fluttertoast/fluttertoast.dart' as ToastPlugins; - -class Toast{ - /// 土司提示 - /// msg: 提示的信息 - /// gravity:显示的位置 - static show({required String msg,ToastPlugins.ToastGravity? gravity}){ - ToastPlugins.Fluttertoast.showToast( - msg: msg, - toastLength: ToastPlugins.Toast.LENGTH_SHORT, - gravity: gravity??ToastPlugins.ToastGravity.CENTER, - timeInSecForIosWeb: 1, - backgroundColor: Colors.black, - textColor: Colors.white, - fontSize: 16.0 - ); - } - - /// 土司提示 - /// 隐藏 - static hidden(){ - ToastPlugins.Fluttertoast.cancel(); - } - - /// 显示模态弹窗 - /// context: 上下文 - /// title:标题 - /// content:内容 - /// confirmText:确认按钮文案 - /// confirmTextColor:确认按钮颜色 默认颜色 const Color(0xFFEE4A42) - /// cancelText:取消按钮文案 - /// showCancel:是否显示取消按钮 - /// success: 确认按钮回调函数 - /// fail: 取消按钮回调函数 - static showModal({ - required BuildContext context, - required String title, - required String content, - required String confirmText, - required Function success, - Color? confirmTextColor, - String? cancelText, - bool? showCancel, - Function? fail - }){ - confirmTextColor ??= const Color(0xFFE37549); - showCancel ??= true; - cancelText ??= '取消'; - showDialog(context: context, builder: (cxt){ - return AlertDialog( - buttonPadding: const EdgeInsets.fromLTRB(0, 0, 0, 0), - contentPadding: EdgeInsets.fromLTRB( 55.w, 45.w, 55.w, 70.w), - title: Text(title,textAlign: TextAlign.center,style: TextStyle( - fontSize: 32.sp, - color: const Color(0xff26313B), - fontWeight:FontWeight.w400 - )), - content: Text(content,style: TextStyle( - fontSize: 28.sp, - color: const Color(0xff666666), - fontWeight:FontWeight.w400 - )), - actions: [ - Container( - width: double.infinity, - decoration: BoxDecoration( - border: Border( - top: BorderSide( - width: 1.w,//宽度 - color: const Color(0xFFEEEEEE), //边框颜色 - ), - ) - ), - child: Row( - children: [ - showCancel==true?Expanded(child: GestureDetector( - child: Container( - height: 90.w, - alignment: Alignment.center, - child: Text(cancelText!,textAlign: TextAlign.center,style: TextStyle( - fontSize: 28.sp - )), - ), - onTap: (){ - Navigator.of(cxt).pop(); - if(fail!=null){ - fail(); - } - }, - )):const SizedBox(width: 0,height: 0), - showCancel==true?Container(width: 1.w,height: 60.w,color: const Color(0xffEEEEEE)):const SizedBox(width: 0,height: 0), - Expanded(child: GestureDetector( - child: Container( - height: 90.w, - alignment: Alignment.center, - child: Text(confirmText,textAlign: TextAlign.center,style: TextStyle( - fontSize: 28.sp, - color: confirmTextColor - )), - ), - onTap: (){ - Navigator.of(cxt).pop(); - if(success!=null){ - success(); - } - }, - )), - ], - ), - ) - ], - ); - }); - } - -} \ No newline at end of file