Puts a MapLibre map on screen framed on the region, with the credit obligations that come with showing third-party data satisfied structurally rather than by remembering to add a label. The base map style comes from MAP_STYLE_URL, and with no key configured the app generates a fallback style from the region's own bounding box: a flat background and the extent outline, no network sources at all. That keeps a fresh clone runnable offline without pulling in a boundary dataset that would carry its own licence, and it deliberately looks like a placeholder so it is not mistaken for a finished map. Attribution is driven by what is actually rendered. The bar lists the credits for the active sources only, because crediting OpenStreetMap while showing the fallback style would be a false attribution, and it says plainly when no base map is configured. It sits below the map rather than floating over it so no map control or gesture overlay can occlude a credit that the ODbL and CC BY-SA terms require to be visible. The Sources screen leads with the independence disclaimer, before the sources it qualifies, so a reader who stops after the first screenful has still seen it. Sources with no stated licence — ARPA publishes none for the alert bulletin — say so explicitly rather than being shown bare or given an invented one. A separate note explains that the rendered radar frames inherit CC BY-SA from the DPC source data. Also declares the INTERNET permission in the main manifest: Flutter injects it into the debug and profile manifests only, so a release build would otherwise fail every request on device. Verified: analyze clean, 66 tests passing, appbundle builds with the native MapLibre plugin. Not verified visually — this machine has no Android device or emulator image, so nobody has watched the map render. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
112 lines
3.5 KiB
Dart
112 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:maplibre_gl/maplibre_gl.dart';
|
|
|
|
import '../../core/config/env.dart';
|
|
import '../../core/region/region_config.dart';
|
|
import '../../core/region/region_repository.dart';
|
|
import '../../l10n/app_localizations.dart';
|
|
import 'attribution_bar.dart';
|
|
import 'map_style.dart';
|
|
|
|
/// The radar map.
|
|
///
|
|
/// Milestone 2 renders the base map, frames it on the region and keeps the
|
|
/// attribution visible. The radar image layers and the timeline arrive in
|
|
/// milestone 3.
|
|
class RadarMapScreen extends ConsumerWidget {
|
|
const RadarMapScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final l10n = AppLocalizations.of(context);
|
|
final region = ref.watch(regionConfigProvider);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(l10n.appTitle)),
|
|
body: switch (region) {
|
|
AsyncData(:final value) => _MapWithAttribution(region: value),
|
|
AsyncError(:final error) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Text('${l10n.dataUnavailable}\n$error'),
|
|
),
|
|
),
|
|
_ => Center(child: Text(l10n.loading)),
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MapWithAttribution extends StatelessWidget {
|
|
const _MapWithAttribution({required this.region});
|
|
|
|
final RegionConfig region;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context);
|
|
final style = MapStyle.forRegion(region);
|
|
|
|
return Column(
|
|
children: [
|
|
if (Env.isDemoMode)
|
|
MaterialBanner(
|
|
content: Text(l10n.demoModeBanner),
|
|
actions: const [SizedBox.shrink()],
|
|
),
|
|
Expanded(
|
|
child: _RegionMap(region: region, style: style),
|
|
),
|
|
// Outside the map rather than floating over it, so the credit can never
|
|
// be occluded by a map control or a gesture overlay.
|
|
AttributionBar(
|
|
region: region,
|
|
activeSourceIds: style.attributionIds,
|
|
showBaseMapNotice: style.kind == BaseMapKind.offlineFallback,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _RegionMap extends StatelessWidget {
|
|
const _RegionMap({required this.region, required this.style});
|
|
|
|
final RegionConfig region;
|
|
final MapStyle style;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final center = region.map.center;
|
|
final zoom = region.map.zoom;
|
|
final bounds = region.bounds;
|
|
|
|
return MapLibreMap(
|
|
styleString: style.styleString,
|
|
initialCameraPosition: CameraPosition(
|
|
target: LatLng(center.latitude, center.longitude),
|
|
zoom: zoom.initial,
|
|
),
|
|
minMaxZoomPreference: MinMaxZoomPreference(zoom.min, zoom.max),
|
|
// Panning is confined to the region: this app has data for Piedmont and
|
|
// nowhere else, so letting the user drift away would only ever show an
|
|
// empty map.
|
|
cameraTargetBounds: CameraTargetBounds(
|
|
LatLngBounds(
|
|
southwest: LatLng(bounds.south, bounds.west),
|
|
northeast: LatLng(bounds.north, bounds.east),
|
|
),
|
|
),
|
|
// Kept enabled on top of our own attribution bar: some tile providers
|
|
// require the plugin's own attribution control, and a duplicated credit
|
|
// is harmless where a missing one is a licence breach.
|
|
attributionButtonPosition: AttributionButtonPosition.bottomRight,
|
|
compassEnabled: false,
|
|
rotateGesturesEnabled: false,
|
|
tiltGesturesEnabled: false,
|
|
myLocationEnabled: false,
|
|
);
|
|
}
|
|
}
|