Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customization tools #97

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\My Program Files\flutter"
export "FLUTTER_APPLICATION_PATH=D:\Work\flutter\google_map_location_picker\example"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\My Program Files\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1.0.0"
1 change: 1 addition & 0 deletions example/lib/keys.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const String apiKey = 'apikey';
90 changes: 79 additions & 11 deletions lib/src/google_map_location_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ class LocationPicker extends StatefulWidget {
this.hintText,
this.resultCardConfirmIcon,
this.resultCardAlignment,
this.resultCardDecoration,
this.resultCardPadding,

this.locationPinIcon,
this.searchOverlayDecoration,
this.searchOverlayTextStyle,
this.appBarIconTheme,
this.resultCardColor,
this.fabsColor,
this.resultCardShape,
this.resultCardTextStyle,
this.searchOverLaybackgroundColor,
this.fabsIconsColor,

this.countries,
this.language = 'en',
});
Expand All @@ -57,9 +68,20 @@ class LocationPicker extends StatefulWidget {
final String hintText;
final Widget resultCardConfirmIcon;
final Alignment resultCardAlignment;
final Decoration resultCardDecoration;
final EdgeInsets resultCardPadding;


final Widget locationPinIcon;
final TextStyle searchOverlayTextStyle;
final Decoration searchOverlayDecoration;
final IconThemeData appBarIconTheme;
final TextStyle resultCardTextStyle;
final Color resultCardColor;
final ShapeBorder resultCardShape;
final Color fabsColor;
final Color searchOverLaybackgroundColor;
final Color fabsIconsColor;

final String language;

@override
Expand Down Expand Up @@ -117,8 +139,10 @@ class LocationPickerState extends State<LocationPicker> {
top: appBarBox.size.height,
width: size.width,
child: Material(
color: widget.searchOverLaybackgroundColor,
elevation: 1,
child: Container(
decoration: widget.searchOverlayDecoration,
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 24),
child: Row(
children: <Widget>[
Expand All @@ -131,7 +155,8 @@ class LocationPickerState extends State<LocationPicker> {
Expanded(
child: Text(
S.of(context)?.finding_place ?? 'Finding place...',
style: TextStyle(fontSize: 16),
style: widget.searchOverlayTextStyle ??
TextStyle(fontSize: 16),
),
)
],
Expand Down Expand Up @@ -183,7 +208,13 @@ class LocationPickerState extends State<LocationPicker> {
aci.offset = 0;
aci.length = 0;

suggestions.add(RichSuggestion(aci, () {}));
suggestions.add(RichSuggestion(
aci,
() {},
decoration: widget.searchOverlayDecoration,
textStyle: widget.searchOverlayTextStyle,
backgroundColor: widget.searchOverLaybackgroundColor,
));
} else {
for (dynamic t in predictions) {
AutoCompleteItem aci = AutoCompleteItem();
Expand All @@ -193,9 +224,15 @@ class LocationPickerState extends State<LocationPicker> {
aci.offset = t['matched_substrings'][0]['offset'];
aci.length = t['matched_substrings'][0]['length'];

suggestions.add(RichSuggestion(aci, () {
decodeAndSelectPlace(aci.id);
}));
suggestions.add(RichSuggestion(
aci,
() {
decodeAndSelectPlace(aci.id);
},
decoration: widget.searchOverlayDecoration,
textStyle: widget.searchOverlayTextStyle,
backgroundColor: widget.searchOverLaybackgroundColor,
));
}
}

Expand Down Expand Up @@ -247,6 +284,7 @@ class LocationPickerState extends State<LocationPicker> {
width: size.width,
top: appBarBox.size.height,
child: Material(
color: widget.searchOverLaybackgroundColor,
elevation: 1,
child: Column(
children: suggestions,
Expand Down Expand Up @@ -383,7 +421,7 @@ class LocationPickerState extends State<LocationPicker> {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
iconTheme: Theme.of(context).iconTheme,
iconTheme: widget.appBarIconTheme ?? Theme.of(context).iconTheme,
elevation: 0,
backgroundColor: widget.appBarColor,
key: appBarKey,
Expand All @@ -409,8 +447,13 @@ class LocationPickerState extends State<LocationPicker> {
hintText: widget.hintText,
resultCardConfirmIcon: widget.resultCardConfirmIcon,
resultCardAlignment: widget.resultCardAlignment,
resultCardDecoration: widget.resultCardDecoration,
resultCardPadding: widget.resultCardPadding,
locationPinIcon: widget.locationPinIcon,
resultCardColor: widget.resultCardColor,
fabsColor: widget.fabsColor,
resultCardShape: widget.resultCardShape,
resultCardTextStyle: widget.resultCardTextStyle,
fabsIconsColor: widget.fabsIconsColor,
key: mapKey,
language: widget.language,
),
Expand Down Expand Up @@ -447,8 +490,20 @@ Future<LocationResult> showLocationPicker(
Widget resultCardConfirmIcon,
AlignmentGeometry resultCardAlignment,
EdgeInsetsGeometry resultCardPadding,
Decoration resultCardDecoration,

Widget locationPinIcon,
Decoration searchOverlayDecoration,
TextStyle searchOverlayTextStyle,
IconThemeData appBarIconTheme,
TextStyle resultCardTextStyle,
Color resultCardColor,
ShapeBorder resultCardShape,
Color fabsColor,
Color searchOverLaybackgroundColor,
Color fabsIconsColor,

String language,

}) async {
final results = await Navigator.of(context).push(
MaterialPageRoute<dynamic>(
Expand All @@ -470,9 +525,22 @@ Future<LocationResult> showLocationPicker(
resultCardConfirmIcon: resultCardConfirmIcon,
resultCardAlignment: resultCardAlignment,
resultCardPadding: resultCardPadding,
resultCardDecoration: resultCardDecoration,

locationPinIcon: locationPinIcon,
searchOverlayDecoration: searchOverlayDecoration,
searchOverlayTextStyle: searchOverlayTextStyle,
appBarIconTheme: appBarIconTheme,
resultCardColor: resultCardColor,
fabsColor: fabsColor,
resultCardShape: resultCardShape,
resultCardTextStyle: resultCardTextStyle,
searchOverLaybackgroundColor: searchOverLaybackgroundColor,
fabsIconsColor: fabsIconsColor,


countries: countries,
language: language,

);
},
),
Expand Down
46 changes: 39 additions & 7 deletions lib/src/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ class MapPicker extends StatefulWidget {
this.hintText,
this.resultCardConfirmIcon,
this.resultCardAlignment,
this.resultCardDecoration,
this.resultCardPadding,

this.locationPinIcon,
this.resultCardColor,
this.resultCardShape,
this.resultCardTextStyle,
this.fabsColor,
this.fabsIconsColor,

this.language,
}) : super(key: key);

Expand All @@ -56,9 +63,15 @@ class MapPicker extends StatefulWidget {
final String hintText;
final Widget resultCardConfirmIcon;
final Alignment resultCardAlignment;
final Decoration resultCardDecoration;
final EdgeInsets resultCardPadding;

final TextStyle resultCardTextStyle;
final Widget locationPinIcon;
final Color resultCardColor;
final ShapeBorder resultCardShape;
final Color fabsColor;
final Color fabsIconsColor;

final String language;

@override
Expand Down Expand Up @@ -190,6 +203,8 @@ class MapPickerState extends State<MapPicker> {
layersButtonEnabled: widget.layersButtonEnabled,
onToggleMapTypePressed: _onToggleMapTypePressed,
onMyLocationPressed: _initCurrentLocation,
fabsBackgroundColor: widget.fabsColor,
fabsIconsColor: widget.fabsIconsColor,
),
pin(),
locationCard(),
Expand All @@ -204,7 +219,9 @@ class MapPickerState extends State<MapPicker> {
child: Padding(
padding: widget.resultCardPadding ?? EdgeInsets.all(16.0),
child: Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
color: widget.resultCardColor,
shape: widget.resultCardShape ??
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
child: Consumer<LocationProvider>(
builder: (context, locationProvider, _) {
return Padding(
Expand All @@ -227,12 +244,14 @@ class MapPickerState extends State<MapPicker> {
_address = address;
return Text(
address ?? 'Unnamed place',
style: TextStyle(fontSize: 18),
style: widget.resultCardTextStyle ??
TextStyle(fontSize: 18),
);
}),
),
Spacer(),
FloatingActionButton(
backgroundColor: widget.fabsColor,
onPressed: () {
Navigator.of(context).pop({
'location': LocationResult(
Expand Down Expand Up @@ -275,7 +294,7 @@ class MapPickerState extends State<MapPicker> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.place, size: 56),
widget.locationPinIcon ?? Icon(Icons.place, size: 56),
Container(
decoration: ShapeDecoration(
shadows: [
Expand Down Expand Up @@ -382,6 +401,8 @@ class _MapFabs extends StatelessWidget {
@required this.layersButtonEnabled,
@required this.onToggleMapTypePressed,
@required this.onMyLocationPressed,
this.fabsBackgroundColor,
this.fabsIconsColor,
}) : assert(onToggleMapTypePressed != null),
super(key: key);

Expand All @@ -391,6 +412,9 @@ class _MapFabs extends StatelessWidget {
final VoidCallback onToggleMapTypePressed;
final VoidCallback onMyLocationPressed;

final Color fabsIconsColor;
final Color fabsBackgroundColor;

@override
Widget build(BuildContext context) {
return Container(
Expand All @@ -400,18 +424,26 @@ class _MapFabs extends StatelessWidget {
children: <Widget>[
if (layersButtonEnabled)
FloatingActionButton(
backgroundColor: fabsBackgroundColor,
onPressed: onToggleMapTypePressed,
materialTapTargetSize: MaterialTapTargetSize.padded,
mini: true,
child: const Icon(Icons.layers),
child: Icon(
Icons.layers,
color: fabsIconsColor,
),
heroTag: "layers",
),
if (myLocationButtonEnabled)
FloatingActionButton(
backgroundColor: fabsBackgroundColor,
onPressed: onMyLocationPressed,
materialTapTargetSize: MaterialTapTargetSize.padded,
mini: true,
child: const Icon(Icons.my_location),
child: Icon(
Icons.my_location,
color: fabsIconsColor,
),
heroTag: "myLocation",
),
],
Expand Down
Loading