import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/components/appbar.dart';
import 'package:vnoteapp/pages/contract/contract_record_html/controller.dart';

class ContractRecordsHtmlPage extends GetView<ContractRecordsHtmlController> {
  const ContractRecordsHtmlPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: VAppBar(
        titleWidget: const Text(
          "合同",
          style: TextStyle(fontSize: 24),
        ),
      ),
      body: Obx(
        () => InAppWebView(
          key: UniqueKey(),
          initialData: InAppWebViewInitialData(
            data:
                '<body style="padding: 100px;">${controller.state.contractRecordDTO.contractedFileUrl ?? ''}</body>',
            mimeType: 'text/html',
            encoding: 'utf-8',
          ),
          initialOptions: InAppWebViewGroupOptions(
            crossPlatform: InAppWebViewOptions(
              useShouldOverrideUrlLoading: true,
              mediaPlaybackRequiresUserGesture: false,
              disableVerticalScroll: false,
            ),
          ),
          onWebViewCreated: (InAppWebViewController controller) {
            // _webViewController = controller;
          },
          onLoadHttpError: (controller, url, statusCode, description) {
            // ignore: avoid_print
            print("InAppWebView onLoadHttpError: $description");
          },
        ),
      ),
    );
  }
}
