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 {
|
2022-09-21 20:27:35 +00:00
|
|
|
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);
|
|
|
|
|
2022-09-21 20:27:35 +00:00
|
|
|
final Widget? label;
|
|
|
|
final Widget? content;
|
2020-07-27 20:43:58 +00:00
|
|
|
final double labelWidth;
|
|
|
|
final bool checked;
|
2022-09-21 20:27:35 +00:00
|
|
|
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) {
|
2022-09-21 20:27:35 +00:00
|
|
|
onChanged!();
|
2020-07-27 20:43:58 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|