123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import 'package:flutter/material.dart';
- import 'package:flutter_inappwebview/flutter_inappwebview.dart';
- import 'package:get/get.dart';
- import 'package:vnoteapp/components/appbar.dart';
- import 'controller.dart';
- class ContractTemplatePage extends GetView<ContractTemplateController> {
- ContractTemplatePage({super.key});
- late InAppWebViewController? _webViewController;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- // backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
- appBar: VAppBar(
- titleWidget: const Text(
- "合同",
- style: TextStyle(fontSize: 24),
- ),
- actions: [
- TextButton(
- onPressed: () async {
- await controller.createContractRecord();
- Get.back();
- },
- child: const Text(
- '提交',
- style: TextStyle(color: Colors.white, fontSize: 20),
- ),
- ),
- const SizedBox(
- width: 15,
- ),
- ],
- ),
- body: LayoutBuilder(
- builder: (BuildContext context, BoxConstraints constraints) {
- return Stack(
- children: [
- SizedBox(
- child: Transform.scale(
- scale: 1,
- child: Container(
- width: constraints.maxWidth,
- height: constraints.maxHeight,
- padding: const EdgeInsets.symmetric(horizontal: 50),
- child: Obx(() {
- String templateContent = controller.state.templateContent;
- if (templateContent.isEmpty) {
- return const SizedBox();
- } else {
- return InAppWebView(
- initialData: InAppWebViewInitialData(
- data: controller.state.templateContent,
- mimeType: 'text/html',
- encoding: 'utf-8',
- ),
- initialOptions: InAppWebViewGroupOptions(
- crossPlatform: InAppWebViewOptions(
- useShouldOverrideUrlLoading: true,
- mediaPlaybackRequiresUserGesture: false,
- ),
- ),
- onWebViewCreated:
- (InAppWebViewController controller) {
- _webViewController = controller;
- },
- );
- }
- }),
- ),
- ),
- ),
- Positioned(
- bottom: 0,
- left: 0,
- right: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 15),
- color: Colors.white,
- alignment: Alignment.bottomCenter,
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 100,
- vertical: 5,
- ),
- child: TextButton(
- onPressed: () async {
- final result = await Get.toNamed("/contract/signature");
- controller.state.mock2Base64 = result;
- final dto = await controller.contractTemplateManager
- .getContractTemplateDetail(
- controller.state.templateCode);
- if (dto != null) {
- controller.state.templateContent =
- dto.templateContent ?? '';
- controller.getkey();
- }
- _webViewController?.loadData(
- data: controller.state.templateContent,
- mimeType: 'text/html',
- encoding: 'utf-8');
- },
- child: const Text(
- '签字',
- style: TextStyle(fontSize: 30),
- ),
- ),
- ),
- ),
- )
- ],
- );
- },
- ),
- );
- }
- }
|