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

Fix geocoding serch due to updated Mapbox library & Adjust colors #235

Merged
merged 3 commits into from
Jul 18, 2024
Merged
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
12 changes: 8 additions & 4 deletions green_walking/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ class GreenWalkingApp extends StatelessWidget {
return MaterialApp(
onGenerateTitle: (BuildContext context) => AppLocalizations.of(context)!.appTitle,
theme: ThemeData(
brightness: Brightness.light,
primaryColor: Colors.blue,
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.light,
seedColor: Colors.blue,
),
),
darkTheme: ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.blue,
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: Colors.blue,
),
),
themeMode: prefsProvider.themeMode,
initialRoute: Routes.map,
Expand Down
2 changes: 1 addition & 1 deletion green_walking/lib/pages/feedback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FeedbackPage extends StatelessWidget {
children: <Widget>[
RichText(
text: TextSpan(
style: TextStyle(color: theme.unselectedWidgetColor),
style: TextStyle(color: theme.colorScheme.secondary),
children: <InlineSpan>[
TextSpan(
text: '${locale.feedbackPageText}\n',
Expand Down
4 changes: 2 additions & 2 deletions green_walking/lib/pages/legal_notice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LegalNoticePage extends StatelessWidget {
children: <Widget>[
RichText(
text: TextSpan(
style: TextStyle(color: theme.unselectedWidgetColor),
style: TextStyle(color: theme.colorScheme.secondary),
children: <InlineSpan>[
TextSpan(
text: '${locale.imprintTmgText('5')}:\n\n',
Expand All @@ -41,7 +41,7 @@ class LegalNoticePage extends StatelessWidget {
TextSpan(text: '${locale.imprintGdprApplyText} '),
TextSpan(
text: locale.gdprPrivacyPolicy,
style: TextStyle(color: theme.primaryColor),
style: TextStyle(color: theme.colorScheme.primary, fontWeight: FontWeight.bold),
recognizer: TapGestureRecognizer()..onTap = () => launchUrl(privacyPolicyUrl),
),
const TextSpan(text: '.')
Expand Down
6 changes: 2 additions & 4 deletions green_walking/lib/pages/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class _SearchPageState extends State<SearchPage> {
@override
Widget build(BuildContext context) {
final AppLocalizations locale = AppLocalizations.of(context)!;
final ThemeData theme = Theme.of(context);

return Scaffold(
// If the search in the search bar is clicked the keyboard appears. The keyboard
Expand All @@ -59,7 +58,6 @@ class _SearchPageState extends State<SearchPage> {
title: TextField(
controller: _queryFieldController,
autofocus: true,
cursorColor: theme.hintColor,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.go,
decoration: InputDecoration(
Expand All @@ -69,7 +67,7 @@ class _SearchPageState extends State<SearchPage> {
onSubmitted: _onSearchSubmitted,
),
),
Padding(padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), child: _resultList(context)),
Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child: _resultList(context)),
],
),
));
Expand Down Expand Up @@ -131,7 +129,7 @@ class _SearchPageState extends State<SearchPage> {
children: [
Flexible(
child: Text(locale.geocodingResultLegalNotice(data.attribution),
style: TextStyle(color: theme.hintColor, fontSize: 12.0)))
style: TextStyle(color: theme.colorScheme.secondary, fontSize: 12.0)))
],
),
],
Expand Down
4 changes: 2 additions & 2 deletions green_walking/lib/widgets/location_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class _LocationButtonState extends State<LocationButton> {
child: Padding(
padding: const EdgeInsets.only(bottom: 18.0, right: 18.0),
child: FloatingActionButton(
backgroundColor: theme.primaryColor,
backgroundColor: theme.colorScheme.primary,
onPressed: _onPressed,
child: ValueListenableBuilder<UserLocationTracking>(
valueListenable: widget.trackUserLocation,
Expand All @@ -63,7 +63,7 @@ class _LocationButtonState extends State<LocationButton> {
return Icon(
icon,
size: 27,
color: Colors.white,
color: theme.colorScheme.onPrimary,
);
})),
),
Expand Down
9 changes: 3 additions & 6 deletions green_walking/lib/widgets/map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class _MapViewState extends State<MapView> {
widget.lastCameraOption ?? CameraOptions(center: Point(coordinates: Position(9.8682, 53.5519)), zoom: 11.0),
styleUri: CustomMapboxStyles.outdoor,
onMapIdleListener: _onCameraIdle,
onLongTapListener: (MapContentGestureContext context) =>
_onLongTapListener(widget.accessToken, context.touchPosition),
onLongTapListener: _onLongTapListener,
onCameraChangeListener: (CameraChangedEventData cameraChangedEventData) {
_mapboxMap.scaleBar.updateSettings(ScaleBarSettings(enabled: true));
},
Expand All @@ -119,11 +118,9 @@ class _MapViewState extends State<MapView> {
);
}

Future<void> _onLongTapListener(String accesstoken, ScreenCoordinate coordinate) async {
Future<void> _onLongTapListener(MapContentGestureContext context) async {
try {
// https://github.com/mapbox/mapbox-maps-flutter/issues/81 It actual returns the position
// and not the coordinates.
final Position tapPosition = Position(coordinate.y, coordinate.x);
final Position tapPosition = context.point.coordinates;
final Position? userPosition = (await _mapboxMap.getPuckLocation())?.position;

return _displaySearchResult(await widget.onSearchPage(userPosition: userPosition, reversePosition: tapPosition));
Expand Down
10 changes: 5 additions & 5 deletions green_walking/lib/widgets/navigation_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ class AppNavigationDrawer extends StatelessWidget {
children: <Widget>[
DrawerHeader(
decoration: BoxDecoration(
color: theme.primaryColor,
color: theme.colorScheme.primary,
),
child: Column(children: <Widget>[
Row(children: <Widget>[
Text(
locale.appTitle,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: theme.colorScheme.onPrimary,
fontSize: 22,
),
),
]),
Row(
children: <Widget>[
Text(locale.appSlogan,
style: const TextStyle(
color: Colors.white70,
style: TextStyle(
color: theme.colorScheme.onPrimary,
)),
],
)
Expand Down
9 changes: 6 additions & 3 deletions green_walking/lib/widgets/search_result_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SearchResultCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final String subtitle = truncateString(place.placeName?.replaceFirst('${place.text ?? ''}, ', ''), 65) ?? '';
final String subtitle = truncateString(place.placeName?.replaceFirst('${place.text ?? ''}, ', ''), 70) ?? '';

return Card(
child: ListTile(
Expand Down Expand Up @@ -49,7 +49,7 @@ class _TrailingWidget extends StatelessWidget {

final List<Widget> children = [
IconButton(
color: theme.primaryColor,
color: theme.colorScheme.primary,
tooltip: locale.openLocationInDefaultAppSemanticLabel,
icon: Icon(Icons.open_in_new, semanticLabel: locale.openLocationInDefaultAppSemanticLabel),
onPressed: () => launchUrlString(
Expand Down Expand Up @@ -94,7 +94,10 @@ class _FooterRow extends StatelessWidget {
return Row(
children: [
const Icon(Icons.directions_run, size: 11.0),
Text(distanceString, style: const TextStyle(fontSize: 11.0)),
Padding(
padding: const EdgeInsets.only(left: 1.0),
child: Text(distanceString, style: const TextStyle(fontSize: 11.0)),
)
],
);
}
Expand Down
6 changes: 3 additions & 3 deletions green_walking/lib/widgets/user_consent_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ class UserConsentDialog extends StatelessWidget {
child: ListBody(
children: <Widget>[
RichText(
text: TextSpan(style: TextStyle(color: theme.hintColor), children: <InlineSpan>[
text: TextSpan(style: TextStyle(color: theme.colorScheme.secondary), children: <InlineSpan>[
TextSpan(
text: '${locale.gdprDialogText} ',
),
TextSpan(
text: locale.gdprPrivacyPolicy,
style: TextStyle(color: theme.primaryColor),
style: TextStyle(color: theme.colorScheme.primary, fontWeight: FontWeight.bold),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrl(privacyPolicyUrl);
},
),
TextSpan(
text: '.',
style: TextStyle(color: theme.hintColor),
style: TextStyle(color: theme.colorScheme.secondary),
),
]),
),
Expand Down