import 'package:fis_lib_report/converts/alignment_convert.dart'; import 'package:fis_lib_report/pages/components/datetime.dart'; import 'package:fis_lib_report/pages/components/input_image.dart'; import 'package:fis_lib_report/pages/components/input_text.dart'; import 'package:fis_lib_report/pages/components/line.dart'; import 'package:fis_lib_report/pages/components/multi_selected.dart'; import 'package:fis_lib_report/pages/components/page_number.dart'; import 'package:fis_lib_report/pages/components/single_select.dart'; import 'package:fis_lib_report/pages/components/space.dart'; import 'package:fis_lib_report/pages/components/static_Text.dart'; import 'package:fis_lib_report/pages/components/static_image.dart'; import 'package:fis_lib_report/pages/helpler.dart'; import 'package:fis_lib_report/report/dateTimeElement.dart'; import 'package:fis_lib_report/report/element_type.dart'; import 'package:fis_lib_report/report/inputImage.dart'; import 'package:fis_lib_report/report/inputText.dart'; import 'package:fis_lib_report/report/interfaces/element.dart'; import 'package:fis_lib_report/report/line.dart'; import 'package:fis_lib_report/report/multiSelected.dart'; import 'package:fis_lib_report/report/page_number.dart'; import 'package:fis_lib_report/report/paragraph.dart'; import 'package:fis_lib_report/report/rt_Cell.dart'; import 'package:fis_lib_report/report/rt_table.dart'; import 'package:fis_lib_report/report/singleSelected.dart'; import 'package:fis_lib_report/report/space.dart'; import 'package:fis_lib_report/report/static_text.dart'; import 'package:fis_lib_report/report/static_image.dart'; import 'package:flutter/material.dart'; class ParagraphPage extends StatefulWidget { final Paragraph paragraph; ParagraphPage({Key? key, required this.paragraph}) : super(key: key); @override State createState() { return _ParagraphState(); } } class _ParagraphState extends State { List? _elements = []; int _itemCount = 0; @override initState() { super.initState(); } @override Widget build(BuildContext context) { _elements = widget.paragraph.elements; _itemCount = _elements!.length; if (_itemCount == 0) { return const SizedBox(); } else if (_itemCount == 2 && _elements![0].elementType!.name == ElementType.staticText.name && (_elements![1].elementType!.name == ElementType.singleSelected.name || _elements![1].elementType!.name == ElementType.multiSelected.name || _elements![1].elementType!.name == ElementType.inputText.name)) { try { final staticText = _elements![0]; if (staticText.parent != null) { final paragraph = staticText.parent as Paragraph; if (paragraph.parent != null) { final cell = paragraph.parent as RTCell; if (cell.parent != null) { final table = cell.parent as RTTable; final values = table.cells!.values.toList(); for (var i = 0; i < values.length; i++) { if (values[i] == cell) { final key = table.cells!.keys.toList()[i]; final column = key.column; final width = table.columnDefinitions![column!].width; var valueWidth = 0.0; if (_elements![1].elementType!.name == ElementType.inputText.name) { final input = _elements![1] as InputText; valueWidth = input.lineWidth!; } if (_elements![1].elementType!.name == ElementType.singleSelected.name) { final input = _elements![1] as SingleSelected; valueWidth = input.lineWidth!; } if (_elements![1].elementType!.name == ElementType.multiSelected.name) { final input = _elements![1] as MultiSelected; valueWidth = input.lineWidth!; } final textWidth = width! - valueWidth; final textElement = staticText as StaticText; textElement.lineWidth = textWidth; } } } } } } catch (e) { print(e); } } final margin = widget.paragraph.margin!; return Container( margin: EdgeInsets.only( top: margin.top!, bottom: margin.bottom!, left: margin.left!, right: margin.right!, ), alignment: AlignmentConvert.horizontalConvert( widget.paragraph.horizontalAlignment), child: Wrap( alignment: WrapAlignment.spaceEvenly, children: [ ..._elements!.map((element) { if (element.elementType!.name == ElementType.inputText.name) { InputText inputText = element as InputText; return RInputText(inputText: inputText); } else if (element.elementType!.name == ElementType.staticText.name) { StaticText staticText = element as StaticText; return RStaticText(staticText); } else if (element.elementType!.name == ElementType.singleSelected.name) { SingleSelected singleSelected = element as SingleSelected; return RSingleSelected(singleSelected); } else if (element.elementType!.name == ElementType.line.name) { Line line = element as Line; return RLine(line); } else if (element.elementType!.name == ElementType.dateTime.name) { final dateTime = element as DateTimeElement; return RDateTime(dateTime); } else if (element.elementType!.name == ElementType.multiSelected.name) { final multiSelected = element as MultiSelected; return RMultiSelected(multiSelected); } else if (element.elementType!.name == ElementType.inputImage.name) { final inputImage = element as InputImage; return RInputImage(inputImage); } else if (element.elementType!.name == ElementType.staticImage.name) { final staticImage = element as StaticImage; return RStaticImage(staticImage); } else if (element.elementType!.name == ElementType.space.name) { final space = element as Space; return RSpace(space); } else if (element.elementType!.name == ElementType.pageNumber.name) { final pageNumber = element as PageNumber; return RPageNumber(pageNumber); } return Container( height: 30, width: 180, decoration: TestBoxDecoration.buildDecoration(), child: const Text('未知组件占位'), ); }), ], ), ); } }