Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/_configs/theme_helper.dart';
5 : import 'package:app_finance/design/wrapper/row_widget.dart';
6 : import 'package:material_ui/material_ui.dart';
7 :
8 : class GridLayer extends StatelessWidget {
9 : final double padding;
10 : final double? width;
11 : final int crossAxisCount;
12 : final List<dynamic> children;
13 : final List<dynamic> strategy;
14 :
15 6 : const GridLayer({
16 : super.key,
17 : required this.padding,
18 : required this.crossAxisCount,
19 : required this.children,
20 : required this.strategy,
21 : this.width,
22 : });
23 :
24 6 : @override
25 : Widget build(BuildContext context) {
26 36 : fnItem(int index) => children[index] is Function ? children[index]() : children[index];
27 48 : fnList(List<dynamic> scope) => scope.map((e) => e is List ? fnList(e).cast<Widget>().toList() : fnItem(e));
28 6 : return Padding(
29 18 : padding: EdgeInsets.only(left: padding, right: padding),
30 18 : child: strategy.length > 1
31 6 : ? RowWidget(
32 6 : indent: padding,
33 6 : maxWidth: width ?? ThemeHelper.getWidth(context, 2),
34 18 : chunk: List.generate(crossAxisCount, (_) => null),
35 24 : children: fnList(strategy).cast<List<Widget>>().toList(),
36 : )
37 0 : : Column(
38 0 : children: fnList(strategy.first).cast<Widget>().toList(),
39 : ),
40 : );
41 : }
42 : }
|