This commit is contained in:
Hillel Coren 2019-12-04 12:53:40 +02:00
parent 79609a397f
commit 7bca0560e0
3 changed files with 21 additions and 15 deletions

View File

@ -111,30 +111,35 @@ class _EntityDropdownState extends State<EntityDropdown> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (kIsWeb && isNotMobile(context)) { if (true || kIsWeb && isNotMobile(context)) {
return TypeAheadFormField<String>( return TypeAheadFormField<String>(
initialValue: _entityMap[widget.entityId]?.listDisplayName ?? '',
noItemsFoundBuilder: (context) => SizedBox(), noItemsFoundBuilder: (context) => SizedBox(),
suggestionsCallback: (filter) { suggestionsCallback: (filter) {
return widget.entityList return widget.entityList
.where((entityId) => .where((entityId) =>
widget.entityMap[entityId].matchesFilter(filter)) _entityMap[entityId]?.matchesFilter(filter) ?? false)
.toList(); .toList();
}, },
itemBuilder: (context, entityId) { itemBuilder: (context, entityId) {
return _EntityListTile( return _EntityListTile(
entity: widget.entityMap[entityId], entity: _entityMap[entityId],
filter: _textController.text, filter: _textController.text,
); );
}, },
onSuggestionSelected: (entityId) { onSuggestionSelected: (entityId) {
widget.onSelected(widget.entityMap[entityId]); final entity = _entityMap[entityId];
widget.onSelected(entity);
}, },
textFieldConfiguration: textFieldConfiguration: TextFieldConfiguration<String>(
TextFieldConfiguration<String>(onChanged: (value) { decoration: InputDecoration(
_textController.text = value; labelText: widget.labelText,
}), ),
onChanged: (value) {
_textController.text = value;
}),
autoFlipDirection: true, autoFlipDirection: true,
direction: AxisDirection.up, //direction: AxisDirection.up,
animationStart: 1, animationStart: 1,
debounceDuration: Duration(seconds: 0), debounceDuration: Duration(seconds: 0),
); );
@ -144,7 +149,7 @@ class _EntityDropdownState extends State<EntityDropdown> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
children: <Widget>[ children: <Widget>[
InkWell( InkWell(
key: ValueKey(widget.labelText), //key: ValueKey('__stack_${widget.labelText}__'),
onTap: () => _showOptions(), onTap: () => _showOptions(),
child: IgnorePointer( child: IgnorePointer(
child: TextFormField( child: TextFormField(
@ -217,8 +222,8 @@ class _EntityDropdownDialogState extends State<EntityDropdownDialog> {
/* /*
onSubmitted: (value) { onSubmitted: (value) {
final entityId = widget.entityList.firstWhere((entityId) => final entityId = widget.entityList.firstWhere((entityId) =>
widget.entityMap[entityId].matchesFilter(_filter)); _entityMap[entityId].matchesFilter(_filter));
final entity = widget.entityMap[entityId]; final entity = _entityMap[entityId];
_selectEntity(entity); _selectEntity(entity);
}, },
*/ */
@ -259,8 +264,8 @@ class _EntityDropdownDialogState extends State<EntityDropdownDialog> {
Widget _createList() { Widget _createList() {
final matches = widget.entityList final matches = widget.entityList
.where( .where((entityId) =>
(entityId) => widget.entityMap[entityId].matchesFilter(_filter)) widget.entityMap[entityId]?.matchesFilter(_filter) ?? false)
.toList(); .toList();
return ListView.builder( return ListView.builder(

View File

@ -30,6 +30,7 @@ class ClientPicker extends StatelessWidget {
labelText: localization.client, labelText: localization.client,
entityId: clientId, entityId: clientId,
entityList: memoizedDropdownClientList(clientState.map, clientState.list), entityList: memoizedDropdownClientList(clientState.map, clientState.list),
entityMap: clientState.map,
validator: (String val) => val.trim().isEmpty validator: (String val) => val.trim().isEmpty
? AppLocalization.of(context).pleaseSelectAClient ? AppLocalization.of(context).pleaseSelectAClient
: null, : null,

View File

@ -140,7 +140,7 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
_addBlankRow(); _addBlankRow();
}), }),
autoFlipDirection: true, autoFlipDirection: true,
direction: AxisDirection.up, //direction: AxisDirection.up,
animationStart: 1, animationStart: 1,
debounceDuration: Duration(seconds: 0), debounceDuration: Duration(seconds: 0),
), ),