import 'package:fis_lib_report/report/cellPostion.dart'; import 'package:fis_lib_report/report/element.dart'; import 'package:fis_lib_report/report/element_type.dart'; import 'package:fis_lib_report/report/interfaces/cell.dart'; import 'package:fis_lib_report/report/interfaces/element.dart'; import 'package:fis_lib_report/report/interfaces/grid.dart'; import 'package:fis_lib_report/report/interfaces/position_layout.dart'; import 'package:fis_lib_report/report/interfaces/report_element.dart'; import 'package:fis_lib_report/report/rt_Cell.dart'; class RTGrid extends Element implements IGrid { @override List? columnDefinitions = []; @override List? elements = []; @override List? rowDefinitions = []; bool? isDelete; bool? isInsertColumn; int? deleteRowIndex; int? deleteColumnIndex; double? divideWidth; bool? isMergeCell; int? mergeDeleteStartColumnIndex; int? mergeDeleteEndColumnIndex; Map? cells = {}; RTGrid(IReportElement parent) : super.fromParent(parent) { horizontalAlignment = HorizontalLayout.Left; elementType = ElementType.rtGrid; columnDefinitions = []; rowDefinitions = []; cells = {}; } RTGrid.fromJson(Map json) : super.fromJson(json) { horizontalAlignment = HorizontalLayout.Left; List jsonColumnDefinitions = json["ColumnDefinitions"] ?? []; for (var map in jsonColumnDefinitions) { if (map is Map) { final rtcolumn = RTColumnDefinition.fromJson(map); columnDefinitions!.add(rtcolumn); } } isDelete = json['IsDelete']; isInsertColumn = json['IsInsertColumn']; deleteRowIndex = json['DeleteRowIndex']; deleteColumnIndex = json['DeleteColumnIndex']; divideWidth = json['DivideWidth']; isMergeCell = json['IsMergeCell']; mergeDeleteStartColumnIndex = json['MergeDeleteStartColumnIndex']; mergeDeleteEndColumnIndex = json['MergeDeleteEndColumnIndex']; List jsonRowDefinitions = json['RowDefinitions'] ?? []; for (var map in jsonRowDefinitions) { if (map is Map) { final rtRow = RTRowDefinition.fromJson(map); rowDefinitions!.add(rtRow); } } //TODO(Loki): elements init List jsonCells = json['Cells']; int index = 0; CellPostion key = CellPostion(); for (var map in jsonCells) { if (index.isEven) { key = CellPostion.fromJson(map); cells![key] = ICell(); } else { final jsonType = map['ElementType']; final type = ElementType.fromJson(jsonType); if (type.name == ElementType.rtCell.name) { final cell = RTCell.fromJson(map, parent: this); cells![key] = cell; } } index++; } } }