todos-contra-el-fuego-mobile/lib/layerSelectorMapPlugin.dart
vjrj 270d9a569e Remove info-level lint issues: avoid_dynamic_calls, use_build_context_synchronously, avoid_print, non_constant_identifier_names
- Type dynamic map accesses properly (avoid_dynamic_calls in genericMap, globalFiresBottomStats)
- Capture context before async gaps (use_build_context_synchronously in genericMap, genericMapBottom, globalFiresBottomStats)
- Replace print() with debugPrint() (avoid_print in firesApi.dart)
- Rename fireMarker function and _LayerSelectorButton to camelCase
- Rename variable FireNotifications to fireNotifications
- Fix no_default_cases in switch statements (add missing subscriptionConfirm case)
- Make FireNotification fields final, remove @immutable from YourLocation (mutable)
- Make monitoredAreas field final in _ViewModel
- Update subscribeViaApi to use copyWith instead of direct field assignment
2026-03-11 16:53:48 +01:00

93 lines
2.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:redux/redux.dart';
import 'models/appState.dart';
import 'redux/fireMapActions.dart';
/// Layer selector widget for changing map layers
class LayerSelectorMapPluginWidget extends StatelessWidget {
const LayerSelectorMapPluginWidget({super.key});
@override
Widget build(BuildContext context) {
final Store<AppState> store = GetIt.instance<Store<AppState>>();
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) =>
Stack(fit: StackFit.expand, children: <Widget>[
Positioned(
top: constraints.maxHeight - 60,
left: 10.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
children: <Widget>[_layerSelectorButton(store)],
)
],
),
)
]));
}
Widget _layerSelectorButton(Store<AppState> store) {
final GlobalKey<PopupMenuButtonState<FireMapLayer>> key =
GlobalKey<PopupMenuButtonState<FireMapLayer>>();
return PopupMenuButton<FireMapLayer>(
key: key,
initialValue: store.state.fireMapState.layer,
onSelected: (FireMapLayer layer) {
store.dispatch(SelectMapLayerAction(layer));
},
itemBuilder: (BuildContext context) {
return FireMapLayer.values.map((FireMapLayer layer) {
final bool isSelected = store.state.fireMapState.layer == layer;
return PopupMenuItem<FireMapLayer>(
value: layer,
child: Row(
children: <Widget>[
Icon(
isSelected ? Icons.check : Icons.check,
color: isSelected ? Colors.blue : Colors.transparent,
size: 20,
),
const SizedBox(width: 8),
Text(
_getLayerName(layer),
style: TextStyle(
fontWeight:
isSelected ? FontWeight.bold : FontWeight.normal,
),
),
],
),
);
}).toList();
},
child: FloatingActionButton(
backgroundColor: Colors.black26,
mini: true,
child: const Icon(Icons.layers),
onPressed: () {
key.currentState?.showButtonMenu();
},
),
);
}
String _getLayerName(FireMapLayer layer) {
switch (layer) {
case FireMapLayer.osmcGrey:
return 'OSMC Grey';
case FireMapLayer.osmc:
return 'OSMC';
case FireMapLayer.esri:
return 'Esri Street';
case FireMapLayer.esriSatellite:
return 'Esri Satellite';
case FireMapLayer.esriTerrain:
return 'Esri Terrain';
}
}
}