buildFloatingSearchBody method

Widget buildFloatingSearchBody(
  1. BuildContext context,
  2. Animation<double> transition
)

Shows when the user taps on the floating search bar.

Implementation

Widget buildFloatingSearchBody(
  BuildContext context,
  Animation<double> transition,
) {
  String query = mediaType.floatingSearchBarController.query.trim();

  if (query.isEmpty) {
    List<String> searchHistory =
        appModel.getSearchHistory(historyKey: mediaSource.uniqueKey);

    if (searchHistory.isEmpty) {
      return buildEnterSearchTermPlaceholderMessage();
    } else {
      return JidoujishoSearchHistory(
        uniqueKey: mediaSource.uniqueKey,
        onSearchTermSelect: (searchTerm) {
          setState(() {
            mediaType.floatingSearchBarController.query = searchTerm;
          });
        },
        onUpdate: () {
          setState(() {});
        },
      );
    }
  }

  if (_isSearching || pagingController == null) {
    return JidoujishoSearchHistory(
      uniqueKey: mediaSource.uniqueKey,
      searchSuggestions: _searchSuggestions,
      onSearchTermSelect: (searchTerm) {
        setState(() {
          mediaType.floatingSearchBarController.query = searchTerm;
        });
      },
      onUpdate: () {
        setState(() {});
      },
    );
  }

  if (pagingController!.itemList != null) {
    return RawScrollbar(
      thickness: 3,
      thumbVisibility: true,
      controller: _scrollController,
      child: buildResultList(),
    );
  }

  return buildNoSearchResultsPlaceholderMessage();
}