attendance_sign_in_out.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import 'dart:typed_data';
  2. import 'dart:ui';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter/widgets.dart';
  6. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  7. import 'package:get/get.dart';
  8. import 'package:widgets/ext/ex_widget.dart';
  9. import 'package:cs_resources/constants/color_constants.dart';
  10. import 'package:widgets/my_text_view.dart';
  11. import 'package:widgets/widget_export.dart';
  12. /**
  13. * 签到签出的签名弹窗
  14. */
  15. class AttendanceSignInOut extends StatelessWidget {
  16. VoidCallback? cancelAction;
  17. void Function(ByteData byteData)? confirmAction;
  18. //签名版配置
  19. HandSignatureControl handSignatureControl = HandSignatureControl(
  20. threshold: 3.0,
  21. smoothRatio: 200 / 240,
  22. velocityRange: 2.0,
  23. );
  24. AttendanceSignInOut({this.cancelAction, this.confirmAction});
  25. @override
  26. Widget build(BuildContext context) {
  27. return Container(
  28. width: 283,
  29. height: 320,
  30. decoration: BoxDecoration(
  31. color: Colors.white, // 设置背景颜色
  32. borderRadius: BorderRadius.circular(15), // 设置圆角
  33. ),
  34. child: Column(
  35. children: [
  36. MyTextView(
  37. "Sign Here".tr,
  38. fontSize: 19,
  39. isFontMedium: true,
  40. textColor: ColorConstants.black,
  41. marginTop: 15,
  42. marginBottom: 12,
  43. ),
  44. Stack(
  45. children: [
  46. //签名
  47. Center(
  48. child: Container(
  49. width: 240,
  50. height: 200,
  51. color: Color(0XFFF0F0F0),
  52. child: HandSignature(
  53. control: handSignatureControl,
  54. color: ColorConstants.black404A5B,
  55. width: 1.0,
  56. maxWidth: 3.5,
  57. type: SignatureDrawType.shape,
  58. ),
  59. ),
  60. ),
  61. //清除签名
  62. Align(
  63. alignment: Alignment.bottomLeft,
  64. child: MyTextView(
  65. "Clean".tr,
  66. fontSize: 12,
  67. textColor: ColorConstants.white,
  68. cornerRadius: 10.37,
  69. backgroundColor: Color(0XFFFFBB1B),
  70. paddingTop: 4,
  71. paddingBottom: 4,
  72. paddingLeft: 11,
  73. paddingRight: 11,
  74. margin: 10,
  75. onClick: () {
  76. handSignatureControl.clear();
  77. },
  78. ),
  79. ),
  80. ],
  81. ).constrained(
  82. width: 240,
  83. height: 200,
  84. ),
  85. Container(
  86. color: Color(0XFFCECECE),
  87. height: 0.5,
  88. margin: EdgeInsets.only(top: 18),
  89. ),
  90. //Buttons
  91. Row(
  92. children: [
  93. Expanded(
  94. flex: 1,
  95. child: InkWell(
  96. onTap: () {
  97. onCancel();
  98. cancelAction?.call();
  99. },
  100. child: MyTextView(
  101. "Cancel".tr,
  102. fontSize: 17.5,
  103. isFontMedium: true,
  104. textAlign: TextAlign.center,
  105. textColor: Color(0XFF0085C4),
  106. cornerRadius: 3,
  107. borderWidth: 1,
  108. ),
  109. )),
  110. Container(
  111. color: Color(0XFFCECECE),
  112. width: 0.5,
  113. ),
  114. Expanded(
  115. flex: 1,
  116. child: InkWell(
  117. onTap: () async {
  118. //签名数据
  119. var byteData = await handSignatureControl.toImage(
  120. format: ImageByteFormat.png,
  121. border: 0,
  122. width: 240,
  123. height: 200,
  124. background: Colors.white,
  125. ) as ByteData;
  126. onCancel();
  127. confirmAction?.call(byteData);
  128. },
  129. child: MyTextView(
  130. "Confirm".tr,
  131. marginLeft: 10,
  132. fontSize: 17.5,
  133. isFontMedium: true,
  134. textAlign: TextAlign.center,
  135. textColor: Color(0XFF0085C4),
  136. cornerRadius: 3,
  137. ),
  138. )),
  139. ],
  140. ).expanded(),
  141. ],
  142. ),
  143. );
  144. }
  145. //取消弹框
  146. void onCancel() async {
  147. SmartDialog.dismiss();
  148. }
  149. }