Line data Source code
1 : // Copyright 2026 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:app_finance/design/wrapper/text_wrapper.dart';
7 : import 'package:material_ui/material_ui.dart';
8 :
9 : class CheckboxInput extends StatelessWidget {
10 : final String label;
11 : final bool value;
12 : final Function(bool) onChanged;
13 : final BoxConstraints? constraints;
14 : final bool enabled;
15 :
16 0 : const CheckboxInput({
17 : super.key,
18 : required this.label,
19 : required this.value,
20 : required this.onChanged,
21 : this.constraints,
22 : this.enabled = true,
23 : });
24 :
25 0 : @override
26 : Widget build(BuildContext context) {
27 0 : final indent = ThemeHelper.getIndent();
28 0 : final width = ThemeHelper.getWidth(context, 6, constraints);
29 0 : return RowWidget(
30 : indent: indent,
31 : maxWidth: width,
32 : chunk: const [20, null],
33 0 : children: [
34 0 : [
35 0 : if (enabled)
36 0 : Center(
37 : heightFactor: 0.5,
38 0 : child: Checkbox(
39 0 : value: value,
40 0 : onChanged: (newValue) => onChanged(newValue ?? false),
41 : ),
42 : )
43 : else
44 0 : Icon(Icons.indeterminate_check_box_outlined),
45 : ],
46 0 : [
47 0 : TextWrapper(label),
48 : ],
49 : ],
50 : );
51 : }
52 : }
|