// Author: fengshengxiong // Date: 2024/5/9 // Description: 进度框 import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:hello_wallpaper/common/components/view_state_widget.dart'; import 'package:hello_wallpaper/common/utils/obj_util.dart'; class ProcessDialog extends StatelessWidget { final double process; final String processStr; final Function() cancelOnTap; final bool showCanCancel; const ProcessDialog( this.process, this.processStr, { super.key, this.showCanCancel = true, required this.cancelOnTap, }); @override Widget build(BuildContext context) { return PopScope( canPop: false, child: Center( child: IntrinsicWidth( child: Container( constraints: BoxConstraints( minWidth: 80.w, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8).r, ), child: IntrinsicHeight( child: Container( padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox(height: 10.h), loadingView( valueColor: const AlwaysStoppedAnimation(Colors.black), value: process, ), if (ObjUtil.isNotEmptyStr(processStr)) ...[ SizedBox(height: 10.h), Expanded( child: Text( processStr, textAlign: TextAlign.center, style: TextStyle( fontSize: 14.sp, color: Colors.black, ), ), ), ], if (!showCanCancel) ...[ SizedBox(height: 10.h), ], if (showCanCancel) ...[ SizedBox( height: 40.h, child: TextButton( style: TextButton.styleFrom( padding: EdgeInsets.zero, backgroundColor: Colors.transparent, ), onPressed: cancelOnTap, child: Text( 'Cancel', style: TextStyle( color: Colors.black, fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ), ), ], ], ), ), ), ), ), ), ); } }