-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add CheckViewAlarmsLive.dart
- Loading branch information
Showing
3 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:geolocator/geolocator.dart'; | ||
import 'package:locus/services/current_location_service.dart'; | ||
import 'package:locus/services/location_point_service.dart'; | ||
import 'package:locus/services/manager_service/helpers.dart'; | ||
import 'package:locus/services/view_service/index.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
/// Checks view alarms while the app is in use | ||
class CheckViewAlarmsLive extends StatefulWidget { | ||
const CheckViewAlarmsLive({super.key}); | ||
|
||
@override | ||
State<CheckViewAlarmsLive> createState() => _CheckViewAlarmsLiveState(); | ||
} | ||
|
||
class _CheckViewAlarmsLiveState extends State<CheckViewAlarmsLive> { | ||
late final CurrentLocationService _currentLocation; | ||
late final StreamSubscription<Position> _subscription; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
_subscription = _currentLocation.stream.listen((position) async { | ||
final l10n = AppLocalizations.of(context); | ||
final viewService = context.read<ViewService>(); | ||
final userLocation = await LocationPointService.fromPosition(position); | ||
|
||
if (!mounted) { | ||
return; | ||
} | ||
|
||
checkViewAlarms( | ||
l10n: l10n, | ||
viewService: viewService, | ||
userLocation: userLocation, | ||
); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_subscription.cancel(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters