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:material_ui/material_ui.dart';
5 :
6 : class BarVerticalGroup extends StatelessWidget {
7 : final List<Color> color;
8 : final List<double> value;
9 : final double height;
10 : final double width;
11 :
12 2 : const BarVerticalGroup({
13 : super.key,
14 : required this.color,
15 : required this.value,
16 : this.height = 32,
17 : this.width = 4,
18 : });
19 :
20 2 : @override
21 : Widget build(BuildContext context) {
22 8 : double left = value.fold(1.0, (v, e) => v - e);
23 6 : value.insert(0, left < 0 ? 0.0 : left);
24 4 : color.insert(0, Colors.grey);
25 2 : return SizedBox(
26 2 : width: width,
27 2 : height: height,
28 2 : child: ListView.builder(
29 4 : itemCount: value.length,
30 2 : itemBuilder: (context, index) {
31 2 : return Container(
32 4 : color: color[index],
33 2 : child: SizedBox(
34 2 : width: width,
35 14 : height: height * (value[index] > 0 ? value[index] : 0.0),
36 : ),
37 : );
38 : },
39 : ),
40 : );
41 : }
42 : }
|