map: removed connectivity check, harmonized layer background
This commit is contained in:
parent
3ea5ddd753
commit
b9ef030001
3 changed files with 109 additions and 113 deletions
|
@ -5,7 +5,6 @@ import 'package:aves/model/entry.dart';
|
||||||
import 'package:aves/model/settings/enums.dart';
|
import 'package:aves/model/settings/enums.dart';
|
||||||
import 'package:aves/model/settings/map_style.dart';
|
import 'package:aves/model/settings/map_style.dart';
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/services/common/services.dart';
|
|
||||||
import 'package:aves/theme/durations.dart';
|
import 'package:aves/theme/durations.dart';
|
||||||
import 'package:aves/utils/change_notifier.dart';
|
import 'package:aves/utils/change_notifier.dart';
|
||||||
import 'package:aves/utils/constants.dart';
|
import 'package:aves/utils/constants.dart';
|
||||||
|
@ -152,117 +151,111 @@ class _GeoMapState extends State<GeoMap> {
|
||||||
onTap(clusterAverageLocation, markerEntry, getClusterEntries);
|
onTap(clusterAverageLocation, markerEntry, getClusterEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FutureBuilder<bool>(
|
return Selector<Settings, EntryMapStyle>(
|
||||||
future: availability.isConnected,
|
selector: (context, s) => s.infoMapStyle,
|
||||||
builder: (context, snapshot) {
|
builder: (context, mapStyle, child) {
|
||||||
if (snapshot.data != true) return const SizedBox();
|
final isGoogleMaps = mapStyle.isGoogleMaps;
|
||||||
return Selector<Settings, EntryMapStyle>(
|
final progressive = !isGoogleMaps;
|
||||||
selector: (context, s) => s.infoMapStyle,
|
Widget _buildMarkerWidget(MarkerKey key) => ImageMarker(
|
||||||
builder: (context, mapStyle, child) {
|
key: key,
|
||||||
final isGoogleMaps = mapStyle.isGoogleMaps;
|
entry: key.entry,
|
||||||
final progressive = !isGoogleMaps;
|
count: key.count,
|
||||||
Widget _buildMarkerWidget(MarkerKey key) => ImageMarker(
|
extent: GeoMap.markerImageExtent,
|
||||||
key: key,
|
arrowSize: GeoMap.markerArrowSize,
|
||||||
entry: key.entry,
|
progressive: progressive,
|
||||||
count: key.count,
|
);
|
||||||
extent: GeoMap.markerImageExtent,
|
|
||||||
arrowSize: GeoMap.markerArrowSize,
|
|
||||||
progressive: progressive,
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget child = isGoogleMaps
|
Widget child = isGoogleMaps
|
||||||
? EntryGoogleMap(
|
? EntryGoogleMap(
|
||||||
controller: widget.controller,
|
controller: widget.controller,
|
||||||
clusterListenable: _clusterChangeNotifier,
|
clusterListenable: _clusterChangeNotifier,
|
||||||
boundsNotifier: _boundsNotifier,
|
boundsNotifier: _boundsNotifier,
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
maxZoom: 20,
|
maxZoom: 20,
|
||||||
style: mapStyle,
|
style: mapStyle,
|
||||||
markerClusterBuilder: _buildMarkerClusters,
|
markerClusterBuilder: _buildMarkerClusters,
|
||||||
markerWidgetBuilder: _buildMarkerWidget,
|
markerWidgetBuilder: _buildMarkerWidget,
|
||||||
dotLocationNotifier: widget.dotLocationNotifier,
|
dotLocationNotifier: widget.dotLocationNotifier,
|
||||||
onUserZoomChange: widget.onUserZoomChange,
|
onUserZoomChange: widget.onUserZoomChange,
|
||||||
onMapTap: widget.onMapTap,
|
onMapTap: widget.onMapTap,
|
||||||
onMarkerTap: _onMarkerTap,
|
onMarkerTap: _onMarkerTap,
|
||||||
openMapPage: widget.openMapPage,
|
openMapPage: widget.openMapPage,
|
||||||
)
|
)
|
||||||
: EntryLeafletMap(
|
: EntryLeafletMap(
|
||||||
controller: widget.controller,
|
controller: widget.controller,
|
||||||
clusterListenable: _clusterChangeNotifier,
|
clusterListenable: _clusterChangeNotifier,
|
||||||
boundsNotifier: _boundsNotifier,
|
boundsNotifier: _boundsNotifier,
|
||||||
minZoom: 2,
|
minZoom: 2,
|
||||||
maxZoom: 16,
|
maxZoom: 16,
|
||||||
style: mapStyle,
|
style: mapStyle,
|
||||||
markerClusterBuilder: _buildMarkerClusters,
|
markerClusterBuilder: _buildMarkerClusters,
|
||||||
markerWidgetBuilder: _buildMarkerWidget,
|
markerWidgetBuilder: _buildMarkerWidget,
|
||||||
dotLocationNotifier: widget.dotLocationNotifier,
|
dotLocationNotifier: widget.dotLocationNotifier,
|
||||||
markerSize: Size(
|
markerSize: Size(
|
||||||
GeoMap.markerImageExtent + ImageMarker.outerBorderWidth * 2,
|
GeoMap.markerImageExtent + ImageMarker.outerBorderWidth * 2,
|
||||||
GeoMap.markerImageExtent + ImageMarker.outerBorderWidth * 2 + GeoMap.markerArrowSize.height,
|
GeoMap.markerImageExtent + ImageMarker.outerBorderWidth * 2 + GeoMap.markerArrowSize.height,
|
||||||
),
|
|
||||||
dotMarkerSize: const Size(
|
|
||||||
DotMarker.diameter + ImageMarker.outerBorderWidth * 2,
|
|
||||||
DotMarker.diameter + ImageMarker.outerBorderWidth * 2,
|
|
||||||
),
|
|
||||||
onUserZoomChange: widget.onUserZoomChange,
|
|
||||||
onMapTap: widget.onMapTap,
|
|
||||||
onMarkerTap: _onMarkerTap,
|
|
||||||
openMapPage: widget.openMapPage,
|
|
||||||
);
|
|
||||||
|
|
||||||
final mapHeight = context.select<MapThemeData, double?>((v) => v.mapHeight);
|
|
||||||
child = Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
mapHeight != null
|
|
||||||
? SizedBox(
|
|
||||||
height: mapHeight,
|
|
||||||
child: child,
|
|
||||||
)
|
|
||||||
: Expanded(child: child),
|
|
||||||
SafeArea(
|
|
||||||
top: false,
|
|
||||||
bottom: false,
|
|
||||||
child: Attribution(style: mapStyle),
|
|
||||||
),
|
),
|
||||||
],
|
dotMarkerSize: const Size(
|
||||||
);
|
DotMarker.diameter + ImageMarker.outerBorderWidth * 2,
|
||||||
|
DotMarker.diameter + ImageMarker.outerBorderWidth * 2,
|
||||||
|
),
|
||||||
|
onUserZoomChange: widget.onUserZoomChange,
|
||||||
|
onMapTap: widget.onMapTap,
|
||||||
|
onMarkerTap: _onMarkerTap,
|
||||||
|
openMapPage: widget.openMapPage,
|
||||||
|
);
|
||||||
|
|
||||||
return AnimatedSize(
|
final mapHeight = context.select<MapThemeData, double?>((v) => v.mapHeight);
|
||||||
alignment: Alignment.topCenter,
|
child = Column(
|
||||||
curve: Curves.easeInOutCubic,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
duration: Durations.mapStyleSwitchAnimation,
|
children: [
|
||||||
child: ValueListenableBuilder<bool>(
|
mapHeight != null
|
||||||
valueListenable: widget.isAnimatingNotifier,
|
? SizedBox(
|
||||||
builder: (context, animating, child) {
|
height: mapHeight,
|
||||||
if (!animating && isGoogleMaps) {
|
child: child,
|
||||||
_googleMapsLoaded = true;
|
)
|
||||||
}
|
: Expanded(child: child),
|
||||||
Widget replacement = Stack(
|
SafeArea(
|
||||||
children: [
|
top: false,
|
||||||
const MapDecorator(),
|
bottom: false,
|
||||||
MapButtonPanel(
|
child: Attribution(style: mapStyle),
|
||||||
boundsNotifier: _boundsNotifier,
|
),
|
||||||
openMapPage: widget.openMapPage,
|
],
|
||||||
),
|
);
|
||||||
],
|
|
||||||
);
|
return AnimatedSize(
|
||||||
if (mapHeight != null) {
|
alignment: Alignment.topCenter,
|
||||||
replacement = SizedBox(
|
curve: Curves.easeInOutCubic,
|
||||||
height: mapHeight,
|
duration: Durations.mapStyleSwitchAnimation,
|
||||||
child: replacement,
|
child: ValueListenableBuilder<bool>(
|
||||||
);
|
valueListenable: widget.isAnimatingNotifier,
|
||||||
}
|
builder: (context, animating, child) {
|
||||||
return Visibility(
|
if (!animating && isGoogleMaps) {
|
||||||
visible: !isGoogleMaps || _googleMapsLoaded,
|
_googleMapsLoaded = true;
|
||||||
replacement: replacement,
|
}
|
||||||
child: child!,
|
Widget replacement = Stack(
|
||||||
);
|
children: [
|
||||||
},
|
const MapDecorator(),
|
||||||
child: child,
|
MapButtonPanel(
|
||||||
),
|
boundsNotifier: _boundsNotifier,
|
||||||
);
|
openMapPage: widget.openMapPage,
|
||||||
},
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (mapHeight != null) {
|
||||||
|
replacement = SizedBox(
|
||||||
|
height: mapHeight,
|
||||||
|
child: replacement,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Visibility(
|
||||||
|
visible: !isGoogleMaps || _googleMapsLoaded,
|
||||||
|
replacement: replacement,
|
||||||
|
child: child!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
const _tileLayerBackgroundColor = Colors.transparent;
|
||||||
|
|
||||||
class OSMHotLayer extends StatelessWidget {
|
class OSMHotLayer extends StatelessWidget {
|
||||||
const OSMHotLayer({Key? key}) : super(key: key);
|
const OSMHotLayer({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@ -12,6 +14,7 @@ class OSMHotLayer extends StatelessWidget {
|
||||||
options: TileLayerOptions(
|
options: TileLayerOptions(
|
||||||
urlTemplate: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
|
urlTemplate: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
|
||||||
subdomains: ['a', 'b', 'c'],
|
subdomains: ['a', 'b', 'c'],
|
||||||
|
backgroundColor: _tileLayerBackgroundColor,
|
||||||
tileProvider: _NetworkTileProvider(),
|
tileProvider: _NetworkTileProvider(),
|
||||||
retinaMode: context.select<MediaQueryData, double>((mq) => mq.devicePixelRatio) > 1,
|
retinaMode: context.select<MediaQueryData, double>((mq) => mq.devicePixelRatio) > 1,
|
||||||
),
|
),
|
||||||
|
@ -28,6 +31,7 @@ class StamenTonerLayer extends StatelessWidget {
|
||||||
options: TileLayerOptions(
|
options: TileLayerOptions(
|
||||||
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.png',
|
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.png',
|
||||||
subdomains: ['a', 'b', 'c', 'd'],
|
subdomains: ['a', 'b', 'c', 'd'],
|
||||||
|
backgroundColor: _tileLayerBackgroundColor,
|
||||||
tileProvider: _NetworkTileProvider(),
|
tileProvider: _NetworkTileProvider(),
|
||||||
retinaMode: context.select<MediaQueryData, double>((mq) => mq.devicePixelRatio) > 1,
|
retinaMode: context.select<MediaQueryData, double>((mq) => mq.devicePixelRatio) > 1,
|
||||||
),
|
),
|
||||||
|
@ -44,6 +48,7 @@ class StamenWatercolorLayer extends StatelessWidget {
|
||||||
options: TileLayerOptions(
|
options: TileLayerOptions(
|
||||||
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg',
|
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg',
|
||||||
subdomains: ['a', 'b', 'c', 'd'],
|
subdomains: ['a', 'b', 'c', 'd'],
|
||||||
|
backgroundColor: _tileLayerBackgroundColor,
|
||||||
tileProvider: _NetworkTileProvider(),
|
tileProvider: _NetworkTileProvider(),
|
||||||
retinaMode: context.select<MediaQueryData, double>((mq) => mq.devicePixelRatio) > 1,
|
retinaMode: context.select<MediaQueryData, double>((mq) => mq.devicePixelRatio) > 1,
|
||||||
),
|
),
|
||||||
|
|
|
@ -83,7 +83,7 @@ class _Content extends StatefulWidget {
|
||||||
class _ContentState extends State<_Content> with SingleTickerProviderStateMixin {
|
class _ContentState extends State<_Content> with SingleTickerProviderStateMixin {
|
||||||
final List<StreamSubscription> _subscriptions = [];
|
final List<StreamSubscription> _subscriptions = [];
|
||||||
final AvesMapController _mapController = AvesMapController();
|
final AvesMapController _mapController = AvesMapController();
|
||||||
late final ValueNotifier<bool> _isPageAnimatingNotifier;
|
final ValueNotifier<bool> _isPageAnimatingNotifier = ValueNotifier(false);
|
||||||
final ValueNotifier<int?> _selectedIndexNotifier = ValueNotifier(0);
|
final ValueNotifier<int?> _selectedIndexNotifier = ValueNotifier(0);
|
||||||
final ValueNotifier<CollectionLens?> _regionCollectionNotifier = ValueNotifier(null);
|
final ValueNotifier<CollectionLens?> _regionCollectionNotifier = ValueNotifier(null);
|
||||||
final ValueNotifier<LatLng?> _dotLocationNotifier = ValueNotifier(null);
|
final ValueNotifier<LatLng?> _dotLocationNotifier = ValueNotifier(null);
|
||||||
|
@ -102,13 +102,11 @@ class _ContentState extends State<_Content> with SingleTickerProviderStateMixin
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
if (settings.infoMapStyle.isGoogleMaps) {
|
if (settings.infoMapStyle.isGoogleMaps) {
|
||||||
_isPageAnimatingNotifier = ValueNotifier(true);
|
_isPageAnimatingNotifier.value = true;
|
||||||
Future.delayed(Durations.pageTransitionAnimation * timeDilation).then((_) {
|
Future.delayed(Durations.pageTransitionAnimation * timeDilation).then((_) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
_isPageAnimatingNotifier.value = false;
|
_isPageAnimatingNotifier.value = false;
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
_isPageAnimatingNotifier = ValueNotifier(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dotEntryNotifier.addListener(_updateInfoEntry);
|
_dotEntryNotifier.addListener(_updateInfoEntry);
|
||||||
|
|
Loading…
Reference in a new issue