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_imageList.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_select.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/interfaces/position_layout.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/singleSelected.dart'; import 'package:fis_lib_report/report/space.dart'; import 'package:fis_lib_report/report/staticText.dart'; import 'package:fis_lib_report/report/static_image.dart'; import 'package:fis_lib_report/report_info/report_info.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() { _elements = widget.paragraph.elements; _itemCount = _elements!.length; super.initState(); } @override Widget build(BuildContext context) { if (_itemCount == 0) { return const SizedBox(); } 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; if (staticText.lineWidth == 0) { staticText.lineWidth = staticText.lineLength! * 10.5; } 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('未知组件占位'), ); }), ], ), ); } void _showMultiSelect(List? items) async { // a list of selectable items // these items can be hard-coded or dynamically fetched from a database/API if (items!.isEmpty) { return; } final List? results = await showDialog( context: context, builder: (BuildContext context) { return MultiSelect(items: items); }, ); } }