minor fixes
This commit is contained in:
parent
5338cb47c2
commit
c63de86c78
12 changed files with 40 additions and 11 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:aves/geo/countries.dart';
|
||||
import 'package:aves/model/entry_cache.dart';
|
||||
|
@ -178,6 +179,8 @@ class AvesEntry {
|
|||
return _extension;
|
||||
}
|
||||
|
||||
bool get isMissingAtPath => path != null && !File(path!).existsSync();
|
||||
|
||||
// the MIME type reported by the Media Store is unreliable
|
||||
// so we use the one found during cataloguing if possible
|
||||
String get mimeType => _catalogMetadata?.mimeType ?? sourceMimeType;
|
||||
|
|
|
@ -40,7 +40,9 @@ class PlatformMetadataFetchService implements MetadataFetchService {
|
|||
});
|
||||
if (result != null) return result as Map;
|
||||
} on PlatformException catch (e, stack) {
|
||||
await reportService.recordError(e, stack);
|
||||
if (!entry.isMissingAtPath) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -118,7 +120,9 @@ class PlatformMetadataFetchService implements MetadataFetchService {
|
|||
}
|
||||
return MultiPageInfo.fromPageMaps(entry, pageMaps);
|
||||
} on PlatformException catch (e, stack) {
|
||||
await reportService.recordError(e, stack);
|
||||
if (!entry.isMissingAtPath) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -348,7 +348,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
|||
// we compute the default name beforehand
|
||||
// because some filter labels need localization
|
||||
final sortedFilters = List<CollectionFilter>.from(filters)..sort();
|
||||
defaultName = sortedFilters.first.getLabel(context);
|
||||
defaultName = sortedFilters.first.getLabel(context).replaceAll('\n', ' ');
|
||||
}
|
||||
final result = await showDialog<Tuple2<AvesEntry?, String>>(
|
||||
context: context,
|
||||
|
|
|
@ -57,7 +57,7 @@ class GeoMap extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _GeoMapState extends State<GeoMap> {
|
||||
// as of google_maps_flutter v2.0.6, Google Maps initialization is blocking
|
||||
// as of google_maps_flutter v2.0.6, Google map initialization is blocking
|
||||
// cf https://github.com/flutter/flutter/issues/28493
|
||||
// it is especially severe the first time, but still significant afterwards
|
||||
// so we prevent loading it while scrolling or animating
|
||||
|
@ -68,14 +68,21 @@ class _GeoMapState extends State<GeoMap> {
|
|||
|
||||
List<AvesEntry> get entries => widget.entries;
|
||||
|
||||
// cap initial zoom to avoid a zoom change
|
||||
// when toggling overlay on Google map initial state
|
||||
static const double minInitialZoom = 3;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final initialEntry = widget.initialEntry;
|
||||
final points = (initialEntry != null ? [initialEntry] : entries).map((v) => v.latLng!).toSet();
|
||||
_boundsNotifier = ValueNotifier(ZoomedBounds.fromPoints(
|
||||
final bounds = ZoomedBounds.fromPoints(
|
||||
points: points.isNotEmpty ? points : {Constants.wonders[Random().nextInt(Constants.wonders.length)]},
|
||||
collocationZoom: settings.infoMapZoom,
|
||||
);
|
||||
_boundsNotifier = ValueNotifier(bounds.copyWith(
|
||||
zoom: max(bounds.zoom, minInitialZoom),
|
||||
));
|
||||
_defaultMarkerCluster = _buildFluster();
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ class _EntryGoogleMapState extends State<EntryGoogleMap> with WidgetsBindingObse
|
|||
case AppLifecycleState.detached:
|
||||
break;
|
||||
case AppLifecycleState.resumed:
|
||||
// workaround for blank Google Maps when resuming app
|
||||
// workaround for blank Google map when resuming app
|
||||
// cf https://github.com/flutter/flutter/issues/40284
|
||||
_googleMapController?.setMapStyle(null);
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/rendering.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
// generate bitmap from widget, for Google Maps
|
||||
// generate bitmap from widget, for Google map
|
||||
class MarkerGeneratorWidget<T extends Key> extends StatefulWidget {
|
||||
final List<Widget> markers;
|
||||
final bool Function(T markerKey) isReadyToRender;
|
||||
|
|
|
@ -66,7 +66,7 @@ class _EntryLeafletMapState extends State<EntryLeafletMap> with TickerProviderSt
|
|||
|
||||
ZoomedBounds get bounds => boundsNotifier.value;
|
||||
|
||||
// duration should match the uncustomizable Google Maps duration
|
||||
// duration should match the uncustomizable Google map duration
|
||||
static const _cameraAnimationDuration = Duration(milliseconds: 600);
|
||||
|
||||
@override
|
||||
|
|
|
@ -39,7 +39,7 @@ class ImageMarker extends StatelessWidget {
|
|||
)
|
||||
: const SizedBox();
|
||||
|
||||
// need to be sized for the Google Maps marker generator
|
||||
// need to be sized for the Google map marker generator
|
||||
child = SizedBox(
|
||||
width: extent,
|
||||
height: extent,
|
||||
|
|
|
@ -63,5 +63,19 @@ class ZoomedBounds extends Equatable {
|
|||
);
|
||||
}
|
||||
|
||||
ZoomedBounds copyWith({
|
||||
LatLng? sw,
|
||||
LatLng? ne,
|
||||
double? zoom,
|
||||
double? rotation,
|
||||
}) {
|
||||
return ZoomedBounds(
|
||||
sw: sw ?? this.sw,
|
||||
ne: ne ?? this.ne,
|
||||
zoom: zoom ?? this.zoom,
|
||||
rotation: rotation ?? this.rotation,
|
||||
);
|
||||
}
|
||||
|
||||
bool contains(LatLng point) => GeoUtils.contains(sw, ne, point);
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class _AddressRowState extends State<_AddressRow> {
|
|||
child: Container(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
// addresses can include non-latin scripts with inconsistent line height,
|
||||
// which is especially an issue for relayout/painting of heavy Google maps,
|
||||
// which is especially an issue for relayout/painting of heavy Google map,
|
||||
// so we give extra height to give breathing room to the text and stabilize layout
|
||||
height: Theme.of(context).textTheme.bodyText2!.fontSize! * context.select<MediaQueryData, double>((mq) => mq.textScaleFactor) * 2,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
|
|
|
@ -382,7 +382,7 @@ class _MapPageContentState extends State<MapPageContent> with SingleTickerProvid
|
|||
|
||||
void _toggleOverlay() => _overlayVisible.value = !_overlayVisible.value;
|
||||
|
||||
// TODO TLAD [map] as of Flutter v2.5.1 / google_maps_flutter v2.0.10, toggling overlay changes the size of the map, which is an issue for Google Maps on Android 12
|
||||
// TODO TLAD [map] as of Flutter v2.5.1 / google_maps_flutter v2.0.10, toggling overlay changes the size of the map, which is an issue for Google map on Android 12
|
||||
// cf https://github.com/flutter/flutter/issues/90556
|
||||
Future<void> _onOverlayVisibleChange({bool animate = true}) async {
|
||||
if (_overlayVisible.value) {
|
||||
|
|
|
@ -68,6 +68,7 @@ class ViewerDebugPage extends StatelessWidget {
|
|||
'sourceTitle': entry.sourceTitle ?? '',
|
||||
'sourceMimeType': entry.sourceMimeType,
|
||||
'mimeType': entry.mimeType,
|
||||
'isMissingAtPath': '${entry.isMissingAtPath}',
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
|
|
Loading…
Reference in a new issue