-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19e341d
commit 663110e
Showing
5 changed files
with
230 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_app/pages/map/map_bloc.dart'; | ||
import 'package:flutter_app/pages/map/place_widget.dart'; | ||
import 'package:flutter_app/pages/places/places_models.dart'; | ||
|
||
class SearchPlaces extends SearchDelegate<Candidate> { | ||
|
||
|
||
SearchPlaces(this._mapBloc); | ||
|
||
final MapBloc _mapBloc; | ||
|
||
@override | ||
List<Widget> buildActions(BuildContext context) { | ||
return [ | ||
IconButton( | ||
icon: Icon(Icons.close), | ||
onPressed: () { | ||
close(context, null); | ||
}, | ||
) | ||
]; | ||
} | ||
|
||
@override | ||
Widget buildLeading(BuildContext context) { | ||
return IconButton( | ||
icon: Icon(Icons.arrow_back), | ||
onPressed: () { | ||
close(context, null); | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Widget buildResults(BuildContext context) { | ||
return _buildPlaceStream(); | ||
} | ||
|
||
@override | ||
Widget buildSuggestions(BuildContext context) { | ||
_mapBloc.fetchLocations(query); | ||
return _buildPlaceStream(); | ||
} | ||
|
||
StreamBuilder _buildPlaceStream() { | ||
return StreamBuilder<List<Candidate>>( | ||
stream: _mapBloc.offices, | ||
builder: (context, snapshot) { | ||
if (snapshot.hasData) { | ||
return PlaceWidget(snapshot.data); | ||
} | ||
return CircularProgressIndicator(); | ||
}, | ||
); | ||
} | ||
} |