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/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/static_text.dart'; import 'package:fis_lib_report/report/static_image.dart'; import 'package:fis_lib_report/report_info/block_element_info_interface.dart'; import 'package:fis_lib_report/report_info/date_time_info.dart'; import 'package:fis_lib_report/report_info/element_info.dart'; import 'package:fis_lib_report/report_info/input_image_info.dart'; import 'package:fis_lib_report/report_info/input_text_info.dart'; import 'package:fis_lib_report/report_info/line_info.dart'; import 'package:fis_lib_report/report_info/multi_selected_info.dart'; import 'package:fis_lib_report/report_info/page_number_info.dart'; import 'package:fis_lib_report/report_info/single_selected_info.dart'; import 'package:fis_lib_report/report_info/static_image_info.dart'; import 'package:fis_lib_report/report_info/static_text_info.dart'; class ParagraphInfo extends ElementInfo implements IBlockElementInfo { double? lineSpace; @override List? elementInfos = []; bool? isEmptyFirst; ParagraphInfo.fromElement(Paragraph paragraph) : super.fromElement(paragraph) { final elements = paragraph.elements; for (var element in elements!) { if (element.elementType!.name == ElementType.inputText.name) { InputText inputText = element as InputText; elementInfos!.add(InputTextInfo.fromElement(inputText)); } else if (element.elementType!.name == ElementType.staticText.name) { StaticText staticText = element as StaticText; elementInfos!.add(StaticTextInfo.fromElement(staticText)); } else if (element.elementType!.name == ElementType.singleSelected.name) { SingleSelected singleSelected = element as SingleSelected; elementInfos!.add(SingleSelectedInfo.fromElement(singleSelected)); } else if (element.elementType!.name == ElementType.dateTime.name) { final dateTime = element as DateTimeElement; elementInfos!.add(DateTimeInfo.fromElement(dateTime)); } else if (element.elementType!.name == ElementType.multiSelected.name) { final multiSelected = element as MultiSelected; elementInfos!.add(MulitiSelectedInfo.fromElement(multiSelected)); } else if (element.elementType!.name == ElementType.inputImage.name) { final inputImage = element as InputImage; elementInfos!.add(InputImageInfo.fromElement(inputImage)); } else if (element.elementType!.name == ElementType.staticImage.name) { final inputImage = element as StaticImage; elementInfos!.add(StaticImageInfo.fromElement(inputImage)); } else if (element.elementType!.name == ElementType.pageNumber.name) { final pageNumber = element as PageNumber; elementInfos!.add(PageNumberInfo.fromElement(pageNumber)); } else if (element.elementType!.name == ElementType.line.name) { final pageNumber = element as Line; elementInfos!.add(LineInfo.fromElement(pageNumber)); } } } @override Map toJson() { final map = {}; map.addAll(super.toJson()); final elementInfosmap = {}; elementInfosmap.addAll(super.toJson()); for (var element in elementInfos!) { if (element.elementType!.name == ElementType.inputText.name) { final inputText = element as InputTextInfo; elementInfosmap.addAll(inputText.toJson()); } else if (element.elementType!.name == ElementType.staticText.name) { final staticText = element as StaticTextInfo; elementInfosmap.addAll(staticText.toJson()); } else if (element.elementType!.name == ElementType.singleSelected.name) { final singleSelected = element as SingleSelectedInfo; elementInfosmap.addAll(singleSelected.toJson()); } else if (element.elementType!.name == ElementType.dateTime.name) { final dateTime = element as DateTimeInfo; elementInfosmap.addAll(dateTime.toJson()); } else if (element.elementType!.name == ElementType.multiSelected.name) { final elementInfo = element as MulitiSelectedInfo; elementInfosmap.addAll(elementInfo.toJson()); } else if (element.elementType!.name == ElementType.inputImage.name) { final elementInfo = element as InputImageInfo; elementInfosmap.addAll(elementInfo.toJson()); } else if (element.elementType!.name == ElementType.staticImage.name) { final elementInfo = element as StaticImageInfo; elementInfosmap.addAll(elementInfo.toJson()); } else if (element.elementType!.name == ElementType.pageNumber.name) { final elementInfo = element as PageNumberInfo; elementInfosmap.addAll(elementInfo.toJson()); } else if (element.elementType!.name == ElementType.line.name) { final elementInfo = element as LineInfo; elementInfosmap.addAll(elementInfo.toJson()); } } map['ElementInfos'] = elementInfos; return map; } }