view.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import 'package:fis_ui/index.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vitalapp/architecture/storage/file_storage.dart';
  5. import 'package:vitalapp/pages/report_preview/controller.dart';
  6. import 'package:fis_lib_pdf/pdf_render_container.dart';
  7. import 'package:fis_lib_pdf/ultils/pdf_access_type.dart';
  8. import 'package:fis_lib_pdf/ultils/pdf381_wrapper/pdf381_preview_ext.dart';
  9. // ///报告预览页面
  10. // class ReportPreviewPage extends GetView<ReportPreviewController> {
  11. // const ReportPreviewPage({Key? key}) : super(key: key);
  12. // @override
  13. // Widget build(BuildContext context) {
  14. // return Obx(() {
  15. // if (controller.state.isLoaded) {
  16. // List<FWidget> children = ReportPreviewController.imageOrFileUrls
  17. // .map(
  18. // (e) => FContainer(
  19. // child: FImage.network(
  20. // e,
  21. // fit: BoxFit.fitWidth,
  22. // ),
  23. // ),
  24. // )
  25. // .toList();
  26. // return LayoutBuilder(
  27. // builder: (BuildContext context, BoxConstraints constraints) {
  28. // print(
  29. // '${MediaQuery.of(context).size.height} ,, ${constraints.maxHeight}');
  30. // return InteractiveViewer(
  31. // constrained: false,
  32. // minScale: 0.5,
  33. // child: FContainer(
  34. // width: constraints.maxWidth,
  35. // child: FColumn(
  36. // mainAxisAlignment: MainAxisAlignment.center,
  37. // children: children,
  38. // ),
  39. // ),
  40. // );
  41. // },
  42. // );
  43. // // return FStack(
  44. // // children: [
  45. // // FPDFRenderContainer(
  46. // // pdfTypeEnum: ReportPreviewController.pdfType,
  47. // // demoMode: false,
  48. // // pdfAccessTypeEnum: PDFAccessTypeEnum.preview,
  49. // // fileName: _generateReaportFileName(),
  50. // // pdfExporter: TextMediaFileExporterForShell.exportFile,
  51. // // cacheGet: controller.fileStorage.read,
  52. // // cacheSave: controller.fileStorage.save,
  53. // // fromEditor: ReportPreviewController.isFromEditor,
  54. // // webSideShare: controller.shareReport,
  55. // // imageOrFileUrls: ReportPreviewController.imageOrFileUrls,
  56. // // onClose: controller.onPDFClose,
  57. // // customAction: [],
  58. // // ),
  59. // // ],
  60. // // );
  61. // } else {
  62. // return FSizedBox();
  63. // }
  64. // });
  65. // }
  66. // ///获取报告名称
  67. // String _generateReaportFileName() {
  68. // return controller.state.reportName;
  69. // }
  70. // }
  71. ///桌面端布局
  72. class ReportPreviewPage extends GetView<ReportPreviewController> {
  73. @override
  74. Widget build(BuildContext context) {
  75. return Obx(() {
  76. if (controller.state.isLoaded) {
  77. return FStack(
  78. children: [
  79. FPDFRenderContainer(
  80. pdfTypeEnum: ReportPreviewController.pdfType,
  81. demoMode: false,
  82. pdfAccessTypeEnum: PDFAccessTypeEnum.preview,
  83. fileName: _generateReaportFileName(),
  84. pdfExporter: TextMediaFileExporterForShell.exportFile,
  85. cacheGet: (a) async {
  86. return null;
  87. },
  88. cacheSave: (a, b) async {
  89. return false;
  90. },
  91. fromEditor: ReportPreviewController.isFromEditor,
  92. webSideShare: controller.shareReport,
  93. imageOrFileUrls: ReportPreviewController.imageOrFileUrls,
  94. onClose: controller.onPDFClose,
  95. customAction: [
  96. SelfPdfPreviewAction(
  97. content: '关闭',
  98. icon: Icon(Icons.close),
  99. onPressed: (context, build, pageFormat) {
  100. Get.back();
  101. },
  102. ),
  103. ],
  104. ),
  105. ],
  106. );
  107. } else {
  108. return FSizedBox();
  109. }
  110. });
  111. }
  112. ///获取报告名称
  113. String _generateReaportFileName() {
  114. return controller.state.reportName;
  115. }
  116. }