Resolves #145 Fan support

This commit is contained in:
Yegor Vialov
2018-11-24 17:00:45 +02:00
parent a36c7a9ca3
commit 5f3c77f4b9
6 changed files with 180 additions and 9 deletions

View File

@ -6,27 +6,22 @@ class ModeSwitchWidget extends StatelessWidget {
final onChange;
final double captionFontSize;
final bool value;
final bool expanded;
ModeSwitchWidget({
Key key,
@required this.caption,
@required this.onChange,
this.captionFontSize,
this.value
this.value,
this.expanded: true
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Expanded(
child: Text(
"$caption",
style: TextStyle(
fontSize: captionFontSize ?? Sizes.stateFontSize
),
),
),
_buildCaption(),
Switch(
onChanged: (value) => onChange(value),
value: value ?? false,
@ -35,4 +30,19 @@ class ModeSwitchWidget extends StatelessWidget {
);
}
Widget _buildCaption() {
Widget captionWidget = Text(
"$caption",
style: TextStyle(
fontSize: captionFontSize ?? Sizes.stateFontSize
),
);
if (expanded) {
return Expanded(
child: captionWidget,
);
}
return captionWidget;
}
}