info: added map controls
This commit is contained in:
parent
be66415842
commit
dce5a30dca
1 changed files with 72 additions and 20 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
|
import 'package:aves/utils/android_app_service.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/info_page.dart';
|
import 'package:aves/widgets/fullscreen/info/info_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
@ -16,7 +17,16 @@ class LocationSection extends AnimatedWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SectionRow('Location'),
|
SectionRow('Location'),
|
||||||
ImageMap(markerId: entry.path, latLng: LatLng(entry.latLng.item1, entry.latLng.item2)),
|
ImageMap(
|
||||||
|
markerId: entry.path,
|
||||||
|
latLng: LatLng(
|
||||||
|
entry.latLng.item1,
|
||||||
|
entry.latLng.item2,
|
||||||
|
),
|
||||||
|
geoUri: entry.geoUri,
|
||||||
|
// TODO TLAD read preferences/zoom
|
||||||
|
initialZoom: 12,
|
||||||
|
),
|
||||||
if (entry.isLocated)
|
if (entry.isLocated)
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 8),
|
padding: EdgeInsets.only(top: 8),
|
||||||
|
@ -30,41 +40,83 @@ class LocationSection extends AnimatedWidget {
|
||||||
class ImageMap extends StatefulWidget {
|
class ImageMap extends StatefulWidget {
|
||||||
final String markerId;
|
final String markerId;
|
||||||
final LatLng latLng;
|
final LatLng latLng;
|
||||||
|
final String geoUri;
|
||||||
|
final double initialZoom;
|
||||||
|
|
||||||
const ImageMap({Key key, this.markerId, this.latLng}) : super(key: key);
|
const ImageMap({
|
||||||
|
Key key,
|
||||||
|
this.markerId,
|
||||||
|
this.latLng,
|
||||||
|
this.geoUri,
|
||||||
|
this.initialZoom,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => ImageMapState();
|
State<StatefulWidget> createState() => ImageMapState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
||||||
|
GoogleMapController controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
final accentHue = HSVColor.fromColor(Theme.of(context).accentColor).hue;
|
final accentHue = HSVColor.fromColor(Theme.of(context).accentColor).hue;
|
||||||
return SizedBox(
|
return Row(
|
||||||
height: 200,
|
children: [
|
||||||
child: ClipRRect(
|
Expanded(
|
||||||
borderRadius: BorderRadius.all(
|
child: SizedBox(
|
||||||
Radius.circular(16),
|
height: 200,
|
||||||
),
|
child: ClipRRect(
|
||||||
child: GoogleMap(
|
borderRadius: BorderRadius.all(
|
||||||
initialCameraPosition: CameraPosition(
|
Radius.circular(16),
|
||||||
target: widget.latLng,
|
),
|
||||||
zoom: 12,
|
child: GoogleMap(
|
||||||
|
initialCameraPosition: CameraPosition(
|
||||||
|
target: widget.latLng,
|
||||||
|
zoom: widget.initialZoom,
|
||||||
|
),
|
||||||
|
onMapCreated: (controller) => setState(() => this.controller = controller),
|
||||||
|
rotateGesturesEnabled: false,
|
||||||
|
scrollGesturesEnabled: false,
|
||||||
|
zoomGesturesEnabled: false,
|
||||||
|
tiltGesturesEnabled: false,
|
||||||
|
myLocationButtonEnabled: false,
|
||||||
|
markers: [
|
||||||
|
Marker(
|
||||||
|
markerId: MarkerId(widget.markerId),
|
||||||
|
icon: BitmapDescriptor.defaultMarkerWithHue(accentHue),
|
||||||
|
position: widget.latLng,
|
||||||
|
)
|
||||||
|
].toSet(),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
markers: [
|
|
||||||
Marker(
|
|
||||||
markerId: MarkerId(widget.markerId),
|
|
||||||
icon: BitmapDescriptor.defaultMarkerWithHue(accentHue),
|
|
||||||
position: widget.latLng,
|
|
||||||
)
|
|
||||||
].toSet(),
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(width: 8),
|
||||||
|
Column(children: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.add),
|
||||||
|
onPressed: controller == null ? null : () => zoomBy(1),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.remove),
|
||||||
|
onPressed: controller == null ? null : () => zoomBy(-1),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.open_in_new),
|
||||||
|
onPressed: () => AndroidAppService.openMap(widget.geoUri),
|
||||||
|
),
|
||||||
|
])
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zoomBy(double amount) {
|
||||||
|
// TODO TLAD update preferences/zoom
|
||||||
|
controller.animateCamera(CameraUpdate.zoomBy(amount));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue