|
|
|
|
|
|
|
|
|
|
namespace Unity.UIWidgets.material { |
|
|
|
public class SearchUtils { |
|
|
|
public static Future<object> showSearch( |
|
|
|
public static Future<T> showSearch<T>( |
|
|
|
SearchDelegate del, |
|
|
|
SearchDelegate<T> del, |
|
|
|
string query = "" |
|
|
|
) { |
|
|
|
D.assert(del != null); |
|
|
|
|
|
|
del._currentBody = _SearchBody.suggestions; |
|
|
|
return Navigator.of(context).push(new _SearchPageRoute( |
|
|
|
return Navigator.of(context).push<T>(new _SearchPageRoute<T>( |
|
|
|
public abstract class SearchDelegate { |
|
|
|
public abstract class SearchDelegate<T> { |
|
|
|
public abstract Widget buildSuggestions(BuildContext context); |
|
|
|
public abstract Widget buildResults(BuildContext context); |
|
|
|
public abstract Widget buildLeading(BuildContext context); |
|
|
|
|
|
|
set { _currentBodyNotifier.value = value; } |
|
|
|
} |
|
|
|
|
|
|
|
internal _SearchPageRoute _route; |
|
|
|
internal _SearchPageRoute<T> _route; |
|
|
|
} |
|
|
|
|
|
|
|
enum _SearchBody { |
|
|
|
|
|
|
|
|
|
|
class _SearchPageRoute : PageRoute { |
|
|
|
public _SearchPageRoute(SearchDelegate del) { |
|
|
|
class _SearchPageRoute<T> : PageRoute { |
|
|
|
public _SearchPageRoute(SearchDelegate<T> del) { |
|
|
|
D.assert(del != null); |
|
|
|
D.assert(del._route == null, |
|
|
|
() => $"The {this.del.GetType()} instance is currently used by another active " + |
|
|
|
|
|
|
this.del._route = this; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly SearchDelegate del; |
|
|
|
public readonly SearchDelegate<T> del; |
|
|
|
|
|
|
|
public override Color barrierColor { |
|
|
|
get { return null; } |
|
|
|
|
|
|
Animation<float> animation, |
|
|
|
Animation<float> secondaryAnimation |
|
|
|
) { |
|
|
|
return new _SearchPage( |
|
|
|
return new _SearchPage<T>( |
|
|
|
del: del, |
|
|
|
animation: animation |
|
|
|
); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _SearchPage : StatefulWidget { |
|
|
|
class _SearchPage<T> : StatefulWidget { |
|
|
|
SearchDelegate del, |
|
|
|
SearchDelegate<T> del, |
|
|
|
Animation<float> animation |
|
|
|
) { |
|
|
|
this.del = del; |
|
|
|
|
|
|
public readonly SearchDelegate del; |
|
|
|
public readonly SearchDelegate<T> del; |
|
|
|
return new _SearchPageState(); |
|
|
|
return new _SearchPageState<T>(); |
|
|
|
class _SearchPageState : State<_SearchPage> { |
|
|
|
class _SearchPageState<T> : State<_SearchPage<T>> { |
|
|
|
public override void initState() { |
|
|
|
base.initState(); |
|
|
|
queryTextController.addListener(_onQueryChanged); |
|
|
|