diff --git a/lib/widgets/common/map/geo_map.dart b/lib/widgets/common/map/geo_map.dart index f52cae77e..ffd8176a6 100644 --- a/lib/widgets/common/map/geo_map.dart +++ b/lib/widgets/common/map/geo_map.dart @@ -5,7 +5,6 @@ import 'package:aves/model/entry.dart'; import 'package:aves/model/settings/enums.dart'; import 'package:aves/model/settings/map_style.dart'; import 'package:aves/model/settings/settings.dart'; -import 'package:aves/services/common/services.dart'; import 'package:aves/theme/durations.dart'; import 'package:aves/utils/change_notifier.dart'; import 'package:aves/utils/constants.dart'; @@ -152,117 +151,111 @@ class _GeoMapState extends State { onTap(clusterAverageLocation, markerEntry, getClusterEntries); } - return FutureBuilder( - future: availability.isConnected, - builder: (context, snapshot) { - if (snapshot.data != true) return const SizedBox(); - return Selector( - selector: (context, s) => s.infoMapStyle, - builder: (context, mapStyle, child) { - final isGoogleMaps = mapStyle.isGoogleMaps; - final progressive = !isGoogleMaps; - Widget _buildMarkerWidget(MarkerKey key) => ImageMarker( - key: key, - entry: key.entry, - count: key.count, - extent: GeoMap.markerImageExtent, - arrowSize: GeoMap.markerArrowSize, - progressive: progressive, - ); + return Selector( + selector: (context, s) => s.infoMapStyle, + builder: (context, mapStyle, child) { + final isGoogleMaps = mapStyle.isGoogleMaps; + final progressive = !isGoogleMaps; + Widget _buildMarkerWidget(MarkerKey key) => ImageMarker( + key: key, + entry: key.entry, + count: key.count, + extent: GeoMap.markerImageExtent, + arrowSize: GeoMap.markerArrowSize, + progressive: progressive, + ); - Widget child = isGoogleMaps - ? EntryGoogleMap( - controller: widget.controller, - clusterListenable: _clusterChangeNotifier, - boundsNotifier: _boundsNotifier, - minZoom: 0, - maxZoom: 20, - style: mapStyle, - markerClusterBuilder: _buildMarkerClusters, - markerWidgetBuilder: _buildMarkerWidget, - dotLocationNotifier: widget.dotLocationNotifier, - onUserZoomChange: widget.onUserZoomChange, - onMapTap: widget.onMapTap, - onMarkerTap: _onMarkerTap, - openMapPage: widget.openMapPage, - ) - : EntryLeafletMap( - controller: widget.controller, - clusterListenable: _clusterChangeNotifier, - boundsNotifier: _boundsNotifier, - minZoom: 2, - maxZoom: 16, - style: mapStyle, - markerClusterBuilder: _buildMarkerClusters, - markerWidgetBuilder: _buildMarkerWidget, - dotLocationNotifier: widget.dotLocationNotifier, - markerSize: Size( - GeoMap.markerImageExtent + ImageMarker.outerBorderWidth * 2, - 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((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), + Widget child = isGoogleMaps + ? EntryGoogleMap( + controller: widget.controller, + clusterListenable: _clusterChangeNotifier, + boundsNotifier: _boundsNotifier, + minZoom: 0, + maxZoom: 20, + style: mapStyle, + markerClusterBuilder: _buildMarkerClusters, + markerWidgetBuilder: _buildMarkerWidget, + dotLocationNotifier: widget.dotLocationNotifier, + onUserZoomChange: widget.onUserZoomChange, + onMapTap: widget.onMapTap, + onMarkerTap: _onMarkerTap, + openMapPage: widget.openMapPage, + ) + : EntryLeafletMap( + controller: widget.controller, + clusterListenable: _clusterChangeNotifier, + boundsNotifier: _boundsNotifier, + minZoom: 2, + maxZoom: 16, + style: mapStyle, + markerClusterBuilder: _buildMarkerClusters, + markerWidgetBuilder: _buildMarkerWidget, + dotLocationNotifier: widget.dotLocationNotifier, + markerSize: Size( + GeoMap.markerImageExtent + ImageMarker.outerBorderWidth * 2, + 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, + ); - return AnimatedSize( - alignment: Alignment.topCenter, - curve: Curves.easeInOutCubic, - duration: Durations.mapStyleSwitchAnimation, - child: ValueListenableBuilder( - valueListenable: widget.isAnimatingNotifier, - builder: (context, animating, child) { - if (!animating && isGoogleMaps) { - _googleMapsLoaded = true; - } - Widget replacement = Stack( - children: [ - const MapDecorator(), - 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, - ), - ); - }, + final mapHeight = context.select((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), + ), + ], + ); + + return AnimatedSize( + alignment: Alignment.topCenter, + curve: Curves.easeInOutCubic, + duration: Durations.mapStyleSwitchAnimation, + child: ValueListenableBuilder( + valueListenable: widget.isAnimatingNotifier, + builder: (context, animating, child) { + if (!animating && isGoogleMaps) { + _googleMapsLoaded = true; + } + Widget replacement = Stack( + children: [ + const MapDecorator(), + 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, + ), ); }, ); diff --git a/lib/widgets/common/map/leaflet/tile_layers.dart b/lib/widgets/common/map/leaflet/tile_layers.dart index 759502bcb..069a0967c 100644 --- a/lib/widgets/common/map/leaflet/tile_layers.dart +++ b/lib/widgets/common/map/leaflet/tile_layers.dart @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:provider/provider.dart'; +const _tileLayerBackgroundColor = Colors.transparent; + class OSMHotLayer extends StatelessWidget { const OSMHotLayer({Key? key}) : super(key: key); @@ -12,6 +14,7 @@ class OSMHotLayer extends StatelessWidget { options: TileLayerOptions( urlTemplate: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c'], + backgroundColor: _tileLayerBackgroundColor, tileProvider: _NetworkTileProvider(), retinaMode: context.select((mq) => mq.devicePixelRatio) > 1, ), @@ -28,6 +31,7 @@ class StamenTonerLayer extends StatelessWidget { options: TileLayerOptions( urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.png', subdomains: ['a', 'b', 'c', 'd'], + backgroundColor: _tileLayerBackgroundColor, tileProvider: _NetworkTileProvider(), retinaMode: context.select((mq) => mq.devicePixelRatio) > 1, ), @@ -44,6 +48,7 @@ class StamenWatercolorLayer extends StatelessWidget { options: TileLayerOptions( urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg', subdomains: ['a', 'b', 'c', 'd'], + backgroundColor: _tileLayerBackgroundColor, tileProvider: _NetworkTileProvider(), retinaMode: context.select((mq) => mq.devicePixelRatio) > 1, ), diff --git a/lib/widgets/map/map_page.dart b/lib/widgets/map/map_page.dart index 171eafe28..214dd0398 100644 --- a/lib/widgets/map/map_page.dart +++ b/lib/widgets/map/map_page.dart @@ -83,7 +83,7 @@ class _Content extends StatefulWidget { class _ContentState extends State<_Content> with SingleTickerProviderStateMixin { final List _subscriptions = []; final AvesMapController _mapController = AvesMapController(); - late final ValueNotifier _isPageAnimatingNotifier; + final ValueNotifier _isPageAnimatingNotifier = ValueNotifier(false); final ValueNotifier _selectedIndexNotifier = ValueNotifier(0); final ValueNotifier _regionCollectionNotifier = ValueNotifier(null); final ValueNotifier _dotLocationNotifier = ValueNotifier(null); @@ -102,13 +102,11 @@ class _ContentState extends State<_Content> with SingleTickerProviderStateMixin super.initState(); if (settings.infoMapStyle.isGoogleMaps) { - _isPageAnimatingNotifier = ValueNotifier(true); + _isPageAnimatingNotifier.value = true; Future.delayed(Durations.pageTransitionAnimation * timeDilation).then((_) { if (!mounted) return; _isPageAnimatingNotifier.value = false; }); - } else { - _isPageAnimatingNotifier = ValueNotifier(false); } _dotEntryNotifier.addListener(_updateInfoEntry);