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

Smaller code improvements #209

Merged
merged 1 commit into from
Oct 4, 2023
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
4 changes: 2 additions & 2 deletions green_walking/lib/library/map_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension MapboxMapPosition on MapboxMap {
Future<Position?> getCameraPosition() async {
try {
final CameraState mapCameraState = await getCameraState();
return positionForCoordinate(mapCameraState.center);
return _positionForCoordinate(mapCameraState.center);
} catch (e) {
log('failed to get camera position: $e');
return null;
Expand All @@ -35,7 +35,7 @@ extension MapboxMapPosition on MapboxMap {
}
}

Position positionForCoordinate(Map<String?, Object?> raw) {
Position _positionForCoordinate(Map<String?, Object?> raw) {
final List<Object?> coordinates = raw['coordinates'] as List<Object?>;
return Position(coordinates[0] as num, coordinates[1] as num);
}
17 changes: 2 additions & 15 deletions green_walking/lib/widgets/map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import '../library/map_utils.dart';
import '../pages/search.dart';
import '../services/shared_prefs.dart';
import '../widgets/app_bar.dart';
import '../widgets/gdpr_dialog.dart';
import '../widgets/page_route.dart';
import '../widgets/location_button.dart';
import '../config.dart';
Expand All @@ -33,21 +32,12 @@ class _MapViewState extends State<MapView> {
CircleAnnotationManager? _circleAnnotationManager;
Timer? _timer;

@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => enableAnalyticsOrConsent(context));
}

@override
Widget build(BuildContext context) {
final AppLocalizations locale = AppLocalizations.of(context)!;
return Stack(
children: <Widget>[
_mapWidget(),
/*Attribution(
satelliteLayer:
_mapboxStyle == MabboxTileset.satellite),*/
LocationButton(
trackUserLocation: _userlocationTracking,
onOkay: (bool permissionGranted) => _onLocationSearchPressed(locale, permissionGranted),
Expand Down Expand Up @@ -80,12 +70,9 @@ class _MapViewState extends State<MapView> {
onMapCreated: (MapboxMap mapboxMap) {
_mapboxMap = mapboxMap;

//mapboxMap.setTelemetryEnabled(false);
//_mapboxMap.setTelemetryEnabled(false);
_mapboxMap.compass.updateSettings(CompassSettings(marginTop: 400.0));
_mapboxMap.scaleBar.updateSettings(ScaleBarSettings(enabled: false));
//mapController!.onSymbolTapped.add(_onSymbolTapped);
//onPositionChanged(mapController!.cameraPosition);

_mapboxMap.annotations.createCircleAnnotationManager().then((value) {
_circleAnnotationManager = value;
});
Expand Down Expand Up @@ -212,7 +199,7 @@ class _MapViewState extends State<MapView> {
});
}

Future<void> _displaySearchResult(Position? position) async {
void _displaySearchResult(Position? position) async {
if (position == null) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions green_walking/lib/widgets/search_result_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ class SearchResultCard extends StatelessWidget {
subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(subtitle),
const Padding(padding: EdgeInsets.only(bottom: 8.0)),
_PlaceCardFooterRow(
_FooterRow(
userPosition: userPosition,
place: place,
)
]),
trailing: _PlaceCardTrailingWidget(place: place),
trailing: _TrailingWidget(place: place),
),
);
}
}

class _PlaceCardTrailingWidget extends StatelessWidget {
const _PlaceCardTrailingWidget({required this.place});
class _TrailingWidget extends StatelessWidget {
const _TrailingWidget({required this.place});

final GeocodingPlace place;

Expand Down Expand Up @@ -68,8 +68,8 @@ class _PlaceCardTrailingWidget extends StatelessWidget {
}
}

class _PlaceCardFooterRow extends StatelessWidget {
const _PlaceCardFooterRow({required this.place, required this.userPosition});
class _FooterRow extends StatelessWidget {
const _FooterRow({required this.place, required this.userPosition});

final GeocodingPlace place;
final Position? userPosition;
Expand Down