import 'dart:typed_data'; import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:widgets/ext/ex_widget.dart'; import 'package:cs_resources/constants/color_constants.dart'; import 'package:widgets/my_text_view.dart'; import 'package:widgets/widget_export.dart'; /** * 签到签出的签名弹窗 */ class AttendanceSignInOut extends StatelessWidget { VoidCallback? cancelAction; void Function(ByteData byteData)? confirmAction; //签名版配置 HandSignatureControl handSignatureControl = HandSignatureControl( threshold: 3.0, smoothRatio: 200 / 240, velocityRange: 2.0, ); AttendanceSignInOut({this.cancelAction, this.confirmAction}); @override Widget build(BuildContext context) { return Container( width: 283, height: 320, decoration: BoxDecoration( color: Colors.white, // 设置背景颜色 borderRadius: BorderRadius.circular(15), // 设置圆角 ), child: Column( children: [ MyTextView( "Sign Here".tr, fontSize: 19, isFontMedium: true, textColor: ColorConstants.black, marginTop: 15, marginBottom: 12, ), Stack( children: [ //签名 Center( child: Container( width: 240, height: 200, color: Color(0XFFF0F0F0), child: HandSignature( control: handSignatureControl, color: ColorConstants.black404A5B, width: 1.0, maxWidth: 3.5, type: SignatureDrawType.shape, ), ), ), //清除签名 Align( alignment: Alignment.bottomLeft, child: MyTextView( "Clean".tr, fontSize: 12, textColor: ColorConstants.white, cornerRadius: 10.37, backgroundColor: Color(0XFFFFBB1B), paddingTop: 4, paddingBottom: 4, paddingLeft: 11, paddingRight: 11, margin: 10, onClick: () { handSignatureControl.clear(); }, ), ), ], ).constrained( width: 240, height: 200, ), Container( color: Color(0XFFCECECE), height: 0.5, margin: EdgeInsets.only(top: 18), ), //Buttons Row( children: [ Expanded( flex: 1, child: InkWell( onTap: () { onCancel(); cancelAction?.call(); }, child: MyTextView( "Cancel".tr, fontSize: 17.5, isFontMedium: true, textAlign: TextAlign.center, textColor: Color(0XFF0085C4), cornerRadius: 3, borderWidth: 1, ), )), Container( color: Color(0XFFCECECE), width: 0.5, ), Expanded( flex: 1, child: InkWell( onTap: () async { //签名数据 var byteData = await handSignatureControl.toImage( format: ImageByteFormat.png, border: 0, width: 240, height: 200, background: Colors.white, ) as ByteData; onCancel(); confirmAction?.call(byteData); }, child: MyTextView( "Confirm".tr, marginLeft: 10, fontSize: 17.5, isFontMedium: true, textAlign: TextAlign.center, textColor: Color(0XFF0085C4), cornerRadius: 3, ), )), ], ).expanded(), ], ), ); } //取消弹框 void onCancel() async { SmartDialog.dismiss(); } }