view.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_inappwebview/flutter_inappwebview.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vnoteapp/components/appbar.dart';
  5. import 'controller.dart';
  6. class ContractTemplatePage extends GetView<ContractTemplateController> {
  7. ContractTemplatePage({super.key});
  8. late InAppWebViewController? _webViewController;
  9. @override
  10. Widget build(BuildContext context) {
  11. return Scaffold(
  12. // backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
  13. appBar: VAppBar(
  14. titleWidget: const Text(
  15. "合同",
  16. style: TextStyle(fontSize: 24),
  17. ),
  18. actions: [
  19. TextButton(
  20. onPressed: () async {
  21. await controller.createContractRecord();
  22. Get.back();
  23. },
  24. child: const Text(
  25. '提交',
  26. style: TextStyle(color: Colors.white, fontSize: 20),
  27. ),
  28. ),
  29. const SizedBox(
  30. width: 15,
  31. ),
  32. ],
  33. ),
  34. body: LayoutBuilder(
  35. builder: (BuildContext context, BoxConstraints constraints) {
  36. return Stack(
  37. children: [
  38. SizedBox(
  39. child: Transform.scale(
  40. scale: 1,
  41. child: Container(
  42. width: constraints.maxWidth,
  43. height: constraints.maxHeight,
  44. padding: const EdgeInsets.symmetric(horizontal: 50),
  45. child: Obx(() {
  46. String templateContent = controller.state.templateContent;
  47. if (templateContent.isEmpty) {
  48. return const SizedBox();
  49. } else {
  50. return InAppWebView(
  51. initialData: InAppWebViewInitialData(
  52. data: controller.state.templateContent,
  53. mimeType: 'text/html',
  54. encoding: 'utf-8',
  55. ),
  56. initialOptions: InAppWebViewGroupOptions(
  57. crossPlatform: InAppWebViewOptions(
  58. useShouldOverrideUrlLoading: true,
  59. mediaPlaybackRequiresUserGesture: false,
  60. ),
  61. ),
  62. onWebViewCreated:
  63. (InAppWebViewController controller) {
  64. _webViewController = controller;
  65. },
  66. );
  67. }
  68. }),
  69. ),
  70. ),
  71. ),
  72. Positioned(
  73. bottom: 0,
  74. left: 0,
  75. right: 0,
  76. child: Container(
  77. padding: const EdgeInsets.symmetric(vertical: 15),
  78. color: Colors.white,
  79. alignment: Alignment.bottomCenter,
  80. child: Padding(
  81. padding: const EdgeInsets.symmetric(
  82. horizontal: 100,
  83. vertical: 5,
  84. ),
  85. child: TextButton(
  86. onPressed: () async {
  87. final result = await Get.toNamed("/contract/signature");
  88. controller.state.mock2Base64 = result;
  89. final dto = await controller.contractTemplateManager
  90. .getContractTemplateDetail(
  91. controller.state.templateCode);
  92. if (dto != null) {
  93. controller.state.templateContent =
  94. dto.templateContent ?? '';
  95. controller.getkey();
  96. }
  97. _webViewController?.loadData(
  98. data: controller.state.templateContent,
  99. mimeType: 'text/html',
  100. encoding: 'utf-8');
  101. },
  102. child: const Text(
  103. '签字',
  104. style: TextStyle(fontSize: 30),
  105. ),
  106. ),
  107. ),
  108. ),
  109. )
  110. ],
  111. );
  112. },
  113. ),
  114. );
  115. }
  116. }