mobile_nebula/lib/components/config/ConfigCheckboxItem.dart

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

53 lines
1.4 KiB
Dart
Raw 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({
super.key,
this.label,
this.content,
this.labelWidth = 100,
this.onChanged,
this.checked = false,
});
2020-07-27 20:43:58 +00:00
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.symmetric(horizontal: 15),
constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
label != null ? SizedBox(width: labelWidth, child: label) : Container(),
Expanded(child: Container(padding: EdgeInsets.only(right: 10), child: content)),
checked
? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context))
: Container(),
],
),
);
2020-07-27 20:43:58 +00:00
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;
}
}
}