1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import 'dart:math';
- import 'package:fis_lib_report/pages/rt_cell.dart';
- import 'package:fis_lib_report/report/cellPostion.dart';
- import 'package:fis_lib_report/report/interfaces/block_element.dart';
- import 'package:fis_lib_report/report/interfaces/cell.dart';
- import 'package:fis_lib_report/report/interfaces/rt_table.dart';
- import 'package:fis_lib_report/report/rt_Cell.dart';
- import 'package:fis_lib_report/report/rt_table.dart';
- import 'package:flutter/cupertino.dart';
- class RTTablePage extends StatefulWidget {
- const RTTablePage({required this.element, Key? key}) : super(key: key);
- final RTTable element;
- @override
- State<StatefulWidget> createState() {
- return _RTTableState();
- }
- }
- class _RTTableState extends State<RTTablePage> {
- Map<CellPostion, ICell>? _cells;
- List<ICell>? _values = [];
- int? _column;
- int? _row;
- @override
- initState() {
- super.initState();
- _cells = widget.element.cells ?? {};
- List<CellPostion> cellPostions = _cells!.keys.toList();
- cellPostions.sort(((a, b) => (b.column!).compareTo(a.column!)));
- // +1 为列数
- _column = cellPostions.first.column! + 1;
- _values = _cells!.values.toList();
- _row = widget.element.rowDefinitions!.length;
- }
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- height: _row! * 40,
- child: (_column == null || _column == 0 || _values!.isEmpty)
- ? const SizedBox()
- : GridView.builder(
- controller: ScrollController(),
- shrinkWrap: true,
- itemCount: _values!.length,
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: _column!,
- childAspectRatio: _column == 3 ? 6.6 : 24,
- ),
- itemBuilder: (BuildContext context, int index) {
- final cell = _values![index];
- RTCell c = cell as RTCell;
- return RTCellPage(
- cell: c,
- );
- },
- ),
- );
- }
- }
|