Эх сурвалжийг харах

修复报告模板在宽度特别大的情况内容不居中的问题

loki.wu 2 жил өмнө
parent
commit
0d929fcc45

+ 1 - 0
lib/main.dart

@@ -79,6 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
     ];
 
     return Scaffold(
+      backgroundColor: Colors.white,
       body: Row(
         children: [
           if (_jsonStr.isNotEmpty)

+ 3 - 1
lib/pages/block_element_page.dart

@@ -38,7 +38,9 @@ class _BlockElementState extends State<BlockElementPage> {
       return ParagraphPage(paragraph: paragraph);
     } else if (_type != null && _type!.name == ElementType.imageList!.name) {
       final inputImageList = widget.element as InputImageList;
-      return RInputImageList(inputImageList);
+      return Center(
+        child: RInputImageList(inputImageList),
+      );
     }
     return Container(
       height: 20,

+ 35 - 25
lib/report_edit.dart

@@ -60,31 +60,41 @@ class _ReportEditPageState extends State<ReportEditPage> {
     if (widget.jsonStr.isEmpty) {
       return const SizedBox();
     }
-    // if (!isInit) {
-    //  // _intitTemplate();
-    // }
-    return Container(
-      decoration: _buildDecoration(),
-      padding: _padding,
-      alignment: Alignment.center,
-      height: _height,
-      width: _width,
-      child: ListView(
-        children: [
-          ..._header.map((head) {
-            return BlockElementPage(element: head);
-          }),
-          ..._blocks.map((block) {
-            return SizedBox(
-              width: _width,
-              child: BlockElementPage(element: block),
-            );
-          }),
-          const SizedBox(height: 10),
-          ..._footer.map((footer) {
-            return BlockElementPage(element: footer);
-          }),
-        ],
+    final pagePadding = _reportTemplate.pagePadding ?? RTThickness.uniform(56);
+    return Center(
+      child: Container(
+        padding: _padding,
+        alignment: Alignment.center,
+        height: _height,
+        width: _width,
+        color: Colors.white,
+        child: ListView(
+          children: [
+            ..._header.map((head) {
+              return Container(
+                width: _width,
+                alignment: Alignment.center,
+                child: BlockElementPage(element: head),
+              );
+            }),
+            ..._blocks.map((block) {
+              return Container(
+                alignment: Alignment.center,
+                width: _width,
+                child: BlockElementPage(element: block),
+              );
+            }),
+            const SizedBox(height: 10),
+            ..._footer.map((footer) {
+              return SizedBox(
+                width: _width -
+                    PtToPxConverter.ptToPx(
+                        pagePadding.left! + pagePadding.right!),
+                child: BlockElementPage(element: footer),
+              );
+            }),
+          ],
+        ),
       ),
     );
   }