Newer
Older
import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
import 'package:reversi/models/settings/settings_activity.dart';
import 'package:reversi/models/settings/settings_global.dart';
class ParameterWidget extends StatelessWidget {
const ParameterWidget({
super.key,
required this.code,
required this.value,
required this.isSelected,
required this.size,
required this.activitySettings,
required this.globalSettings,
required this.onPressed,
});
final String code;
final String value;
final bool isSelected;
final double size;
final ActivitySettings activitySettings;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
final GlobalSettings globalSettings;
final VoidCallback onPressed;
static const Color buttonColorActive = Colors.blue;
static const Color buttonColorInactive = Colors.white;
static const double buttonBorderWidth = 4.0;
static const double buttonBorderRadius = 12.0;
@override
Widget build(BuildContext context) {
Widget content = const SizedBox.shrink();
switch (code) {
default:
printlog('Unknown parameter: $code/$value');
content = getUnknownParameterItem();
}
final Color buttonColor = isSelected ? buttonColorActive : buttonColorInactive;
return Container(
decoration: BoxDecoration(
color: buttonColor,
borderRadius: BorderRadius.circular(buttonBorderRadius),
border: Border.all(
color: buttonColor,
width: buttonBorderWidth,
),
),
child: content,
);
}
// "unknown" parameter -> simple block with text
Widget getUnknownParameterItem() {
return StyledButton.text(
caption: '$code / $value',
color: Colors.grey,
onPressed: null,
);
}
}