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
Widget build(BuildContext context) {
return SizedBox(
height: height,
//height: height,
child: Row(
children: <Widget>[
EntityIcon(),

View File

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

View File

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

View File

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