|
@@ -0,0 +1,172 @@
|
|
|
+import 'package:fis_lib_report/pages/components/multi_select.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/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/multiSelected.dart';
|
|
|
+import 'package:fis_lib_report/report/paragraph.dart';
|
|
|
+import 'package:fis_lib_report/report/singleSelected.dart';
|
|
|
+import 'package:fis_lib_report/report/staticText.dart';
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+
|
|
|
+class ParagraphPage extends StatefulWidget {
|
|
|
+ final Paragraph paragraph;
|
|
|
+
|
|
|
+ ParagraphPage({Key? key, required this.paragraph}) : super(key: key);
|
|
|
+
|
|
|
+ @override
|
|
|
+ State<StatefulWidget> createState() {
|
|
|
+ return _ParagraphState();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class _ParagraphState extends State<ParagraphPage> {
|
|
|
+ final _controller = TextEditingController();
|
|
|
+ List<IElement>? _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();
|
|
|
+ }
|
|
|
+ return Row(
|
|
|
+ mainAxisAlignment:
|
|
|
+ widget.paragraph.horizontalAlignment == HorizontalLayout.Center
|
|
|
+ ? MainAxisAlignment.center
|
|
|
+ : MainAxisAlignment.start,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ ..._elements!.map((element) {
|
|
|
+ if (element.elementType!.name == ElementType.inputText!.name) {
|
|
|
+ InputText inputText = element as InputText;
|
|
|
+ return Container(
|
|
|
+ color: Colors.white,
|
|
|
+ width: inputText.lineWidth! * 1.5,
|
|
|
+ height: inputText.lineWidth! / 3.5,
|
|
|
+ child: TextField(
|
|
|
+ decoration: const InputDecoration(
|
|
|
+ isCollapsed: true,
|
|
|
+ contentPadding:
|
|
|
+ EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
|
|
+ hintText: '',
|
|
|
+ border: OutlineInputBorder(
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(4.0)),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ maxLines: 6,
|
|
|
+ controller: _controller,
|
|
|
+ textAlign: TextAlign.start,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 18,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ } else if (element.elementType!.name ==
|
|
|
+ ElementType.staticText!.name) {
|
|
|
+ StaticText staticText = element as StaticText;
|
|
|
+ return SizedBox(
|
|
|
+ width: staticText.text!.length > 10 ? 300 : 110,
|
|
|
+ child: Text(staticText.text!),
|
|
|
+ );
|
|
|
+ } else if (element.elementType!.name ==
|
|
|
+ ElementType.singleSelected!.name) {
|
|
|
+ SingleSelected singleSelected = element as SingleSelected;
|
|
|
+
|
|
|
+ List<String>? values = singleSelected.items;
|
|
|
+
|
|
|
+ if (values != null && values.isNotEmpty) {
|
|
|
+ return SizedBox(
|
|
|
+ width: 104,
|
|
|
+ height: 30,
|
|
|
+ child: DropdownButton(
|
|
|
+ onChanged: (Object? value) {},
|
|
|
+ items: values.map<DropdownMenuItem<String>>((String value) {
|
|
|
+ return DropdownMenuItem<String>(
|
|
|
+ value: value,
|
|
|
+ child: Text(value),
|
|
|
+ );
|
|
|
+ }).toList(),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else if (element.elementType!.name == ElementType.line!.name) {
|
|
|
+ return Container(
|
|
|
+ margin: const EdgeInsets.symmetric(vertical: 10),
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 0),
|
|
|
+ width: 760,
|
|
|
+ child: const Divider(
|
|
|
+ height: 1,
|
|
|
+ thickness: 1,
|
|
|
+ color: Colors.black,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ } else if (element.elementType!.name == ElementType.dateTime!.name) {
|
|
|
+ final dateTime = element as DateTimeElement;
|
|
|
+ final currentDateTime = DateTime.now();
|
|
|
+ final text = currentDateTime.toString().substring(0, 10);
|
|
|
+ return Container(
|
|
|
+ width: 110,
|
|
|
+ child: Text(text),
|
|
|
+ );
|
|
|
+ } else if (element.elementType!.name ==
|
|
|
+ ElementType.multiSelected!.name) {
|
|
|
+ final multiSelected = element as MultiSelected;
|
|
|
+
|
|
|
+ List<String>? values = multiSelected.items;
|
|
|
+ return SizedBox(
|
|
|
+ width: 120,
|
|
|
+ height: 30,
|
|
|
+ child: TextField(
|
|
|
+ cursorWidth: 0,
|
|
|
+ mouseCursor: SystemMouseCursors.click,
|
|
|
+ decoration: const InputDecoration(
|
|
|
+ suffixIcon: Icon(Icons.arrow_drop_down),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ _showMultiSelect(values);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return Container(
|
|
|
+ height: 30,
|
|
|
+ width: 80,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ border: Border.all(
|
|
|
+ width: 0.5,
|
|
|
+ color: const Color.fromARGB(255, 83, 83, 83),
|
|
|
+ ),
|
|
|
+ color: Colors.grey[200]),
|
|
|
+ child: const Text('组件占位'),
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ void _showMultiSelect(List<String>? items) async {
|
|
|
+
|
|
|
+
|
|
|
+ if (items!.isEmpty) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ final List<String>? results = await showDialog(
|
|
|
+ context: context,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return MultiSelect(items: items);
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|