-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Thuenen-Forest-Ecosystems/merge-supabase-…
…Version Merge supabase version
- Loading branch information
Showing
65 changed files
with
5,456 additions
and
721 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
2 changes: 1 addition & 1 deletion
2
android/app/src/main/kotlin/com/example/terrestrial_forest_monitor/MainActivity.kt
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
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,86 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:geolocator/geolocator.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
import 'package:terrestrial_forest_monitor/providers/gps-position.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:terrestrial_forest_monitor/services/utils.dart'; | ||
|
||
class NavigationCar extends StatefulWidget { | ||
Map target; | ||
LatLng position; | ||
NavigationCar({super.key, required this.target, required this.position}); | ||
|
||
@override | ||
State<NavigationCar> createState() => _NavigationCarState(); | ||
} | ||
|
||
class _NavigationCarState extends State<NavigationCar> { | ||
@override | ||
Widget build(BuildContext context) { | ||
double? distance; | ||
double? bearing; | ||
|
||
Position? lastPosition = context.watch<GpsPositionProvider>().lastPosition; | ||
|
||
if (lastPosition != null) { | ||
distance = Geolocator.distanceBetween( | ||
lastPosition.latitude, | ||
lastPosition.longitude, | ||
widget.position.latitude, | ||
widget.position.longitude, | ||
); | ||
bearing = Geolocator.bearingBetween( | ||
lastPosition.latitude, | ||
lastPosition.longitude, | ||
widget.position.latitude, | ||
widget.position.longitude, | ||
); | ||
if (bearing < 0) { | ||
bearing += 360; | ||
} | ||
} | ||
|
||
print(context.read<GpsPositionProvider>().listeningPosition); | ||
|
||
return Stack( | ||
children: [ | ||
Positioned( | ||
top: 5, | ||
left: 5, | ||
child: Text( | ||
'NAVIGATION CAR', | ||
style: TextStyle(fontSize: 11), | ||
), | ||
), | ||
Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
ClipOval( | ||
child: Material( | ||
color: Theme.of(context).primaryColor, // Button color | ||
child: InkWell( | ||
splashColor: Colors.red, // Splash color | ||
onTap: () { | ||
launchStringExternal('google.navigation:q=${widget.position.latitude},${widget.position.longitude}'); | ||
}, | ||
child: SizedBox( | ||
width: 56, | ||
height: 56, | ||
child: Icon( | ||
Icons.directions_car, | ||
color: Colors.black54, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
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,106 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:geolocator/geolocator.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
import 'package:terrestrial_forest_monitor/providers/gps-position.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:terrestrial_forest_monitor/services/utils.dart'; | ||
|
||
class Navigation extends StatefulWidget { | ||
Map target; | ||
LatLng position; | ||
Navigation({super.key, required this.target, required this.position}); | ||
|
||
@override | ||
State<Navigation> createState() => _NavigationState(); | ||
} | ||
|
||
class _NavigationState extends State<Navigation> { | ||
@override | ||
Widget build(BuildContext context) { | ||
double? distance; | ||
double? bearing; | ||
|
||
Position? lastPosition = context.watch<GpsPositionProvider>().lastPosition; | ||
|
||
if (lastPosition != null) { | ||
distance = Geolocator.distanceBetween( | ||
lastPosition.latitude, | ||
lastPosition.longitude, | ||
widget.position.latitude, | ||
widget.position.longitude, | ||
); | ||
bearing = Geolocator.bearingBetween( | ||
lastPosition.latitude, | ||
lastPosition.longitude, | ||
widget.position.latitude, | ||
widget.position.longitude, | ||
); | ||
if (bearing < 0) { | ||
bearing += 360; | ||
} | ||
} | ||
|
||
print(context.read<GpsPositionProvider>().listeningPosition); | ||
|
||
return Stack( | ||
children: [ | ||
Positioned( | ||
top: 5, | ||
left: 5, | ||
child: Text( | ||
'NAVIGATION', | ||
style: TextStyle(fontSize: 11), | ||
), | ||
), | ||
if (context.read<GpsPositionProvider>().listeningPosition) | ||
Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
Text('Richtungswinkel', style: TextStyle(fontSize: 15)), | ||
Text(bearing != null ? '${degreeToGon(bearing)}' : 'No GPS signal', style: TextStyle(fontSize: 20)), | ||
SizedBox( | ||
width: 20, | ||
child: Divider( | ||
height: 20, | ||
thickness: 1, | ||
), | ||
), | ||
Text('Entfernung', style: TextStyle(fontSize: 15)), | ||
Text(distance != null ? prettyDistance(distance) : 'No GPS signal', style: TextStyle(fontSize: 20)), | ||
], | ||
), | ||
), | ||
if (!context.read<GpsPositionProvider>().listeningPosition) | ||
Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
ClipOval( | ||
child: Material( | ||
color: Theme.of(context).primaryColor, // Button color | ||
child: InkWell( | ||
splashColor: Colors.red, // Splash color | ||
onTap: () { | ||
context.read<GpsPositionProvider>().navigateToTarget(widget.position, widget.target); | ||
}, | ||
child: SizedBox( | ||
width: 56, | ||
height: 56, | ||
child: Icon( | ||
Icons.navigation, | ||
color: Colors.black26, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.