info: address via geocoder
This commit is contained in:
parent
d831146135
commit
d6d8c6dea2
3 changed files with 28 additions and 3 deletions
|
@ -4,6 +4,7 @@ import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/model/metadata_service.dart';
|
import 'package:aves/model/metadata_service.dart';
|
||||||
import 'package:aves/utils/file_utils.dart';
|
import 'package:aves/utils/file_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:geocoder/geocoder.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
@ -35,7 +36,18 @@ class InfoPageState extends State<InfoPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
initMetadataLoader() {
|
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);
|
_metadataLoader = MetadataService.getAllMetadata(entry.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +103,7 @@ class InfoPageState extends State<InfoPage> {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
..._buildLocationSection(metadata['latitude'], metadata['longitude']),
|
..._buildLocationSection(metadata['latitude'], metadata['longitude'], metadata['address']),
|
||||||
..._buildTagSection(metadata['keywords']),
|
..._buildTagSection(metadata['keywords']),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -133,7 +145,7 @@ class InfoPageState extends State<InfoPage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildLocationSection(double latitude, double longitude) {
|
List<Widget> _buildLocationSection(double latitude, double longitude, Address address) {
|
||||||
if (latitude == null || longitude == null) return [];
|
if (latitude == null || longitude == null) return [];
|
||||||
final latLng = LatLng(latitude, longitude);
|
final latLng = LatLng(latitude, longitude);
|
||||||
return [
|
return [
|
||||||
|
@ -159,6 +171,11 @@ class InfoPageState extends State<InfoPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (address != null)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: 8),
|
||||||
|
child: InfoRow('Address', address.addressLine),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,13 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
google_maps_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -22,6 +22,7 @@ dependencies:
|
||||||
chewie:
|
chewie:
|
||||||
collection:
|
collection:
|
||||||
flutter_sticky_header:
|
flutter_sticky_header:
|
||||||
|
geocoder:
|
||||||
google_maps_flutter:
|
google_maps_flutter:
|
||||||
intl:
|
intl:
|
||||||
photo_view:
|
photo_view:
|
||||||
|
|
Loading…
Reference in a new issue