From 554971a3085d7a1d5ca4228f81fdd8ede086bdb9 Mon Sep 17 00:00:00 2001 From: Xennis Date: Thu, 18 Jul 2024 19:40:09 +0200 Subject: [PATCH 1/3] Fix geocoding serch due to updated Mapbox library --- green_walking/lib/widgets/map_view.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/green_walking/lib/widgets/map_view.dart b/green_walking/lib/widgets/map_view.dart index a111a82..2c0f683 100644 --- a/green_walking/lib/widgets/map_view.dart +++ b/green_walking/lib/widgets/map_view.dart @@ -104,8 +104,7 @@ class _MapViewState extends State { 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)); }, @@ -119,11 +118,9 @@ class _MapViewState extends State { ); } - Future _onLongTapListener(String accesstoken, ScreenCoordinate coordinate) async { + Future _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)); From ddb51578f3bad00caf1f6777132ad3b7f05f1d8a Mon Sep 17 00:00:00 2001 From: Xennis Date: Thu, 18 Jul 2024 20:41:22 +0200 Subject: [PATCH 2/3] Adjust colors due to Flutter/Material update --- green_walking/lib/main.dart | 12 ++++++++---- green_walking/lib/pages/feedback.dart | 2 +- green_walking/lib/pages/legal_notice.dart | 4 ++-- green_walking/lib/pages/search.dart | 4 +--- green_walking/lib/widgets/location_button.dart | 4 ++-- green_walking/lib/widgets/navigation_drawer.dart | 10 +++++----- green_walking/lib/widgets/search_result_card.dart | 2 +- green_walking/lib/widgets/user_consent_dialog.dart | 6 +++--- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/green_walking/lib/main.dart b/green_walking/lib/main.dart index 7d3794e..6cd4218 100644 --- a/green_walking/lib/main.dart +++ b/green_walking/lib/main.dart @@ -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, diff --git a/green_walking/lib/pages/feedback.dart b/green_walking/lib/pages/feedback.dart index b4467e5..aebed60 100644 --- a/green_walking/lib/pages/feedback.dart +++ b/green_walking/lib/pages/feedback.dart @@ -23,7 +23,7 @@ class FeedbackPage extends StatelessWidget { children: [ RichText( text: TextSpan( - style: TextStyle(color: theme.unselectedWidgetColor), + style: TextStyle(color: theme.colorScheme.secondary), children: [ TextSpan( text: '${locale.feedbackPageText}\n', diff --git a/green_walking/lib/pages/legal_notice.dart b/green_walking/lib/pages/legal_notice.dart index d160224..5d3bce9 100644 --- a/green_walking/lib/pages/legal_notice.dart +++ b/green_walking/lib/pages/legal_notice.dart @@ -24,7 +24,7 @@ class LegalNoticePage extends StatelessWidget { children: [ RichText( text: TextSpan( - style: TextStyle(color: theme.unselectedWidgetColor), + style: TextStyle(color: theme.colorScheme.secondary), children: [ TextSpan( text: '${locale.imprintTmgText('5')}:\n\n', @@ -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: '.') diff --git a/green_walking/lib/pages/search.dart b/green_walking/lib/pages/search.dart index af13375..0b682a3 100644 --- a/green_walking/lib/pages/search.dart +++ b/green_walking/lib/pages/search.dart @@ -42,7 +42,6 @@ class _SearchPageState extends State { @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 @@ -59,7 +58,6 @@ class _SearchPageState extends State { title: TextField( controller: _queryFieldController, autofocus: true, - cursorColor: theme.hintColor, keyboardType: TextInputType.text, textInputAction: TextInputAction.go, decoration: InputDecoration( @@ -131,7 +129,7 @@ class _SearchPageState extends State { 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))) ], ), ], diff --git a/green_walking/lib/widgets/location_button.dart b/green_walking/lib/widgets/location_button.dart index 63b4088..7213896 100644 --- a/green_walking/lib/widgets/location_button.dart +++ b/green_walking/lib/widgets/location_button.dart @@ -47,7 +47,7 @@ class _LocationButtonState extends State { 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( valueListenable: widget.trackUserLocation, @@ -63,7 +63,7 @@ class _LocationButtonState extends State { return Icon( icon, size: 27, - color: Colors.white, + color: theme.colorScheme.onPrimary, ); })), ), diff --git a/green_walking/lib/widgets/navigation_drawer.dart b/green_walking/lib/widgets/navigation_drawer.dart index e394ad6..358434d 100644 --- a/green_walking/lib/widgets/navigation_drawer.dart +++ b/green_walking/lib/widgets/navigation_drawer.dart @@ -21,14 +21,14 @@ class AppNavigationDrawer extends StatelessWidget { children: [ DrawerHeader( decoration: BoxDecoration( - color: theme.primaryColor, + color: theme.colorScheme.primary, ), child: Column(children: [ Row(children: [ Text( locale.appTitle, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: theme.colorScheme.onPrimary, fontSize: 22, ), ), @@ -36,8 +36,8 @@ class AppNavigationDrawer extends StatelessWidget { Row( children: [ Text(locale.appSlogan, - style: const TextStyle( - color: Colors.white70, + style: TextStyle( + color: theme.colorScheme.onPrimary, )), ], ) diff --git a/green_walking/lib/widgets/search_result_card.dart b/green_walking/lib/widgets/search_result_card.dart index 22ea00f..bd8b304 100644 --- a/green_walking/lib/widgets/search_result_card.dart +++ b/green_walking/lib/widgets/search_result_card.dart @@ -49,7 +49,7 @@ class _TrailingWidget extends StatelessWidget { final List children = [ IconButton( - color: theme.primaryColor, + color: theme.colorScheme.primary, tooltip: locale.openLocationInDefaultAppSemanticLabel, icon: Icon(Icons.open_in_new, semanticLabel: locale.openLocationInDefaultAppSemanticLabel), onPressed: () => launchUrlString( diff --git a/green_walking/lib/widgets/user_consent_dialog.dart b/green_walking/lib/widgets/user_consent_dialog.dart index b748ef1..d165c0b 100644 --- a/green_walking/lib/widgets/user_consent_dialog.dart +++ b/green_walking/lib/widgets/user_consent_dialog.dart @@ -31,13 +31,13 @@ class UserConsentDialog extends StatelessWidget { child: ListBody( children: [ RichText( - text: TextSpan(style: TextStyle(color: theme.hintColor), children: [ + text: TextSpan(style: TextStyle(color: theme.colorScheme.secondary), children: [ 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); @@ -45,7 +45,7 @@ class UserConsentDialog extends StatelessWidget { ), TextSpan( text: '.', - style: TextStyle(color: theme.hintColor), + style: TextStyle(color: theme.colorScheme.secondary), ), ]), ), From dd2affcc9d774d517093133ba77731345f289096 Mon Sep 17 00:00:00 2001 From: Xennis Date: Thu, 18 Jul 2024 20:42:29 +0200 Subject: [PATCH 3/3] Minor style adjustments --- green_walking/lib/pages/search.dart | 2 +- green_walking/lib/widgets/search_result_card.dart | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/green_walking/lib/pages/search.dart b/green_walking/lib/pages/search.dart index 0b682a3..dbda445 100644 --- a/green_walking/lib/pages/search.dart +++ b/green_walking/lib/pages/search.dart @@ -67,7 +67,7 @@ class _SearchPageState extends State { onSubmitted: _onSearchSubmitted, ), ), - Padding(padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), child: _resultList(context)), + Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child: _resultList(context)), ], ), )); diff --git a/green_walking/lib/widgets/search_result_card.dart b/green_walking/lib/widgets/search_result_card.dart index bd8b304..8de0e45 100644 --- a/green_walking/lib/widgets/search_result_card.dart +++ b/green_walking/lib/widgets/search_result_card.dart @@ -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( @@ -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)), + ) ], ); }