3
0
Fork 0
trifid_mobile/lib/components/config/ConfigCheckboxItem.dart

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.5 KiB
Dart
Raw Permalink Normal View History

2020-07-27 20:43:58 +00:00
import 'package:flutter/cupertino.dart';
import 'package:mobile_nebula/components/SpecialButton.dart';
import 'package:mobile_nebula/services/utils.dart';
class ConfigCheckboxItem extends StatelessWidget {
const ConfigCheckboxItem(
{Key? key, this.label, this.content, this.labelWidth = 100, this.onChanged, this.checked = false})
2020-07-27 20:43:58 +00:00
: super(key: key);
final Widget? label;
final Widget? content;
2020-07-27 20:43:58 +00:00
final double labelWidth;
final bool checked;
final Function? onChanged;
2020-07-27 20:43:58 +00:00
@override
Widget build(BuildContext context) {
Widget item = Container(
padding: EdgeInsets.only(left: 15),
constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
label != null ? Container(width: labelWidth, child: label) : Container(),
Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))),
checked
? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context), size: 34)
: Container()
],
));
if (onChanged != null) {
return SpecialButton(
color: Utils.configItemBackground(context),
child: item,
onPressed: () {
if (onChanged != null) {
onChanged!();
2020-07-27 20:43:58 +00:00
}
},
);
} else {
return item;
}
}
}