2019-07-09 10:52:25 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:local_spend/common/widgets/custom_checkbox.dart';
|
|
|
|
|
|
|
|
class LabeledCheckboxWithIcon extends StatelessWidget {
|
|
|
|
const LabeledCheckboxWithIcon({
|
|
|
|
this.label,
|
|
|
|
this.textStyle,
|
|
|
|
this.icon,
|
2019-07-09 11:44:05 +00:00
|
|
|
this.iconSize,
|
2019-07-09 10:52:25 +00:00
|
|
|
this.iconColor,
|
|
|
|
this.padding,
|
|
|
|
this.value,
|
|
|
|
this.onChanged,
|
|
|
|
});
|
|
|
|
|
|
|
|
final String label;
|
|
|
|
final TextStyle textStyle;
|
|
|
|
final IconData icon;
|
2019-07-09 11:44:05 +00:00
|
|
|
final double iconSize;
|
2019-07-09 10:52:25 +00:00
|
|
|
final Color iconColor;
|
|
|
|
final EdgeInsets padding;
|
|
|
|
final bool value;
|
|
|
|
final Function onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
onChanged(!value);
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
padding: padding,
|
|
|
|
|
|
|
|
child: Row(
|
2019-07-09 11:44:05 +00:00
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center, //doesn't do anything
|
2019-07-09 10:52:25 +00:00
|
|
|
|
|
|
|
children: <Widget>[
|
2019-07-09 11:44:05 +00:00
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(0),
|
|
|
|
width: iconSize,
|
|
|
|
|
2019-07-09 10:52:25 +00:00
|
|
|
child : Icon(
|
|
|
|
icon,
|
2019-07-09 11:44:05 +00:00
|
|
|
// size: iconSize,
|
2019-07-09 10:52:25 +00:00
|
|
|
color: iconColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
Expanded(child: Text(label, style: textStyle, textAlign: TextAlign.center,)),
|
|
|
|
|
|
|
|
CustomCheckbox(
|
|
|
|
//custom checkbox removes padding so the form looks nice
|
|
|
|
|
|
|
|
value: value,
|
|
|
|
useTapTarget: false,
|
|
|
|
onChanged: (bool newValue) {
|
|
|
|
onChanged(newValue);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LabeledCheckbox extends StatelessWidget {
|
|
|
|
const LabeledCheckbox({
|
|
|
|
this.label,
|
|
|
|
this.textStyle,
|
|
|
|
this.padding,
|
|
|
|
this.value,
|
|
|
|
this.onChanged,
|
|
|
|
});
|
|
|
|
|
|
|
|
final String label;
|
|
|
|
final TextStyle textStyle;
|
|
|
|
final EdgeInsets padding;
|
|
|
|
final bool value;
|
|
|
|
final Function onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
onChanged(!value);
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: padding,
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(child: Text(label, style: textStyle)),
|
|
|
|
|
2019-07-09 11:44:05 +00:00
|
|
|
CustomCheckbox(
|
|
|
|
//custom checkbox removes padding so the form looks nice
|
|
|
|
|
2019-07-09 10:52:25 +00:00
|
|
|
value: value,
|
2019-07-09 11:44:05 +00:00
|
|
|
useTapTarget: false,
|
2019-07-09 10:52:25 +00:00
|
|
|
onChanged: (bool newValue) {
|
|
|
|
onChanged(newValue);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
//USAGE:
|
|
|
|
|
|
|
|
bool _isSelected = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
body: Center(
|
|
|
|
child: LabeledCheckbox(
|
|
|
|
label: 'Label Text Here',
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
value: _isSelected,
|
|
|
|
|
|
|
|
onChanged: (bool newValue) {
|
|
|
|
setState(() {
|
|
|
|
_isSelected = newValue;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
*/
|