Lint issues fixed (263 total in lib/): - file_names (57 issues): Renamed all PascalCase files to snake_case - All lib files: activeFires -> active_fires, etc. - All models: appState -> app_state, fireMapState -> fire_map_state, etc. - All redux files: appActions -> app_actions, appReducer -> app_reducer, etc. - Updated all import statements and exports across the codebase - Fixed unused imports, exports, and references in rebuilt modules Style fixes (16 issues): - prefer_generic_function_type_aliases (2): Updated typedef syntax from old to new - unnecessary_nullable_for_final_variable_declarations (2): Removed ? from non-nullable types - unnecessary_import: Removed duplicate meta/meta import - unnecessary_parenthesis: Removed unnecessary parentheses in expressions - avoid_renaming_method_parameters: Renamed parameter 'o' to 'other' - prefer_const_declarations: Changed final to const for constant values - use_key_in_widget_constructors (3): Added key parameters to widget constructors - sort_child_properties_last (1): Reordered children property to end Verification: - APK builds successfully (146 MB) - Reduced from 106 lint issues to 49 high-priority issues - Total file_names issues: 0 (down from 57) - All imports and exports updated correctly
145 lines
6 KiB
Dart
145 lines
6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'colors.dart';
|
|
import 'custom_bottom_app_bar.dart';
|
|
import 'custom_moment.dart';
|
|
import 'generated/i18n.dart';
|
|
import 'models/app_state.dart';
|
|
import 'models/false_positive_types.dart';
|
|
import 'models/fire_map_state.dart';
|
|
import 'models/fire_notification.dart';
|
|
import 'models/your_location.dart';
|
|
import 'utils/widget_utils.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: compactWidgets(<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) {
|
|
final S strings = S.of(context);
|
|
final ScaffoldMessengerState messenger =
|
|
ScaffoldMessenger.of(context);
|
|
if (value != null) {
|
|
onFalsePositive(notif, value);
|
|
}
|
|
Future<void>.delayed(
|
|
const Duration(milliseconds: 500))
|
|
.then((_) {
|
|
messenger.showSnackBar(SnackBar(
|
|
content: Text(strings.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;
|
|
}
|
|
}
|