import 'package:flutter/material.dart'; import 'package:cs_resources/generated/l10n.dart'; import 'package:widgets/ext/ex_widget.dart'; import 'package:cs_resources/theme/app_colors_theme.dart'; import 'package:widgets/my_text_view.dart'; import 'package:widgets/no_shadow_scroll_behavior.dart'; import 'package:widgets/widget_export.dart'; class CommentsDialog extends StatelessWidget { String? title; String? message; Widget? Function(BuildContext)? messageBuilder; VoidCallback confirmAction; VoidCallback? cancelAction; bool isShowCancelBtn; bool isShowConfirmBtn; String? confirmTxt; String? cancelTxt; double? height = 0.0; double? minHeight = 0.0; double? maxHeight = 300.0; CommentsDialog({ this.title, this.message, Widget Function(BuildContext)? this.messageBuilder, required this.confirmAction, this.cancelAction, this.isShowCancelBtn = true, this.isShowConfirmBtn = true, this.confirmTxt, this.cancelTxt, height, minHeight, maxHeight, Key? key, }): height = height?? 0.0, minHeight = minHeight?? 0.0, maxHeight = maxHeight?? 5000, super(key:key); @override Widget build(BuildContext context) { return Container( width: double.infinity, padding: const EdgeInsets.only(top: 30), constraints: BoxConstraints( minHeight: minHeight!, maxHeight: maxHeight!, ), decoration: BoxDecoration( color: context.appColors.whiteSecondBG, borderRadius: const BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(0), ), ), child: SizedBox( height: height!, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Scrollbar( child: ScrollConfiguration( behavior: NoShadowScrollBehavior(), child: SingleChildScrollView( child: messageBuilder?.call(context) ?? MyTextView( message!, fontSize: 18, textColor: context.appColors.textBlack, isFontRegular: true, textAlign: TextAlign.center, paddingLeft: 30, paddingRight: 30, ), ), ), ).constrained(maxHeight: maxHeight! - 60), ), Row( children: [ const SizedBox(width: 18), Visibility( visible: isShowCancelBtn, child: Expanded( flex: 1, child: InkWell( onTap: () { onCancel(); cancelAction?.call(); }, child: MyTextView( cancelTxt ?? S.current.no, fontSize: 16, isFontMedium: true, paddingTop: 13, marginRight: 15, paddingBottom: 13, textAlign: TextAlign.center, textColor: Colors.white, backgroundColor: context.appColors.orangeBG, cornerRadius: 7, ), )), ), Expanded( flex: 1, child: Visibility( visible: isShowConfirmBtn, child: InkWell( onTap: () async { onCancel(); confirmAction(); }, child: MyTextView( confirmTxt ?? S.current.yes, fontSize: 16, paddingTop: 13, paddingBottom: 13, isFontMedium: true, textAlign: TextAlign.center, textColor: Colors.white, backgroundColor: context.appColors.btnBgDefault, cornerRadius: 7, ), ), )), const SizedBox(width: 18), ], ).marginOnly(bottom: 30, top: 28), ], ), ), ); } //取消弹框 void onCancel() async { SmartDialog.dismiss(); } }