-
-
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.
- Loading branch information
Showing
16 changed files
with
376 additions
and
152 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
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
82 changes: 82 additions & 0 deletions
82
lib/screens/view_alarm_screen_widgets/GeoLocationAlarmPreview.dart
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,82 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; | ||
import 'package:locus/constants/spacing.dart'; | ||
import 'package:locus/screens/locations_overview_screen_widgets/LocationFetchers.dart'; | ||
import 'package:locus/services/location_alarm_service/index.dart'; | ||
import 'package:locus/services/view_service.dart'; | ||
import 'package:locus/utils/map.dart'; | ||
import 'package:locus/widgets/LocusFlutterMap.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class GeoLocationAlarmPreview extends StatelessWidget { | ||
final TaskView view; | ||
final GeoLocationAlarm alarm; | ||
final VoidCallback onDelete; | ||
|
||
const GeoLocationAlarmPreview({ | ||
super.key, | ||
required this.view, | ||
required this.alarm, | ||
required this.onDelete, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final locationFetchers = context.watch<LocationFetchers>(); | ||
final lastLocation = | ||
locationFetchers.getLocations(view).lastOrNull?.asLatLng(); | ||
|
||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
PlatformListTile( | ||
title: Text(alarm.zoneName), | ||
leading: alarm.getIcon(context), | ||
trailing: PlatformIconButton( | ||
icon: Icon(context.platformIcons.delete), | ||
onPressed: onDelete, | ||
), | ||
), | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(LARGE_SPACE), | ||
child: SizedBox( | ||
width: double.infinity, | ||
height: 200, | ||
child: IgnorePointer( | ||
ignoring: true, | ||
child: LocusFlutterMap( | ||
options: MapOptions( | ||
center: alarm.center, | ||
maxZoom: 18, | ||
// create zoom based of radius | ||
zoom: getZoomLevelForRadius(alarm.radius), | ||
), | ||
children: [ | ||
CircleLayer( | ||
circles: [ | ||
if (lastLocation != null) | ||
CircleMarker( | ||
point: lastLocation, | ||
radius: 5, | ||
color: Colors.blue, | ||
), | ||
CircleMarker( | ||
point: alarm.center, | ||
useRadiusInMeter: true, | ||
color: Colors.red.withOpacity(0.3), | ||
borderStrokeWidth: 5, | ||
borderColor: Colors.red, | ||
radius: alarm.radius, | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
lib/screens/view_alarm_screen_widgets/ProximityAlarmMetaDataSheet.dart
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,64 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:locus/constants/spacing.dart'; | ||
import 'package:locus/services/location_alarm_service/ProximityLocationAlarm.dart'; | ||
import 'package:locus/utils/theme.dart'; | ||
|
||
import '../../widgets/ModalSheet.dart'; | ||
import '../../widgets/PlatformListTile.dart'; | ||
|
||
class ProximityAlarmMetaDataSheet extends StatelessWidget { | ||
final double radius; | ||
|
||
const ProximityAlarmMetaDataSheet({ | ||
required this.radius, | ||
super.key, | ||
}); | ||
|
||
void _createAlarm( | ||
final BuildContext context, | ||
final ProximityLocationAlarmType type, | ||
) { | ||
final alarm = ProximityLocationAlarm.create( | ||
radius: radius, | ||
type: type, | ||
); | ||
|
||
Navigator.pop( | ||
context, | ||
alarm, | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = AppLocalizations.of(context); | ||
|
||
return ModalSheet( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
Text( | ||
l10n.location_addAlarm_radiusBased_trigger_title, | ||
style: getSubTitleTextStyle(context), | ||
), | ||
const SizedBox(height: MEDIUM_SPACE), | ||
PlatformListTile( | ||
onTap: () { | ||
_createAlarm(context, ProximityLocationAlarmType.whenEnter); | ||
}, | ||
leading: const Icon(Icons.arrow_circle_right_rounded), | ||
title: Text(l10n.location_addAlarm_radiusBased_trigger_whenEnter), | ||
), | ||
PlatformListTile( | ||
onTap: () { | ||
_createAlarm(context, ProximityLocationAlarmType.whenLeave); | ||
}, | ||
leading: const Icon(Icons.arrow_circle_left_rounded), | ||
title: Text(l10n.location_addAlarm_radiusBased_trigger_whenLeave), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
lib/screens/view_alarm_screen_widgets/ProximityAlarmPreview.dart
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,108 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
import 'package:locus/constants/spacing.dart'; | ||
import 'package:locus/screens/locations_overview_screen_widgets/LocationFetchers.dart'; | ||
import 'package:locus/services/current_location_service.dart'; | ||
import 'package:locus/services/location_alarm_service/ProximityLocationAlarm.dart'; | ||
import 'package:locus/services/view_service.dart'; | ||
import 'package:locus/utils/location/get-fallback-location.dart'; | ||
import 'package:locus/utils/map.dart'; | ||
import 'package:locus/widgets/LocusFlutterMap.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class ProximityAlarmPreview extends StatelessWidget { | ||
final TaskView view; | ||
final ProximityLocationAlarm alarm; | ||
final VoidCallback onDelete; | ||
|
||
const ProximityAlarmPreview({ | ||
required this.view, | ||
required this.alarm, | ||
required this.onDelete, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = AppLocalizations.of(context); | ||
final locationFetchers = context.watch<LocationFetchers>(); | ||
final lastLocation = | ||
locationFetchers.getLocations(view).lastOrNull?.asLatLng(); | ||
final currentPosition = | ||
context.watch<CurrentLocationService>().currentPosition; | ||
|
||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
PlatformListTile( | ||
title: Text( | ||
alarm.radius > 10000 | ||
? l10n.location_addAlarm_radiusBased_radius_kilometers( | ||
double.parse( | ||
(alarm.radius / 1000).toStringAsFixed(1), | ||
), | ||
) | ||
: l10n.location_addAlarm_radiusBased_radius_meters( | ||
alarm.radius.round()), | ||
), | ||
leading: alarm.getIcon(context), | ||
trailing: PlatformIconButton( | ||
icon: Icon(context.platformIcons.delete), | ||
onPressed: onDelete, | ||
), | ||
), | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(LARGE_SPACE), | ||
child: SizedBox( | ||
width: double.infinity, | ||
height: 200, | ||
child: IgnorePointer( | ||
ignoring: true, | ||
child: LocusFlutterMap( | ||
options: MapOptions( | ||
center: currentPosition == null | ||
? getFallbackLocation(context) | ||
: LatLng( | ||
currentPosition.latitude, | ||
currentPosition.longitude, | ||
), | ||
maxZoom: 18, | ||
// create zoom based of radius | ||
zoom: getZoomLevelForRadius(alarm.radius), | ||
), | ||
children: [ | ||
CircleLayer( | ||
circles: [ | ||
if (lastLocation != null) | ||
CircleMarker( | ||
point: lastLocation, | ||
radius: 5, | ||
color: Colors.blue, | ||
), | ||
CircleMarker( | ||
point: currentPosition == null | ||
? getFallbackLocation(context) | ||
: LatLng( | ||
currentPosition.latitude, | ||
currentPosition.longitude, | ||
), | ||
useRadiusInMeter: true, | ||
color: Colors.red.withOpacity(0.3), | ||
borderStrokeWidth: 5, | ||
borderColor: Colors.red, | ||
radius: alarm.radius, | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.