Skip to content

Commit

Permalink
docs : change example of search
Browse files Browse the repository at this point in the history
  • Loading branch information
liodali committed Mar 17, 2022
1 parent d460fa4 commit 6978167
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 62 deletions.
116 changes: 69 additions & 47 deletions example/lib/src/search_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class _LocationAppExampleState extends State<LocationAppExample> {
textConfirmPicker: "pick",
initCurrentUserPosition: false,
initZoom: 8,
initPosition:
GeoPoint(latitude: 47.4358055, longitude: 8.4737324),
initPosition: GeoPoint(latitude: 47.4358055, longitude: 8.4737324),
radius: 8.0,
);
if (p != null) {
Expand Down Expand Up @@ -104,52 +103,77 @@ class _SearchPageState extends State<SearchPage> {
Widget build(BuildContext context) {
return CustomPickerLocation(
controller: controller,
appBarPicker: AppBar(
title: TextField(
controller: textEditingController,
onEditingComplete: () async {
FocusScope.of(context).requestFocus(new FocusNode());
},
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search,
color: Colors.black,
),
suffix: ValueListenableBuilder<TextEditingValue>(
valueListenable: textEditingController,
builder: (ctx, text, child) {
if (text.text.isNotEmpty) {
return child!;
}
return SizedBox.shrink();
},
child: InkWell(
focusNode: FocusNode(),
onTap: () {
textEditingController.clear();
controller.setSearchableText("");
FocusScope.of(context).requestFocus(new FocusNode());
},
child: Icon(
Icons.close,
size: 16,
color: Colors.black,
topWidgetPicker: Padding(
padding: const EdgeInsets.only(
top: 56,
left: 8,
right: 8,
),
child: Column(
children: [
Row(
children: [
TextButton(
style: TextButton.styleFrom(),
onPressed: () => Navigator.of(context).pop(),
child: Icon(
Icons.arrow_back_ios,
),
),
),
Expanded(
child: TextField(
controller: textEditingController,
onEditingComplete: () async {
FocusScope.of(context).requestFocus(new FocusNode());
},
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search,
color: Colors.black,
),
suffix: ValueListenableBuilder<TextEditingValue>(
valueListenable: textEditingController,
builder: (ctx, text, child) {
if (text.text.isNotEmpty) {
return child!;
}
return SizedBox.shrink();
},
child: InkWell(
focusNode: FocusNode(),
onTap: () {
textEditingController.clear();
controller.setSearchableText("");
FocusScope.of(context).requestFocus(new FocusNode());
},
child: Icon(
Icons.close,
size: 16,
color: Colors.black,
),
),
),
focusColor: Colors.black,
filled: true,
hintText: "search",
border: InputBorder.none,
enabledBorder: InputBorder.none,
fillColor: Colors.grey[300],
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
),
),
),
],
),
focusColor: Colors.black,
filled: true,
hintText: "search",
border: InputBorder.none,
enabledBorder: InputBorder.none,
fillColor: Colors.grey[300],
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
SizedBox(
height: 8,
),
),
TopSearchWidget()
],
),
),
topWidgetPicker: TopSearchWidget(),
bottomWidgetPicker: Positioned(
bottom: 12,
right: 8,
Expand Down Expand Up @@ -195,12 +219,10 @@ class _TopSearchWidgetState extends State<TopSearchWidget> {
final v = controller.searchableText.value;
if (v.length > 3 && oldText != v) {
oldText = v;
if (_timerToStartSuggestionReq != null &&
_timerToStartSuggestionReq!.isActive) {
if (_timerToStartSuggestionReq != null && _timerToStartSuggestionReq!.isActive) {
_timerToStartSuggestionReq!.cancel();
}
_timerToStartSuggestionReq =
Timer.periodic(Duration(seconds: 3), (timer) async {
_timerToStartSuggestionReq = Timer.periodic(Duration(seconds: 3), (timer) async {
await suggestionProcessing(v);
timer.cancel();
});
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.32.0"
version: "0.32.1"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand Down
29 changes: 15 additions & 14 deletions lib/src/widgets/custom_picker_location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CustomPickerLocation extends StatefulWidget {
this.pickerConfig = const CustomPickerLocationConfig(),
this.onMapReady,
Key? key,
}) : super(key: key);
}) : super(key: key);

static PickerMapController of<T>(
BuildContext context, {
Expand Down Expand Up @@ -98,19 +98,20 @@ class _CustomPickerLocationState extends State<CustomPickerLocation> {
children: [
Positioned.fill(
child: OSMFlutter(
controller: widget.controller,
markerOption: widget.pickerConfig.advancedMarkerPicker != null
? MarkerOption(
advancedPickerMarker: widget.pickerConfig.advancedMarkerPicker,
)
: null,
isPicker: true,
mapIsLoading: widget.pickerConfig.loadingWidget,
stepZoom: widget.pickerConfig.stepZoom,
initZoom: widget.pickerConfig.initZoom,
minZoomLevel: widget.pickerConfig.minZoomLevel,
maxZoomLevel: widget.pickerConfig.maxZoomLevel,
onMapIsReady: widget.onMapReady),
controller: widget.controller,
markerOption: widget.pickerConfig.advancedMarkerPicker != null
? MarkerOption(
advancedPickerMarker: widget.pickerConfig.advancedMarkerPicker,
)
: null,
isPicker: true,
mapIsLoading: widget.pickerConfig.loadingWidget,
stepZoom: widget.pickerConfig.stepZoom,
initZoom: widget.pickerConfig.initZoom,
minZoomLevel: widget.pickerConfig.minZoomLevel,
maxZoomLevel: widget.pickerConfig.maxZoomLevel,
onMapIsReady: widget.onMapReady,
),
),
if (widget.topWidgetPicker != null) ...[
Positioned(
Expand Down

0 comments on commit 6978167

Please sign in to comment.