import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:widgets/ext/ex_widget.dart'; import 'package:cs_resources/constants/color_constants.dart'; import '../my_text_view.dart'; import '../no_shadow_scroll_behavior.dart'; import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; import 'package:widgets/widget_export.dart'; /* * 默认的弹窗 */ class AppDefaultDialog extends StatelessWidget { String title; String message; VoidCallback confirmAction; VoidCallback? cancelAction; AppDefaultDialog({ required this.title, required this.message, required this.confirmAction, this.cancelAction, }); @override Widget build(BuildContext context) { //使用一个 Column 为最外层容器,可以方便的视线 wrap_content 的效果 return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ //Title (如果使用 Container 为最外层容器则默认为 match_parent 的效果,除非我们限制宽度和最大高度最小高度) Container( width: double.infinity, decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(15)), ), child: Column( children: [ MyTextView( title, fontSize: 19, isFontMedium: true, textColor: ColorConstants.black, marginTop: 15, marginBottom: 15, ), Scrollbar( child: ScrollConfiguration( behavior: NoShadowScrollBehavior(), child: SingleChildScrollView( child: MyTextView( message, fontSize: 16, textColor: Colors.black, isFontRegular: true, textAlign: TextAlign.center, paddingLeft: 30, paddingRight: 30, ), ), ), ).constrained(maxHeight: 210), Container( margin: EdgeInsets.only(top: 25), color: Color(0XFFCECECE), height: 0.5, ), Row( children: [ Expanded( flex: 1, child: InkWell( onTap: () { onCancel(); cancelAction?.call(); }, child: MyTextView( "Cancel", fontSize: 17.5, isFontMedium: true, textAlign: TextAlign.center, textColor: Color(0XFF0085C4), cornerRadius: 3, borderWidth: 1, ), )), Container( color: Color(0xff09141F).withOpacity(0.13), width: 0.5, ), Expanded( flex: 1, child: InkWell( onTap: () async { onCancel(); confirmAction(); }, child: MyTextView( "Confirm", marginLeft: 10, fontSize: 17.5, isFontMedium: true, textAlign: TextAlign.center, textColor: Color(0XFF0085C4), cornerRadius: 3, ), )), ], ).constrained(height: 46), ], ), ), ], ).constrained(width: 295); } //取消弹框 void onCancel() async { SmartDialog.dismiss(); } }