todos-contra-el-fuego-mobile/lib/models/app_state.dart
vjrj 12653b80a4 Fix 78 additional lint issues: rename all files to snake_case and fix 16 style issues
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
2026-03-12 09:00:06 +01:00

122 lines
4.8 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:latlong2/latlong.dart';
import 'package:meta/meta.dart';
import '../utils/widget_utils.dart';
import 'fire_map_state.dart';
import 'fire_notification.dart';
import 'user.dart';
import 'your_location.dart';
export 'fire_map_state.dart';
part 'app_state.g.dart';
@immutable
@JsonSerializable()
class AppState {
const AppState(
{this.yourLocations = const <YourLocation>[],
this.fireNotifications = const <FireNotification>[],
this.fireNotificationsUnread = 0,
this.user = const User.initial(),
this.isLoading = false,
this.isLoaded = false,
this.error = '',
this.gmapKey = '',
this.firesApiKey = '',
this.firesApiUrl = '',
this.serverUrl = '',
this.monitoredAreas = const <Polyline>[],
this.fireMapState = const FireMapState.initial()});
factory AppState.fromJson(Map<String, dynamic> json) =>
_$AppStateFromJson(json);
final bool isLoading;
@JsonKey(includeFromJson: false, includeToJson: false)
final bool isLoaded;
@JsonKey(includeFromJson: false, includeToJson: false)
final String error;
@JsonKey(includeFromJson: false, includeToJson: false)
final User user;
@JsonKey(includeFromJson: false, includeToJson: false)
final String gmapKey;
@JsonKey(includeFromJson: false, includeToJson: false)
final String serverUrl;
@JsonKey(includeFromJson: false, includeToJson: false)
final String firesApiKey;
@JsonKey(includeFromJson: false, includeToJson: false)
final String firesApiUrl;
final List<YourLocation> yourLocations;
final List<FireNotification> fireNotifications;
@JsonKey(includeFromJson: false, includeToJson: false)
final List<Polyline> monitoredAreas;
@JsonKey(includeFromJson: false, includeToJson: false)
final int fireNotificationsUnread;
@JsonKey(includeFromJson: false, includeToJson: false)
final FireMapState fireMapState;
AppState copyWith(
{bool? isLoading,
bool? isLoaded,
User? user,
String? error,
String? gmapKey,
String? firesApiKey,
String? serverUrl,
String? firesApiUrl,
List<YourLocation>? yourLocations,
List<FireNotification>? fireNotifications,
int? fireNotificationsUnread,
FireMapState? fireMapState,
List<Polyline>? monitoredAreas}) {
return AppState(
isLoading: isLoading ?? this.isLoading,
isLoaded: isLoaded ?? this.isLoaded,
user: user ?? this.user,
error: error ?? this.error,
gmapKey: gmapKey ?? this.gmapKey,
firesApiKey: firesApiKey ?? this.firesApiKey,
firesApiUrl: firesApiUrl ?? this.firesApiUrl,
serverUrl: serverUrl ?? this.serverUrl,
yourLocations: yourLocations ?? this.yourLocations,
fireNotifications: fireNotifications ?? this.fireNotifications,
fireNotificationsUnread:
fireNotificationsUnread ?? this.fireNotificationsUnread,
monitoredAreas: monitoredAreas ?? this.monitoredAreas,
fireMapState: fireMapState ?? this.fireMapState);
}
@override
String toString() {
return 'AppState{\nuser: $user\nisLoading: $isLoading\nisLoaded: $isLoaded\napiKey: ${ellipse(firesApiKey, 8)}\napiUrl: $firesApiUrl\nserverUrl: $serverUrl\nfireMapState: $fireMapState\nyourLocations count: ${yourLocations.length}\nunread notif: $fireNotificationsUnread\nfireNotifications: $fireNotifications\nyourLocations: $yourLocations}';
}
}
typedef AddYourLocationFunction = void Function(YourLocation loc);
typedef DeleteYourLocationFunction = void Function(YourLocation loc);
typedef OnRefreshYourLocationsFunction = void Function(
Completer<void> callback);
typedef ToggleSubscriptionFunction = void Function(YourLocation loc);
typedef OnLocationTapFunction = void Function(YourLocation loc);
typedef OnSubscribeFunction = void Function(YourLocation loc);
typedef OnSubscribeDistanceChangeFunction = void Function(YourLocation loc);
typedef OnUnSubscribeFunction = void Function(YourLocation loc);
typedef OnSubscribeConfirmedFunction = void Function(YourLocation loc);
typedef OnLocationEdit = void Function(YourLocation loc);
typedef OnLocationEditing = void Function(YourLocation loc);
typedef OnLocationEditConfirm = void Function(YourLocation loc);
typedef OnLocationEditCancel = void Function(YourLocation loc);
typedef TapFireNotificationFunction = void Function(FireNotification notif);
typedef OnFirePressedInMap = void Function(
LatLng latLng, DateTime when, String source);
// typedef void OnReceivedFireNotificationFunction(FireNotification notif);
typedef DeleteFireNotificationFunction = void Function(FireNotification notif);
typedef DeleteAllFireNotificationFunction = void Function();
// unused
// typedef void UpdateYourLocationFunction(ObjectId id, YourLocation loc);