Close entity view after setting input value
This commit is contained in:
		| @@ -72,7 +72,7 @@ class Entity { | |||||||
|     eventBus.fire(new ShowEntityPageEvent(this)); |     eventBus.fire(new ShowEntityPageEvent(this)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Widget buildWidget() { |   Widget buildWidget(BuildContext context) { | ||||||
|     return SizedBox( |     return SizedBox( | ||||||
|       height: Entity.WIDGET_HEIGHT, |       height: Entity.WIDGET_HEIGHT, | ||||||
|       child: Row( |       child: Row( | ||||||
| @@ -87,13 +87,13 @@ class Entity { | |||||||
|               onTap: openEntityPage, |               onTap: openEntityPage, | ||||||
|             ), |             ), | ||||||
|           ), |           ), | ||||||
|           _buildActionWidget() |           _buildActionWidget(context) | ||||||
|         ], |         ], | ||||||
|       ), |       ), | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Widget buildExtendedWidget(String staticState) { |   Widget buildExtendedWidget(BuildContext context, String staticState) { | ||||||
|     return Row( |     return Row( | ||||||
|       children: <Widget>[ |       children: <Widget>[ | ||||||
|         _buildIconWidget(), |         _buildIconWidget(), | ||||||
| @@ -106,7 +106,7 @@ class Entity { | |||||||
|                   Expanded( |                   Expanded( | ||||||
|                     child: _buildNameWidget(), |                     child: _buildNameWidget(), | ||||||
|                   ), |                   ), | ||||||
|                   _buildExtendedActionWidget(staticState) |                   _buildExtendedActionWidget(context, staticState) | ||||||
|                 ], |                 ], | ||||||
|               ), |               ), | ||||||
|               _buildLastUpdatedWidget() |               _buildLastUpdatedWidget() | ||||||
| @@ -149,7 +149,7 @@ class Entity { | |||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Widget _buildActionWidget() { |   Widget _buildActionWidget(BuildContext context) { | ||||||
|     return Padding( |     return Padding( | ||||||
|         padding: EdgeInsets.fromLTRB(0.0, 0.0, Entity.RIGTH_WIDGET_PADDING, 0.0), |         padding: EdgeInsets.fromLTRB(0.0, 0.0, Entity.RIGTH_WIDGET_PADDING, 0.0), | ||||||
|         child: GestureDetector( |         child: GestureDetector( | ||||||
| @@ -166,8 +166,8 @@ class Entity { | |||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Widget _buildExtendedActionWidget(String staticState) { |   Widget _buildExtendedActionWidget(BuildContext context, String staticState) { | ||||||
|     return _buildActionWidget(); |     return _buildActionWidget(context); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -176,7 +176,7 @@ class SwitchEntity extends Entity { | |||||||
|   SwitchEntity(Map rawData) : super(rawData); |   SwitchEntity(Map rawData) : super(rawData); | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget _buildActionWidget() { |   Widget _buildActionWidget(BuildContext context) { | ||||||
|     return Switch( |     return Switch( | ||||||
|       value: this.isOn, |       value: this.isOn, | ||||||
|       onChanged: ((switchState) { |       onChanged: ((switchState) { | ||||||
| @@ -192,7 +192,7 @@ class ButtonEntity extends Entity { | |||||||
|   ButtonEntity(Map rawData) : super(rawData); |   ButtonEntity(Map rawData) : super(rawData); | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget _buildActionWidget() { |   Widget _buildActionWidget(BuildContext context) { | ||||||
|     return FlatButton( |     return FlatButton( | ||||||
|       onPressed: (() { |       onPressed: (() { | ||||||
|         eventBus.fire(new ServiceCallEvent(_domain, "turn_on", _entityId, null)); |         eventBus.fire(new ServiceCallEvent(_domain, "turn_on", _entityId, null)); | ||||||
| @@ -212,7 +212,7 @@ class InputEntity extends Entity { | |||||||
|   InputEntity(Map rawData) : super(rawData); |   InputEntity(Map rawData) : super(rawData); | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget buildExtendedWidget(String staticState) { |   Widget buildExtendedWidget(BuildContext context, String staticState) { | ||||||
|     return Column( |     return Column( | ||||||
|       children: <Widget>[ |       children: <Widget>[ | ||||||
|         SizedBox( |         SizedBox( | ||||||
| @@ -229,14 +229,14 @@ class InputEntity extends Entity { | |||||||
|         ), |         ), | ||||||
|         SizedBox( |         SizedBox( | ||||||
|           height: Entity.EXTENDED_WIDGET_HEIGHT, |           height: Entity.EXTENDED_WIDGET_HEIGHT, | ||||||
|           child: _buildExtendedActionWidget(staticState), |           child: _buildExtendedActionWidget(context, staticState), | ||||||
|         ) |         ) | ||||||
|       ], |       ], | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget _buildActionWidget() { |   Widget _buildActionWidget(BuildContext context) { | ||||||
|     if (this.isSliderField) { |     if (this.isSliderField) { | ||||||
|       return Container( |       return Container( | ||||||
|         width: 200.0, |         width: 200.0, | ||||||
| @@ -270,12 +270,12 @@ class InputEntity extends Entity { | |||||||
|         ), |         ), | ||||||
|       ); |       ); | ||||||
|     } else { |     } else { | ||||||
|       return super._buildActionWidget(); |       return super._buildActionWidget(context); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget _buildExtendedActionWidget(String staticState) { |   Widget _buildExtendedActionWidget(BuildContext context, String staticState) { | ||||||
|     return Padding( |     return Padding( | ||||||
|         padding: EdgeInsets.fromLTRB(Entity.LEFT_WIDGET_PADDING, 0.0, Entity.RIGTH_WIDGET_PADDING, 0.0), |         padding: EdgeInsets.fromLTRB(Entity.LEFT_WIDGET_PADDING, 0.0, Entity.RIGTH_WIDGET_PADDING, 0.0), | ||||||
|         child: Row( |         child: Row( | ||||||
| @@ -297,6 +297,7 @@ class InputEntity extends Entity { | |||||||
|               child: FlatButton( |               child: FlatButton( | ||||||
|                 onPressed: () { |                 onPressed: () { | ||||||
|                   eventBus.fire(new ServiceCallEvent(_domain, "set_value", _entityId,{"value": "$staticState"})); |                   eventBus.fire(new ServiceCallEvent(_domain, "set_value", _entityId,{"value": "$staticState"})); | ||||||
|  |                   Navigator.pop(context); | ||||||
|                 }, |                 }, | ||||||
|                 child: Text( |                 child: Text( | ||||||
|                     "SET", |                     "SET", | ||||||
|   | |||||||
| @@ -50,7 +50,7 @@ class _EntityViewPageState extends State<EntityViewPage> { | |||||||
|           padding: EdgeInsets.all(10.0), |           padding: EdgeInsets.all(10.0), | ||||||
|           child: ListView( |           child: ListView( | ||||||
|             children: <Widget>[ |             children: <Widget>[ | ||||||
|               _entity.buildExtendedWidget(_lastState) |               _entity.buildExtendedWidget(context, _lastState) | ||||||
|             ], |             ], | ||||||
|           ), |           ), | ||||||
|       ), |       ), | ||||||
|   | |||||||
| @@ -409,7 +409,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver { | |||||||
|         entities.add( |         entities.add( | ||||||
|           Padding( |           Padding( | ||||||
|             padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0), |             padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0), | ||||||
|             child: entity.buildWidget(), |             child: entity.buildWidget(context), | ||||||
|           )); |           )); | ||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user