TF-3087 [WEB] Apply new design suggestions search for email address in search bar
This commit is contained in:
@@ -1200,65 +1200,10 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget createSuggestionsWidget() {
|
Widget createSuggestionsWidget() {
|
||||||
final listItemSuggestionWidget = _suggestions?.map((T suggestion) {
|
final listItemSuggestionWidget = _buildListViewSuggestionWidget();
|
||||||
if (widget.itemBuilder != null) {
|
final loadingWidget = _buildLoadingBarWidget();
|
||||||
return InkWell(
|
final listAction = _buildListActionWidget();
|
||||||
child: widget.itemBuilder!(context, suggestion),
|
final listItemContactWidget = _buildListViewContactWidget();
|
||||||
onTap: () => widget.onSuggestionSelected?.call(suggestion),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}).toList() ?? [];
|
|
||||||
|
|
||||||
final loadingWidget = widget.loadingBuilder != null
|
|
||||||
? widget.loadingBuilder!(context)
|
|
||||||
: const Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final listAction = Wrap(
|
|
||||||
children: widget.listActionButton!.map((dynamic action) {
|
|
||||||
if (widget.actionButtonBuilder != null) {
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: widget.isDirectionRTL ? 0 : 8,
|
|
||||||
left: widget.isDirectionRTL ? 8 : 0,
|
|
||||||
bottom: kIsWeb ? 8 : 0
|
|
||||||
),
|
|
||||||
child: InkWell(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
||||||
onTap: () {
|
|
||||||
if (widget.buttonActionCallback != null) {
|
|
||||||
widget.buttonActionCallback!(action);
|
|
||||||
invalidateSuggestions();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: widget.actionButtonBuilder!(context, action),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}).toList());
|
|
||||||
|
|
||||||
final listItemContactWidget = _contacts?.map((P contact) {
|
|
||||||
if (widget.contactSuggestionBuilder != null) {
|
|
||||||
return Material(
|
|
||||||
type: MaterialType.transparency,
|
|
||||||
child: InkWell(
|
|
||||||
child: widget.contactSuggestionBuilder!(context, contact),
|
|
||||||
onTap: () => widget.onContactSuggestionSelected?.call(contact),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}).toList() ?? [];
|
|
||||||
|
|
||||||
Widget child = ListView(
|
Widget child = ListView(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@@ -1267,17 +1212,14 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
|
|||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
reverse: widget.suggestionsBox!.direction == AxisDirection.down ? false : true, // reverses the list to start at the bottom
|
reverse: widget.suggestionsBox!.direction == AxisDirection.down ? false : true, // reverses the list to start at the bottom
|
||||||
children: [
|
children: [
|
||||||
if (widget.listActionButton != null && widget.listActionButton?.isNotEmpty == true)
|
if (listAction != null) listAction,
|
||||||
Padding(
|
if (loadingWidget != null) loadingWidget,
|
||||||
padding: widget.listActionPadding ?? EdgeInsets.zero,
|
|
||||||
child: listAction,
|
|
||||||
),
|
|
||||||
if (_isLoading == true && widget.hideOnLoading == false && widget.keepSuggestionsOnLoading == false)
|
|
||||||
loadingWidget,
|
|
||||||
if (listItemContactWidget.isNotEmpty)
|
|
||||||
... listItemContactWidget,
|
|
||||||
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
|
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
|
||||||
widget.buttonShowAllResult!(context, widget.controller?.text),
|
widget.buttonShowAllResult!(context, widget.controller?.text),
|
||||||
|
if (listItemContactWidget.isNotEmpty)
|
||||||
|
... listItemContactWidget,
|
||||||
|
if (listItemContactWidget.isNotEmpty && listItemSuggestionWidget.isNotEmpty)
|
||||||
|
const Divider(),
|
||||||
if (listItemSuggestionWidget.isNotEmpty)
|
if (listItemSuggestionWidget.isNotEmpty)
|
||||||
... [
|
... [
|
||||||
... listItemSuggestionWidget,
|
... listItemSuggestionWidget,
|
||||||
@@ -1297,55 +1239,9 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget createRecentWidget() {
|
Widget createRecentWidget() {
|
||||||
final listItemRecent = _recentItems?.map((R recent) {
|
final listItemRecent = _buildListViewRecentWidget();
|
||||||
if (widget.itemRecentBuilder != null) {
|
final loadingWidget = _buildLoadingBarWidget();
|
||||||
return InkWell(
|
final listAction = _buildListActionWidget();
|
||||||
child: widget.itemRecentBuilder!(context, recent),
|
|
||||||
onTap: () {
|
|
||||||
if (widget.onRecentSelected != null) {
|
|
||||||
widget.onRecentSelected!(recent);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}).toList() ?? [];
|
|
||||||
|
|
||||||
final loadingWidget = widget.loadingBuilder != null
|
|
||||||
? widget.loadingBuilder!(context)
|
|
||||||
: const Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final listAction = Wrap(
|
|
||||||
children: widget.listActionButton!.map((dynamic action) {
|
|
||||||
if (widget.actionButtonBuilder != null) {
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: widget.isDirectionRTL ? 0 : 8,
|
|
||||||
left: widget.isDirectionRTL ? 8 : 0,
|
|
||||||
bottom: kIsWeb ? 8 : 0
|
|
||||||
),
|
|
||||||
child: InkWell(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
||||||
onTap: () {
|
|
||||||
if (widget.buttonActionCallback != null) {
|
|
||||||
widget.buttonActionCallback!(action);
|
|
||||||
invalidateSuggestions();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: widget.actionButtonBuilder!(context, action),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}).toList());
|
|
||||||
|
|
||||||
Widget child = ListView(
|
Widget child = ListView(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@@ -1354,13 +1250,8 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
|
|||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
reverse: widget.suggestionsBox!.direction == AxisDirection.down ? false : true, // reverses the list to start at the bottom
|
reverse: widget.suggestionsBox!.direction == AxisDirection.down ? false : true, // reverses the list to start at the bottom
|
||||||
children: [
|
children: [
|
||||||
if (widget.listActionButton != null && widget.listActionButton?.isNotEmpty == true)
|
if (listAction != null) listAction,
|
||||||
Padding(
|
if (loadingWidget != null) loadingWidget,
|
||||||
padding: widget.listActionPadding ?? EdgeInsets.zero,
|
|
||||||
child: listAction,
|
|
||||||
),
|
|
||||||
if (_isLoading == true && widget.hideOnLoading == false && widget.keepSuggestionsOnLoading == false)
|
|
||||||
loadingWidget,
|
|
||||||
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
|
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
|
||||||
widget.buttonShowAllResult!(context, widget.controller?.text),
|
widget.buttonShowAllResult!(context, widget.controller?.text),
|
||||||
if (_recentItems?.isNotEmpty == true && widget.itemRecentBuilder != null && widget.titleHeaderRecent != null)
|
if (_recentItems?.isNotEmpty == true && widget.itemRecentBuilder != null && widget.titleHeaderRecent != null)
|
||||||
@@ -1382,6 +1273,120 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
|
|||||||
|
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Widget? _buildListActionWidget() {
|
||||||
|
if (widget.listActionButton?.isNotEmpty != true
|
||||||
|
|| widget.actionButtonBuilder == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final listActionWidget = Wrap(children: widget.listActionButton!
|
||||||
|
.map((action) {
|
||||||
|
if (widget.buttonActionCallback != null) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(end: 8, bottom: 8),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
|
onTap: () {
|
||||||
|
widget.buttonActionCallback?.call(action);
|
||||||
|
invalidateSuggestions();
|
||||||
|
},
|
||||||
|
child: widget.actionButtonBuilder!(context, action),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(end: 8, bottom: 8),
|
||||||
|
child: widget.actionButtonBuilder!(context, action)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (widget.listActionPadding != null) {
|
||||||
|
return Padding(padding: widget.listActionPadding!, child: listActionWidget);
|
||||||
|
} else {
|
||||||
|
return listActionWidget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _buildLoadingBarWidget() {
|
||||||
|
if (_isLoading != true
|
||||||
|
|| widget.hideOnLoading != false
|
||||||
|
|| widget.keepSuggestionsOnLoading != false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget.loadingBuilder != null) {
|
||||||
|
return widget.loadingBuilder!(context);
|
||||||
|
} else {
|
||||||
|
return const Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildListViewRecentWidget() {
|
||||||
|
if (_recentItems?.isNotEmpty != true || widget.itemRecentBuilder == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _recentItems!
|
||||||
|
.map((recent) {
|
||||||
|
if (widget.onRecentSelected != null) {
|
||||||
|
return InkWell(
|
||||||
|
child: widget.itemRecentBuilder!(context, recent),
|
||||||
|
onTap: () => widget.onRecentSelected!(recent),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return widget.itemRecentBuilder!(context, recent);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildListViewSuggestionWidget() {
|
||||||
|
if (_suggestions?.isNotEmpty != true || widget.itemBuilder == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _suggestions!
|
||||||
|
.map((suggestion) {
|
||||||
|
if (widget.onSuggestionSelected != null) {
|
||||||
|
return InkWell(
|
||||||
|
child: widget.itemBuilder!(context, suggestion),
|
||||||
|
onTap: () => widget.onSuggestionSelected?.call(suggestion),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return widget.itemBuilder!(context, suggestion);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildListViewContactWidget() {
|
||||||
|
if (_contacts?.isNotEmpty != true || widget.contactSuggestionBuilder == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _contacts!
|
||||||
|
.map((contact) {
|
||||||
|
if (widget.onContactSuggestionSelected != null) {
|
||||||
|
return InkWell(
|
||||||
|
child: widget.contactSuggestionBuilder!(context, contact),
|
||||||
|
onTap: () => widget.onContactSuggestionSelected?.call(contact),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return widget.contactSuggestionBuilder!(context, contact);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supply an instance of this class to the [TypeAhead.suggestionsBoxDecoration]
|
/// Supply an instance of this class to the [TypeAhead.suggestionsBoxDecoration]
|
||||||
|
|||||||
Reference in New Issue
Block a user