diff --git a/lib/widgets/fullscreen/info_page.dart b/lib/widgets/fullscreen/info_page.dart index ab269c9c4..ae47c9df0 100644 --- a/lib/widgets/fullscreen/info_page.dart +++ b/lib/widgets/fullscreen/info_page.dart @@ -4,6 +4,7 @@ import 'package:aves/model/image_entry.dart'; import 'package:aves/model/metadata_service.dart'; import 'package:aves/utils/file_utils.dart'; import 'package:flutter/material.dart'; +import 'package:geocoder/geocoder.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:intl/intl.dart'; @@ -35,7 +36,18 @@ class InfoPageState extends State { } initMetadataLoader() { - _catalogLoader = MetadataService.getCatalogMetadata(entry.path); + _catalogLoader = MetadataService.getCatalogMetadata(entry.path).then((metadata) async { + final latitude = metadata['latitude']; + final longitude = metadata['longitude']; + if (latitude != null && longitude != null) { + final coordinates = Coordinates(latitude, longitude); + final addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates); + if (addresses != null && addresses.length > 0) { + metadata['address'] = addresses.first; + } + } + return metadata; + }); _metadataLoader = MetadataService.getAllMetadata(entry.path); } @@ -91,7 +103,7 @@ class InfoPageState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ..._buildLocationSection(metadata['latitude'], metadata['longitude']), + ..._buildLocationSection(metadata['latitude'], metadata['longitude'], metadata['address']), ..._buildTagSection(metadata['keywords']), ], ); @@ -133,7 +145,7 @@ class InfoPageState extends State { ); } - List _buildLocationSection(double latitude, double longitude) { + List _buildLocationSection(double latitude, double longitude, Address address) { if (latitude == null || longitude == null) return []; final latLng = LatLng(latitude, longitude); return [ @@ -159,6 +171,11 @@ class InfoPageState extends State { ), ), ), + if (address != null) + Padding( + padding: EdgeInsets.only(top: 8), + child: InfoRow('Address', address.addressLine), + ), ]; } diff --git a/pubspec.lock b/pubspec.lock index befefe907..5917b14d2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -60,6 +60,13 @@ packages: description: flutter source: sdk version: "0.0.0" + geocoder: + dependency: "direct main" + description: + name: geocoder + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" google_maps_flutter: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 3d92c9bd6..5068ce354 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: chewie: collection: flutter_sticky_header: + geocoder: google_maps_flutter: intl: photo_view: