Resolves #160 Flexible entity heigth

This commit is contained in:
Yegor Vialov
2018-11-04 22:55:09 +02:00
parent 66f84952f0
commit 788d682f2f
4 changed files with 38 additions and 29 deletions

View File

@ -13,7 +13,7 @@ class DefaultEntityContainer extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
height: height, //height: height,
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
EntityIcon(), EntityIcon(),

View File

@ -9,7 +9,9 @@ class ButtonStateWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final entityModel = EntityModel.of(context); final entityModel = EntityModel.of(context);
return FlatButton( return SizedBox(
height: 34.0,
child: FlatButton(
onPressed: (() { onPressed: (() {
_setNewState(entityModel.entity); _setNewState(entityModel.entity);
}), }),
@ -19,6 +21,7 @@ class ButtonStateWidget extends StatelessWidget {
style: style:
new TextStyle(fontSize: Entity.stateFontSize, color: Colors.blue), new TextStyle(fontSize: Entity.stateFontSize, color: Colors.blue),
), ),
)
); );
} }
} }

View File

@ -4,9 +4,9 @@ class SimpleEntityState extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final entityModel = EntityModel.of(context); final entityModel = EntityModel.of(context);
return Padding( return Expanded(
padding: EdgeInsets.fromLTRB( child: Padding(
0.0, 0.0, Entity.rightWidgetPadding, 0.0), padding: EdgeInsets.fromLTRB(0.0, 0.0, Entity.rightWidgetPadding, 0.0),
child: GestureDetector( child: GestureDetector(
child: Text( child: Text(
"${entityModel.entity.state}${entityModel.entity.unitOfMeasurement}", "${entityModel.entity.state}${entityModel.entity.unitOfMeasurement}",
@ -17,6 +17,8 @@ class SimpleEntityState extends StatelessWidget {
onTap: () => entityModel.handleTap onTap: () => entityModel.handleTap
? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity))
: null, : null,
)); )
),
);
} }
} }

View File

@ -29,15 +29,16 @@ class _SwitchStateWidgetState extends State<SwitchStateWidget> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final entityModel = EntityModel.of(context); final entityModel = EntityModel.of(context);
final entity = entityModel.entity; final entity = entityModel.entity;
Widget result;
if ((entity.attributes["assumed_state"] == null) || (entity.attributes["assumed_state"] == false)) { if ((entity.attributes["assumed_state"] == null) || (entity.attributes["assumed_state"] == false)) {
return Switch( result = Switch(
value: entity.assumedState == 'on', value: entity.assumedState == 'on',
onChanged: ((switchState) { onChanged: ((switchState) {
_setNewState(switchState, entity); _setNewState(switchState, entity);
}), }),
); );
} else { } else {
return Row( result = Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
IconButton( IconButton(
@ -55,6 +56,9 @@ class _SwitchStateWidgetState extends State<SwitchStateWidget> {
], ],
); );
} }
return SizedBox(
height: 32.0,
child: result,
);
} }
} }