todos-contra-el-fuego-mobile/lib/genericMapBottom.dart
vjrj eb0d19621c Migrate fires_flutter to flutter_map v6.1.0 and complete major null-safety fixes
- Updated Android build files: gradle plugin 8.2.2, gradle 8.3, SDK 34, minSdk 21
- Ran dart fix --apply for 87 automatic null-safety fixes
- Migrated flutter_map v6 API breaking changes:
  - MapOptions: center → initialCenter, zoom → initialZoom
  - layers → children structure
  - TileLayerOptions/MarkerLayerOptions/PolylineLayerOptions → TileLayer/MarkerLayer/PolylineLayer
  - Removed plugin_api.dart imports
  - Converted old plugin system (ZoomMapPlugin, AttributionPlugin, etc.) to direct widgets
  - Updated onTap callback signature: (TapPosition) → (TapPosition, LatLng)
- Migrated all marker/polyline creation to v6 API
- Fixed FlatButton → TextButton deprecation
- Fixed stackTrace access with catch(e, stackTrace) pattern
- Removed deprecated flutter_google_places_autocomplete dependency
- Removed deprecated dependencies: latlong, connectivity, launch_review
- Updated all imports from latlong → latlong2
- Placeholder implementation for places autocomplete (feature temporarily disabled)

Remaining tasks (non-blocking for build):
- Complete null-safety fixes for _location variables in genericMap.dart
- Fix theme.dart MaterialTheme parameter issues
- Fix customStepper.dart null-safety issues
- Final build and testing
2026-03-05 02:10:14 +01:00

135 lines
5.6 KiB
Dart

import 'dart:async';
import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:flutter/material.dart';
import 'colors.dart';
import 'customBottomAppBar.dart';
import 'customMoment.dart';
import 'generated/i18n.dart';
import 'models/appState.dart';
import 'models/falsePositiveTypes.dart';
import 'models/fireMapState.dart';
typedef void OnSave();
typedef void OnCancel();
typedef void OnFalsePositive(FireNotification notif, FalsePositiveType type);
class GenericMapBottom extends StatelessWidget {
final OnSave onSave;
final OnCancel onCancel;
final OnFalsePositive onFalsePositive;
final FireMapState state;
final GlobalKey<ScaffoldState> scaffoldKey;
GenericMapBottom(
{required this.onSave,
required this.onCancel,
required this.onFalsePositive,
required this.state,
required this.scaffoldKey});
@override
Widget build(BuildContext context) {
YourLocation loc = state.yourLocation;
int kmAround = loc.distance;
return new CustomBottomAppBar(
fabLocation: FloatingActionButtonLocation.centerFloat,
showNotch: false,
color: fires100,
mainAxisAlignment: MainAxisAlignment.center,
actions: buildActionList(loc, context, kmAround, scaffoldKey));
}
List<Widget> buildActionList(YourLocation loc, BuildContext context,
int kmAround, GlobalKey<ScaffoldState> scaffoldState) {
List<Widget> actionList = [];
switch (state.status) {
case FireMapStatus.edit:
actionList.add(new FlatButton(
onPressed: onSave,
child: new Text(S.of(context).SAVE,
style: Theme.of(context).textTheme.labelLarge)));
actionList.add(new FlatButton(
onPressed: onCancel,
child: new Text(S.of(context).CANCEL,
style: Theme.of(context).textTheme.labelLarge)));
break;
case FireMapStatus.subscriptionConfirm:
break;
case FireMapStatus.viewFireNotification:
actionList.add(new Flexible(
child: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: listWithoutNulls(<Widget>[
new Text(state.fireNotification.description),
// TODO fire type (neighbout, NASA, etc)
new SizedBox(height: 5.0),
new Row(
children: <Widget>[
new Icon(Icons.access_time),
new SizedBox(width: 5.0),
new Text(Moment.now()
.from(context, state.fireNotification.when)),
],
),
state.industries.length > 0 || state.falsePos.length > 0
? new Padding(
padding: new EdgeInsets.only(top: 10.0),
child: new Text(
S.of(context).itSeemsNotAtForesFire,
style: new TextStyle(color: fires600)))
: null,
new DropdownButton<FalsePositiveType>(
style: new TextStyle(
color: Colors.black,
// fontSize: 18.0,
),
hint: new Text(S.of(context).notAWildfire),
items: FalsePositiveType.values
.map((FalsePositiveType value) {
String menuText;
switch (value) {
case FalsePositiveType.industry:
menuText = S.of(context).itSeemsAIndustry;
break;
case FalsePositiveType.controled:
menuText =
S.of(context).itSeemsAControlledBurning;
break;
case FalsePositiveType.falsealarm:
menuText = S.of(context).itSeemsAFalseAlarm;
}
return new DropdownMenuItem<FalsePositiveType>(
value: value, child: new Text(menuText));
}).toList(),
onChanged: (value) async {
onFalsePositive(state.fireNotification, value);
await new Future.delayed(
new Duration(milliseconds: 500));
ScaffoldMessenger.of(context)
.showSnackBar(new SnackBar(
content: new Text(
S.of(context).thanksForParticipating),
));
}),
])))));
break;
case FireMapStatus.unsubscribe:
case FireMapStatus.view:
actionList.add(new Text(state.numFires > 0
? loc.currentNumFires == 1
? S.of(context).fireAroundThisArea(loc.distance.toString())
: S.of(context).firesAroundThisArea(
state.numFires.toString(), kmAround.toString())
: S.of(context).noFiresAroundThisArea(kmAround.toString())));
// SizedBox(width: 10.0)
}
return actionList;
}
}