signature_page.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import 'package:cpt_form/modules/apply/vm/apply_view_model.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:auto_route/auto_route.dart';
  6. import 'package:flutter_hooks/flutter_hooks.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:router/ext/auto_router_extensions.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_appbar.dart';
  11. import 'package:widgets/my_button.dart';
  12. import 'package:widgets/my_text_view.dart';
  13. import 'package:widgets/widget_export.dart';
  14. import '../../router/page/form_page_router.dart';
  15. @RoutePage()
  16. class SignaturePage extends HookConsumerWidget {
  17. const SignaturePage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance({BuildContext? context}) {
  20. if (context != null) {
  21. context.router.push(const SignaturePageRoute());
  22. } else {
  23. appRouter.push(const SignaturePageRoute());
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. final viewModel = ref.watch(applyViewModelProvider.notifier);
  29. final state = ref.watch(applyViewModelProvider);
  30. //签名版配置
  31. HandSignatureControl handSignatureControl = HandSignatureControl(
  32. threshold: 3.0,
  33. smoothRatio: 190 / 345,
  34. velocityRange: 2.0,
  35. );
  36. useEffect(() {
  37. //赋值State的值
  38. Future.microtask(() {});
  39. return () {
  40. // 组件卸载时执行
  41. handSignatureControl.dispose();
  42. };
  43. }, []);
  44. return WillPopScope(
  45. child: Scaffold(
  46. appBar: MyAppBar.appBar(context, state.applyDetail?['title']),
  47. backgroundColor: context.appColors.backgroundWhite,
  48. body: Column(
  49. crossAxisAlignment: CrossAxisAlignment.start,
  50. children: [
  51. SingleChildScrollView(
  52. scrollDirection: Axis.vertical,
  53. physics: const BouncingScrollPhysics(),
  54. child: Container(
  55. margin: const EdgeInsets.symmetric(horizontal: 15),
  56. width: double.infinity,
  57. child: Column(
  58. mainAxisSize: MainAxisSize.max,
  59. crossAxisAlignment: CrossAxisAlignment.start,
  60. children: [
  61. MyTextView(
  62. S.current.signature,
  63. fontSize: 17,
  64. marginTop: 30,
  65. isFontMedium: true,
  66. textColor: context.appColors.textBlack,
  67. ),
  68. //签名的说明文本
  69. MyTextView(
  70. state.applyDetail?['detail_data']['signature_txt'],
  71. fontSize: 15,
  72. marginTop: 26,
  73. marginBottom: 21,
  74. isFontRegular: true,
  75. textColor: context.appColors.textBlack,
  76. ),
  77. //签名框
  78. Stack(
  79. children: [
  80. //签名
  81. Center(
  82. child: Container(
  83. width: 345,
  84. height: 190,
  85. color: context.appColors.imgGrayBg,
  86. child: HandSignature(
  87. control: handSignatureControl,
  88. color: context.appColors.textBlack,
  89. width: 1.0,
  90. maxWidth: 3.5,
  91. type: SignatureDrawType.shape,
  92. ),
  93. ),
  94. ),
  95. //清除签名
  96. Align(
  97. alignment: Alignment.bottomRight,
  98. child: MyTextView(
  99. S.current.clean,
  100. fontSize: 12,
  101. textColor: Colors.white,
  102. cornerRadius: 10.37,
  103. backgroundColor: context.appColors.btnBgDefault,
  104. paddingTop: 4,
  105. paddingBottom: 4,
  106. paddingLeft: 11,
  107. paddingRight: 11,
  108. margin: 10,
  109. onClick: () {
  110. handSignatureControl.clear();
  111. },
  112. ),
  113. ),
  114. ],
  115. ).constrained(
  116. width: 345,
  117. height: 190,
  118. ),
  119. RichText(
  120. text: TextSpan(
  121. style: TextStyle(fontSize: 15, fontWeight: FontWeight.w400, color: context.appColors.textBlack),
  122. children: <TextSpan>[
  123. TextSpan(
  124. text: S.current.signed_and_agreed_by,
  125. ),
  126. TextSpan(
  127. text: " Wu Bing Bing ",
  128. style: TextStyle(color: context.appColors.textPrimary),
  129. ),
  130. TextSpan(
  131. text: " 21 Nov 2024, 03:08 PM",
  132. ),
  133. ],
  134. ),
  135. ).marginOnly(top: 21,bottom: 21),
  136. ],
  137. ),
  138. ),
  139. ).expanded(),
  140. //底部按钮
  141. MyButton(
  142. onPressed: viewModel.gotoNextPage,
  143. text: S.current.submit,
  144. textColor: Colors.white,
  145. backgroundColor: context.appColors.btnBgDefault,
  146. fontWeight: FontWeight.w500,
  147. type: ClickType.throttle,
  148. fontSize: 16,
  149. minHeight: 50,
  150. radius: 0,
  151. ),
  152. ],
  153. )),
  154. onWillPop: () async {
  155. viewModel.handlePopAction();
  156. return true;
  157. });
  158. }
  159. }