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
123 lines
4 KiB
Dart
123 lines
4 KiB
Dart
import 'package:community_material_icon/community_material_icon.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import 'custom_stepper.dart';
|
|
import 'generated/i18n.dart';
|
|
import 'main_drawer.dart';
|
|
import 'models/your_location.dart';
|
|
import 'places_autocomplete_utils.dart';
|
|
|
|
class FireAlert extends StatefulWidget {
|
|
const FireAlert({super.key});
|
|
|
|
static const String routeName = '/fireAlert';
|
|
|
|
@override
|
|
_FireAlertState createState() => _FireAlertState();
|
|
}
|
|
|
|
class _FireAlertState extends State<FireAlert> {
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
int _currentStep = 0;
|
|
|
|
Widget buildCallButton() {
|
|
return Align(
|
|
alignment: const Alignment(0.0, -0.2),
|
|
child: FloatingActionButton(
|
|
heroTag: 'callAction',
|
|
child: const Icon(Icons.call),
|
|
onPressed: () async {
|
|
final Uri url = Uri(scheme: 'tel', path: '112');
|
|
if (await canLaunchUrl(url)) {
|
|
await launchUrl(url);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildNotifyNeighboursButton() {
|
|
return Align(
|
|
alignment: const Alignment(0.0, -0.2),
|
|
child: FloatingActionButton(
|
|
heroTag: 'neighAction',
|
|
child: const Icon(CommunityMaterialIcons.bullhorn),
|
|
onPressed: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
content: Text(S.of(context).inDevelopment),
|
|
));
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildTweetButton() {
|
|
final S strings = S.of(context);
|
|
return Align(
|
|
alignment: const Alignment(0.0, -0.2),
|
|
child: FloatingActionButton(
|
|
heroTag: 'tweetAction',
|
|
child: const Icon(CommunityMaterialIcons.twitter),
|
|
onPressed: () {
|
|
openPlacesDialog(_scaffoldKey).then((YourLocation yourLocation) {
|
|
final String where =
|
|
yourLocation.description.replaceAll(' ', '').split(',')[0];
|
|
Share.shareWithResult(
|
|
strings.tweetAboutSelf(yourLocation.description, '#IF$where'));
|
|
}).catchError((Object onError) {
|
|
if (mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(strings.errorFirePlaceDialog)));
|
|
}
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
List<CustomStep> listWithoutNulls(List<CustomStep> children) =>
|
|
children.whereType<CustomStep>().toList();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final List<CustomStep> fireSteps = listWithoutNulls(<CustomStep>[
|
|
CustomStep(
|
|
title: Text(S.of(context).callEmergencyServicesTitle),
|
|
content: Column(children: <Widget>[
|
|
Text(S.of(context).callEmergencyServicesDescription),
|
|
const SizedBox(height: 20.0),
|
|
buildCallButton()
|
|
])),
|
|
CustomStep(
|
|
title: Text(S.of(context).notifyNeighbours),
|
|
// state: CustomStepState.disabled,
|
|
content: Column(children: <Widget>[
|
|
Text(S.of(context).notifyNeighboursDescription),
|
|
const SizedBox(height: 20.0),
|
|
buildNotifyNeighboursButton()
|
|
])),
|
|
// TODOconditional: this only in Spain
|
|
CustomStep(
|
|
title: Text(S.of(context).tweetAboutAFireTitle),
|
|
// subtitle: new Text(S.of(context).tweetAboutAFireDescription),
|
|
content: Column(children: <Widget>[
|
|
Text(S.of(context).tweetAboutAFireDescription),
|
|
const SizedBox(height: 20.0),
|
|
buildTweetButton()
|
|
])),
|
|
]);
|
|
return Scaffold(
|
|
key: _scaffoldKey,
|
|
appBar: AppBar(title: Text(S.of(context).notifyAFire)),
|
|
drawer: MainDrawer(context, FireAlert.routeName),
|
|
body: CustomStepper(
|
|
currentCustomStep: _currentStep,
|
|
// type: StepperType.horizontal,
|
|
onCustomStepTapped: (int num) => setState(() {
|
|
_currentStep = num;
|
|
}),
|
|
steps: fireSteps));
|
|
}
|
|
}
|