Skip to content

Commit

Permalink
Now she can share host location to firebase in realtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jithin-Jude committed Apr 25, 2019
1 parent f868b16 commit 7186e3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions lib/Landing.dart
Expand Up @@ -78,8 +78,7 @@ class _LandingState extends State<Landing> {
init();
controller = new TextEditingController();

locationSubcription =
location.onLocationChanged().listen((Map<String, double> result) {
locationSubcription = location.onLocationChanged().listen((Map<String, double> result) {
setState(() {
currentLocation = result;
mapController.animateCamera(
Expand All @@ -98,6 +97,7 @@ class _LandingState extends State<Landing> {
),
);*/
});
updateHostLocation(currentLocation['latitude'], currentLocation['longitude']);
});

databaseReference.child("receiver").once().then((DataSnapshot snapshot) {
Expand Down Expand Up @@ -212,6 +212,7 @@ class _LandingState extends State<Landing> {
}

init() async {
user = await _auth.currentUser();
position = await Geolocator().getCurrentPosition();
setState(() {
currentlocation["latitude"] = position.latitude;
Expand Down Expand Up @@ -351,6 +352,23 @@ class _LandingState extends State<Landing> {
]));
}

void updateHostLocation(double latitude, double longitude) {
String userId = user.email;
userId = userId.replaceAll(".", "");

databaseReference.child("host").child(userId).set({
'host_name': user.displayName,
'host_email': user.email,
'mobile_no' : globals.mobileNo,
'model' : globals.model,
'capacity' : globals.capacity,
'host_location_latitude': latitude,
'host_location_longitude': longitude,
'reg_no': globals.regNo,
'car_colour': globals.carColour,
});
}

void registerHost() async {
user = await _auth.currentUser();
String userId = user.email;
Expand Down
2 changes: 1 addition & 1 deletion test/widget_test.dart
Expand Up @@ -13,7 +13,7 @@ import 'package:locatecab/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
await tester.pumpWidget(MaterialApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down

0 comments on commit 7186e3b

Please sign in to comment.