Full ui structure refactoring. InheritedWidget as entity model

This commit is contained in:
Yegor Vialov
2018-10-15 00:15:09 +03:00
parent b5f9ecf601
commit ffc053fbe6
17 changed files with 1118 additions and 960 deletions

View File

@ -1,42 +0,0 @@
part of '../main.dart';
class _SelectEntityWidgetState extends _EntityWidgetState {
List<String> _listOptions = [];
@override
void setNewState(newValue) {
eventBus.fire(new ServiceCallEvent(widget.entity.domain, "select_option", widget.entity.entityId,
{"option": "$newValue"}));
}
@override
Widget _buildActionWidget(BuildContext context) {
Widget ctrl;
_listOptions.clear();
if (widget.entity.attributes["options"] != null) {
widget.entity.attributes["options"].forEach((value){
_listOptions.add(value.toString());
});
}
if (_listOptions.isNotEmpty) {
ctrl = DropdownButton<String>(
value: widget.entity.state,
items: this._listOptions.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {
setNewState(_);
},
);
} else {
ctrl = Text('---');
}
return Expanded(
//width: Entity.INPUT_WIDTH,
child: ctrl,
);
}
}