attendance_sign_in_out.dart 4.6 KB

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