todos-contra-el-fuego-mobile/lib/genericMapBottom.dart
vjrj a5e0335f72 fix: resolve all warnings (59 warnings → 0)
- Fix bloc_lint include_file_not_found by removing unneeded include
- Add explicit type annotations to callback parameters in activeFires.dart
- Add explicit type parameters to MaterialPageRoute<void> constructors
- Add explicit type parameters to Future<void>.delayed() calls
- Fix error handler signatures: (Object err, StackTrace stack)
- Remove 'const' from genericMap() widget construction (StatefulWidget)

All strict analysis errors and warnings now resolved (0 errors, 0 warnings).
Remaining 339 issues are info-level linting suggestions.
2026-03-06 11:28:04 +01:00

142 lines
5.8 KiB
Dart

import 'dart:async';
import 'package:comunes_flutter/comunes_flutter.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';
import 'models/fireNotification.dart';
import 'models/yourLocation.dart';
typedef OnSave = void Function();
typedef OnCancel = void Function();
typedef OnFalsePositive = void Function(
FireNotification notif, FalsePositiveType type);
class GenericMapBottom extends StatelessWidget {
const GenericMapBottom(
{super.key,
required this.onSave,
required this.onCancel,
required this.onFalsePositive,
required this.state,
required this.scaffoldKey});
final OnSave onSave;
final OnCancel onCancel;
final OnFalsePositive onFalsePositive;
final FireMapState state;
final GlobalKey<ScaffoldState> scaffoldKey;
@override
Widget build(BuildContext context) {
final YourLocation? locOrNull = state.yourLocation;
if (locOrNull == null) {
return const SizedBox.shrink();
}
final YourLocation loc = locOrNull;
final int kmAround = loc.distance;
return CustomBottomAppBar(
fabLocation: FloatingActionButtonLocation.centerFloat,
color: fires100,
actions: buildActionList(loc, context, kmAround, scaffoldKey));
}
List<Widget> buildActionList(YourLocation loc, BuildContext context,
int kmAround, GlobalKey<ScaffoldState> scaffoldState) {
final List<Widget> actionList = <Widget>[];
switch (state.status) {
case FireMapStatus.edit:
actionList.add(TextButton(
onPressed: onSave,
child: Text(S.of(context).SAVE,
style: Theme.of(context).textTheme.labelLarge)));
actionList.add(TextButton(
onPressed: onCancel,
child: Text(S.of(context).CANCEL,
style: Theme.of(context).textTheme.labelLarge)));
break;
case FireMapStatus.subscriptionConfirm:
break;
case FireMapStatus.viewFireNotification:
final FireNotification? notif = state.fireNotification;
if (notif != null) {
actionList.add(Flexible(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: listWithoutNulls(<Widget?>[
Text(notif.description),
// TODOfire type (neighbout, NASA, etc)
const SizedBox(height: 5.0),
Row(
children: <Widget>[
const Icon(Icons.access_time),
const SizedBox(width: 5.0),
Text(Moment.now().from(context, notif.when)),
],
),
if (state.industries.isNotEmpty ||
state.falsePos.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Text(S.of(context).itSeemsNotAtForesFire,
style: const TextStyle(color: fires600)))
else
null,
DropdownButton<FalsePositiveType>(
style: const TextStyle(
color: Colors.black,
// fontSize: 18.0,
),
hint: 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 DropdownMenuItem<FalsePositiveType>(
value: value, child: Text(menuText));
}).toList(),
onChanged: (FalsePositiveType? value) async {
if (value != null) {
onFalsePositive(notif, value);
}
await Future<void>.delayed(
const Duration(milliseconds: 500));
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content:
Text(S.of(context).thanksForParticipating),
));
}),
] as List<Widget>)))));
}
break;
case FireMapStatus.unsubscribe:
case FireMapStatus.view:
actionList.add(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;
}
}