From 8efbd814f685e814c89a084a54013a6abecd0412 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 29 Jun 2021 14:34:19 +0100 Subject: [PATCH 01/26] Added smaller marker icons for lower res screens --- lib/Components/flow_maps.dart | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/Components/flow_maps.dart b/lib/Components/flow_maps.dart index 34aa33f..32f9501 100755 --- a/lib/Components/flow_maps.dart +++ b/lib/Components/flow_maps.dart @@ -87,23 +87,19 @@ class _FlowMapsState extends State { ///Setting custom marker icons void setCustomMarker() async { Size screenSize = MediaQuery.of(context).size; - Size markerSize; + //Size markerSize; if (screenSize.width < 1000) { - markerSize = Size.square(35); + mapMarkerRed = await BitmapDescriptor.fromAssetImage( + ImageConfiguration(), 'Assets/images/marker-icon-red-small.png'); + mapMarkerGreen = await BitmapDescriptor.fromAssetImage( + ImageConfiguration(), 'Assets/images/marker-icon-green-small.png'); } else { - markerSize = Size.square(80); + mapMarkerRed = await BitmapDescriptor.fromAssetImage( + ImageConfiguration(), 'Assets/images/marker-icon-red.png'); + mapMarkerGreen = await BitmapDescriptor.fromAssetImage( + ImageConfiguration(), 'Assets/images/marker-icon-green.png'); } - mapMarkerRed = await BitmapDescriptor.fromAssetImage( - ImageConfiguration( - size: markerSize, - ), - 'Assets/images/marker-icon-red.png'); - mapMarkerGreen = await BitmapDescriptor.fromAssetImage( - ImageConfiguration( - size: markerSize, - ), - 'Assets/images/marker-icon-green.png'); // setState(() {}); } From 7ada6fd54d0da3269aa8bf3b2b33358ae8503d0f Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 29 Jun 2021 14:35:42 +0100 Subject: [PATCH 02/26] Made little UI changes --- lib/Screens/FlowAskPermissionsScreen.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Screens/FlowAskPermissionsScreen.dart b/lib/Screens/FlowAskPermissionsScreen.dart index 010f25b..e80839c 100644 --- a/lib/Screens/FlowAskPermissionsScreen.dart +++ b/lib/Screens/FlowAskPermissionsScreen.dart @@ -45,9 +45,14 @@ class _FlowAskPermissionsState extends State { SizedBox(height: 20), Padding( padding: EdgeInsets.symmetric(horizontal: screenWidth * .1), - child: HeadlineTextBold( - title: 'Allow Flow to access your location?', - color: Colors.white), + child: Text( + 'Allow Flow to access your location?', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), SizedBox( height: 10, From 23a64eead6fb34db5468472ea7d58e569ce0f6ae Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 29 Jun 2021 14:36:04 +0100 Subject: [PATCH 03/26] imported smaller marker icons --- Assets/images/marker-icon-green-small.png | Bin 0 -> 760 bytes Assets/images/marker-icon-red-small.png | Bin 0 -> 746 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Assets/images/marker-icon-green-small.png create mode 100644 Assets/images/marker-icon-red-small.png diff --git a/Assets/images/marker-icon-green-small.png b/Assets/images/marker-icon-green-small.png new file mode 100644 index 0000000000000000000000000000000000000000..9ca74467da03b52dc61d5a7696e32ad98db3708d GIT binary patch literal 760 zcmV6@rzJMr)&mR+Y)nz%Ddc?37?YHQ zD=J|>W5bFHM~VIcoCX^?;+297C+OC)ibrMDH*sh(tOK|tEQ;R#+!d9VkDe2C4($Nw z@gx&+LAH5DE(iKsCsa z0o4rtIQWG}UtZzK*G*v?rQ0VvxO3{N4|az^lTnZa*b$#|mqvrf_50gcZ^+wJ*GMj9Y>aTS0h@~f>1%#mf&W>U=}O_FQx?@!&uKG7I`dEuTmnX+u! zOy1P8NVB*~K=2r)IEogSE9>rFu?=N$l4WKRQ5=e=sF#NnGkRmVB|oW9j(8ml*%c-r z-AU?{Ctf$;El|j})m0%+ymp|Ss2$5f<#NOgi#tvu74TZrc*udMZJ1`JyOUz2=NMI~ z9C6caQJjRqC+a%oiMJiNF79;XuT!3Qu^p3QlU_b?QM9g7D>`J#Wg*v#*3*Yu>7Aqw zQ5@x{mT_6gXMBG9OLS?X^InxA{}e~j9&=@oG{gJFcJ%A$(p06$zaxu%yYkH39fvB` zL~|f@L=I~L1aoBTcN6d38}{1ZgPe&M42<&@M6h(^|6gxGdC*3@s)@J2CcaOK3P)-5 qOK&l&jeavP!q)olL-YT~0q_U4Y<9lbrKsNk0000RIZiDp5JW$YNl z%5W@93>}zQ=)j8T$VkSD<%(36473spL!}Cd5pi95K{Pe8`+Pd`Y$uoI4(F3R3~_UtVkuPEsqxo9Kq@W`xjpV}T)m>sB((s_IDD&?b7{yAw14|Y>d@2* zS_t8 z&)t1}Y;Zv?#0>_fxeHQfpuNF=y9+9UdU319?gD+hpJWD0@%pBByjQ)xGarYo_3MNG c-*Eu^1tg_rX4N80tpET307*qoM6N<$g5e=ktN;K2 literal 0 HcmV?d00001 From 458a155aba44d431d97b7190067ed8dab8410723 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:04:09 +0100 Subject: [PATCH 04/26] Created a custom page route for Hero Popup --- lib/Components/custom_dialog_route.dart | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/Components/custom_dialog_route.dart diff --git a/lib/Components/custom_dialog_route.dart b/lib/Components/custom_dialog_route.dart new file mode 100644 index 0000000..e04801a --- /dev/null +++ b/lib/Components/custom_dialog_route.dart @@ -0,0 +1,40 @@ + +import 'package:flutter/material.dart'; + +///{@template custom hero_dialod_route} +///Custom [PageRoute] that creates an overlay dialog popup effect +/// +///Best used with a [Hero] animation + +class CustomHeroDialogRoute extends PageRoute { + +CustomHeroDialogRoute({ + @required WidgetBuilder builder, + RouteSettings settings, + bool fullscreenDialog = false, +}) : _builder = builder, super(settings: settings, fullscreenDialog: fullscreenDialog); + +final WidgetBuilder _builder; + +@override +bool get opaque => false; +@override +bool get barrierDismissible => true; +@override +Duration get transitionDuration => const Duration(milliseconds:300); +@override +bool get maintainState=> true; + +@override +Color get barrierColor => Colors.black54; +@override +Widget buildTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child){ return child;} + +@override +Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation){ + return _builder(context); +} +@override +String get barrierLabel => 'Popup dialog open'; + +} \ No newline at end of file From a9b6ae0495fbe883fde2c456de582c49983528e1 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:06:55 +0100 Subject: [PATCH 05/26] Added new icons --- Assets/icons/svgs/fi-rr-home-alt.svg | 1 + Assets/icons/svgs/fi-sr-home-alt-filled.svg | 1 + Assets/icons/svgs/fi-sr-search-filled.svg | 1 + Assets/icons/svgs/fi-sr-user-filled.svg | 1 + Assets/icons/svgs/fi-sr-user.svg | 1 + 5 files changed, 5 insertions(+) create mode 100644 Assets/icons/svgs/fi-rr-home-alt.svg create mode 100644 Assets/icons/svgs/fi-sr-home-alt-filled.svg create mode 100644 Assets/icons/svgs/fi-sr-search-filled.svg create mode 100644 Assets/icons/svgs/fi-sr-user-filled.svg create mode 100644 Assets/icons/svgs/fi-sr-user.svg diff --git a/Assets/icons/svgs/fi-rr-home-alt.svg b/Assets/icons/svgs/fi-rr-home-alt.svg new file mode 100644 index 0000000..602ecec --- /dev/null +++ b/Assets/icons/svgs/fi-rr-home-alt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Assets/icons/svgs/fi-sr-home-alt-filled.svg b/Assets/icons/svgs/fi-sr-home-alt-filled.svg new file mode 100644 index 0000000..2b1df86 --- /dev/null +++ b/Assets/icons/svgs/fi-sr-home-alt-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Assets/icons/svgs/fi-sr-search-filled.svg b/Assets/icons/svgs/fi-sr-search-filled.svg new file mode 100644 index 0000000..544ef3c --- /dev/null +++ b/Assets/icons/svgs/fi-sr-search-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Assets/icons/svgs/fi-sr-user-filled.svg b/Assets/icons/svgs/fi-sr-user-filled.svg new file mode 100644 index 0000000..b3d800c --- /dev/null +++ b/Assets/icons/svgs/fi-sr-user-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Assets/icons/svgs/fi-sr-user.svg b/Assets/icons/svgs/fi-sr-user.svg new file mode 100644 index 0000000..a0b48b9 --- /dev/null +++ b/Assets/icons/svgs/fi-sr-user.svg @@ -0,0 +1 @@ +94 user \ No newline at end of file From 60158eb05633e01bf766e584f70d634b26acbc27 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:07:57 +0100 Subject: [PATCH 06/26] Added the search button, for searching the closest source --- lib/Components/flow_maps.dart | 120 ++++++++++------------------------ 1 file changed, 34 insertions(+), 86 deletions(-) diff --git a/lib/Components/flow_maps.dart b/lib/Components/flow_maps.dart index 32f9501..69a43c5 100755 --- a/lib/Components/flow_maps.dart +++ b/lib/Components/flow_maps.dart @@ -1,6 +1,4 @@ import 'package:flow/Components/Permissions.dart'; -import 'package:flow/Components/directions/distance_calculator.dart'; -import 'package:flow/Components/directions/prompt_closest_source.dart'; import 'package:flow/constants.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -15,7 +13,7 @@ import 'directions/directions_model.dart'; import 'bottom_sheet_info.dart'; import 'flow_location.dart'; import 'flow_snackbar.dart'; -import 'dart:math'; +import 'search_closest_source_button.dart'; // ignore: must_be_immutable class FlowMaps extends StatefulWidget { @@ -50,7 +48,6 @@ class _FlowMapsState extends State { BitmapDescriptor mapMarker; Directions directionInfo; Directions dirInfoFromSheet; - Directions dirInfoFromClosestSource; LatLng currentLocation; LatLng markerLocation; @@ -62,7 +59,7 @@ class _FlowMapsState extends State { String closestSourceDistance; String closestSourceID; String closestSourceDescription; - List sourceDistancesList; + final List sourceDistancesList = []; GeoPoint firebaseLocation; LatLng markerLocForCalc; @@ -77,7 +74,6 @@ class _FlowMapsState extends State { @override initState() { - // TODO: implement initState super.initState(); setCustomMarker(); //getCurrentLocation(); @@ -86,21 +82,10 @@ class _FlowMapsState extends State { ///Setting custom marker icons void setCustomMarker() async { - Size screenSize = MediaQuery.of(context).size; - //Size markerSize; - if (screenSize.width < 1000) { - mapMarkerRed = await BitmapDescriptor.fromAssetImage( - ImageConfiguration(), 'Assets/images/marker-icon-red-small.png'); - mapMarkerGreen = await BitmapDescriptor.fromAssetImage( - ImageConfiguration(), 'Assets/images/marker-icon-green-small.png'); - } else { - mapMarkerRed = await BitmapDescriptor.fromAssetImage( - ImageConfiguration(), 'Assets/images/marker-icon-red.png'); - mapMarkerGreen = await BitmapDescriptor.fromAssetImage( - ImageConfiguration(), 'Assets/images/marker-icon-green.png'); - } - - // setState(() {}); + mapMarkerGreen = await BitmapDescriptor.fromAssetImage( + ImageConfiguration(), 'Assets/images/marker-icon-green.png'); + mapMarkerRed = await BitmapDescriptor.fromAssetImage( + ImageConfiguration(), 'Assets/images/marker-icon-red.png'); } _onCameraMove(CameraPosition position) { @@ -164,6 +149,7 @@ class _FlowMapsState extends State { 'Assets/icons/svgs/fi-rr-map-change.svg', ), // toggle map type button SizedBox(height: 10.0), + SearchClosestSourceButton(), /* button( _onAddMarkerButtonPressed, @@ -191,7 +177,7 @@ class _FlowMapsState extends State { switch (snapshot.connectionState) { case ConnectionState.waiting: return Center( - child: CircularProgressIndicator( + child: CircularProgressIndicator.adaptive( backgroundColor: Colors.transparent, ), ); @@ -234,7 +220,7 @@ class _FlowMapsState extends State { ['isTypeTap'], bottomSheetIsFlowing: snapshot.data.docs[i] ['isFlowing'], - tapLocation: snapshot.data.docs[i]['location'], + tapLocation: markerLocation, // distance: directionInfo.totalDistance, ); }); @@ -251,33 +237,17 @@ class _FlowMapsState extends State { }, //load bottom sheet ), ); + + // ///Calculating distances and adding to the List; + // sourceDistancesList + // .add(distanceCalculator(currentLocation, markerLocation)); } // end of loop + // calculateClosestSource(currentLocation, markerLocation); - // currentLocation = getCurrentLocation(); - // - // /// Calculating the distance to all sources and finding the closest - // Future.delayed(Duration(seconds: 5), () { - // for (int i = 0; i < snapshot.data.docs.length; i++) { - // LatLng markerLoc = LatLng( - // snapshot.data.docs[i]['location'].latitude, - // snapshot.data.docs[i]['location'].longitude, - // ); - // sourceDistancesList = [ - // calculateClosestSource(currentLocation, markerLoc), - // ]; - // } //end for loop - // - // print('distancelist = $sourceDistancesList'); - // - // ///Finding shortest distance and its index - // shortestDistance = sourceDistancesList.reduce(min); - // var index = sourceDistancesList - // .indexOf(sourceDistancesList.reduce(min)); - // print(shortestDistance); - // print('shortest distance index is $index'); - // - // // popUpClosestSource(); - // }); + ///Getting the shortest distance in the List of Distances + // shortestDistance = sourceDistancesList.reduce(min); + // print('list of distances is $sourceDistancesList'); + // print('shortest distance within the list is $shortestDistance'); return GoogleMap( initialCameraPosition: CameraPosition( @@ -312,43 +282,21 @@ class _FlowMapsState extends State { }); } - ///method to find and show the closest water source - calculateClosestSource( - LatLng currentLocation, - LatLng markerLocation, - ) async { - // final double sourceDistance = - // distanceCalculator(currentLocation, markerLocation); - - return distanceCalculator(currentLocation, markerLocation); - // ///sorting for the shortest distance - // if (shortestDistance !=null && - // documentSnapshot[i]['ifIsFlowing'] == true) { - // closestSourceDistance = shortestDistance.toStringAsFixed(2); - // closestSourceID = documentSnapshot[i]['ID']; - // closestSourceDescription = documentSnapshot[i]['description']; - // firebaseLocation = documentSnapshot[i]['location']; - // markerLocForCalc = - // LatLng(firebaseLocation.latitude, firebaseLocation.longitude); - // return shortestDistance; - // } - } - ///Show Closest Source Popup - Future popUpClosestSource() async { - dirInfoFromClosestSource = await showDialog( - context: context, - builder: (BuildContext context) { - return ShowClosestSource( - id: closestSourceID, - description: closestSourceDescription, - distance: '$closestSourceDistance Km', - ); - }); - setState(() { - directionInfo = dirInfoFromClosestSource; - }); - - return directionInfo; - } + // Future popUpClosestSource() async { + // Directions dirInfoFromClosestSource = await showDialog( + // context: context, + // builder: (BuildContext context) { + // return ShowClosestSource( + // id: closestSourceID, + // description: closestSourceDescription, + // distance: '$closestSourceDistance Km', + // ); + // }); + // setState(() { + // directionInfo = dirInfoFromClosestSource; + // }); + + // return directionInfo; + // } } From 54f0bd061d7723d1c142afc1a96dc112fe7c5ecc Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:09:18 +0100 Subject: [PATCH 07/26] Added show_closest_source_dialog.dart for calculating and displaying the closest source --- .../directions/prompt_closest_source.dart | 147 ---------- .../show_closest_source_dialog.dart | 271 ++++++++++++++++++ 2 files changed, 271 insertions(+), 147 deletions(-) delete mode 100644 lib/Components/directions/prompt_closest_source.dart create mode 100644 lib/Components/directions/show_closest_source_dialog.dart diff --git a/lib/Components/directions/prompt_closest_source.dart b/lib/Components/directions/prompt_closest_source.dart deleted file mode 100644 index 701d6c3..0000000 --- a/lib/Components/directions/prompt_closest_source.dart +++ /dev/null @@ -1,147 +0,0 @@ -import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:flow/Components/flow_location.dart'; -import 'package:flow/constants.dart'; -import 'package:flutter/material.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:location/location.dart'; - -final Stream flowFirestoreStream = - FirebaseFirestore.instance.collection('flow_water_sources').snapshots(); -LatLng markerLocation; -LatLng currentLocation; -double shortestDistance; -String closestSourceID; -String closestSourceDescription; -List sourceDistancesList; - -getLoc() async { - LocationData currentLoc = await getLocation(); - - currentLocation = LatLng(currentLoc.latitude, currentLoc.longitude); - return currentLocation; -} - -class ShowClosestSource extends StatelessWidget { - final String id; - final String description; - final String distance; - - const ShowClosestSource({Key key, this.id, this.description, this.distance}) - : super(key: key); - - @override - Widget build(BuildContext context) { - return Dialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), - backgroundColor: Colors.white, - child: closestSourceDialogContent(), - ); - } -} - -Widget closestSourceDialogContent() { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: primarycolor, - ), - height: 300, - width: 300, - child: Column( - children: [ - Text('$closestSourceID} is closest to you, and marked as flowing'), - Text('$shortestDistance Km'), - ], - ), - ); -} - -// class ShowClosestSource extends StatefulWidget { -// @override -// _ShowClosestSourceState createState() => _ShowClosestSourceState(); -// } -// -// class _ShowClosestSourceState extends State { -// final Stream flowFirestoreStream = -// FirebaseFirestore.instance.collection('flow_water_sources').snapshots(); -// LatLng markerLocation; -// LatLng currentLocation; -// double shortestDistance; -// String closestSourceID; -// String closestSourceDescription; -// List sourceDistancesList; -// -// @override -// void initState() { -// super.initState(); -// getLoc(); -// -// //distanceCalculator(currentLocation, markerLocation); -// // ifTapIsSaved(); -// } -// -// getLoc() async { -// LocationData currentLoc = await getLocation(); -// setState(() { -// currentLocation = LatLng(currentLoc.latitude, currentLoc.longitude); -// }); -// -// return currentLocation; -// } -// -// @override -// Widget build(BuildContext context) { -// return StreamBuilder( -// stream: flowFirestoreStream, -// builder: (BuildContext context, AsyncSnapshot snapshot) { -// // calculatedDistances = [ -// // distanceCalculator(currentLocation, markerLocation) -// // ]; -// for (int i = 0; i < snapshot.data.docs.length; i++) { -// markerLocation = LatLng(snapshot.data.docs[i]['location'].latitude, -// snapshot.data.docs[i]['location'].longitude); -// -// sourceDistancesList = [ -// getClosestSource( -// i, currentLocation, markerLocation, snapshot.data.docs[i]['ID']) -// ]; -// -// ///sorting for the shortest distance -// -// if (shortestDistance > sourceDistancesList[i]) { -// shortestDistance = sourceDistancesList[i]; -// closestSourceID = snapshot.data.docs[i]['ID']; -// } -// -// showDialog( -// context: context, -// builder: (BuildContext context) { -// return Container( -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(15), -// color: primarycolor, -// ), -// height: 300, -// width: 300, -// child: Column( -// children: [ -// Text( -// '$closestSourceID} is closest to you, and marked as flowing'), -// Text('$shortestDistance Km'), -// ], -// ), -// ); -// }); -// } -// -// // ///sorting for the shortest distance -// // for (int i = 0; i < sourceDistancesList.length; i++) { -// // if (shortestDistance > sourceDistancesList[i]) { -// // shortestDistance = sourceDistancesList[i]; -// // } -// // } -// return; -// }, -// ); -// } -// } diff --git a/lib/Components/directions/show_closest_source_dialog.dart b/lib/Components/directions/show_closest_source_dialog.dart new file mode 100644 index 0000000..e504e6d --- /dev/null +++ b/lib/Components/directions/show_closest_source_dialog.dart @@ -0,0 +1,271 @@ +import 'dart:math'; + +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flow/Components/flow_location.dart'; +import 'package:flow/constants.dart'; +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:location/location.dart'; + +import '../flow_maps.dart'; +import 'directions_model.dart'; +import 'distance_calculator.dart'; + +class ShowClosestSourceDialog extends StatefulWidget { + @override + _ShowClosestSourceDialogState createState() => + _ShowClosestSourceDialogState(); +} + +class _ShowClosestSourceDialogState extends State { + final Stream flowFirestoreStream = + FirebaseFirestore.instance.collection('flow_water_sources').snapshots(); + + LatLng markerLocation; + + LatLng currentLocation; + + double shortestDistance; + + String closestSourceID; + + GeoPoint closestSourceGeopoint; + + LatLng closestSourceLocation; + + String closestSourceDescription; + + List sourceDistancesList = []; + + List sourceIDsList = []; + + List sourceLocationList = []; + + Directions directionInfo; + + getLoc() async { + LocationData currentLoc = await getLocation(); + currentLocation = LatLng(currentLoc.latitude, currentLoc.longitude); + return currentLocation; + } + + @override + initState() { + super.initState(); + getLoc(); + } + + Widget build(BuildContext context) { + ///Calculating distances and adding to the List; + return StreamBuilder( + stream: flowFirestoreStream, + builder: (BuildContext context, AsyncSnapshot snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return CustomAlertHeroDialog( + child: Column( + children: [ + Text( + 'Calculating closest source', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 18), + ), + CircularProgressIndicator.adaptive(), + ], + ), + ); + case ConnectionState.none: + return CustomAlertHeroDialog( + child: HeadlineTextBold( + title: 'You are offline', + ), + ); + default: + Future.delayed(Duration(seconds: 3), () { + for (int i = 0; i < snapshot.data.docs.length; i++) { + markerLocation = LatLng( + snapshot.data.docs[i]['location'].latitude, + snapshot.data.docs[i]['location'].longitude); + // sourceDistancesList = []; + // sourceIDsList = []; + // sourceLocationList = []; + // sourceDistancesList = []; + if (snapshot.data.docs[i]['isFlowing'] == true) { + // sourceIDsList = []; + sourceIDsList.add(snapshot.data.docs[i]['ID']); + //sourceLocationList = []; + sourceLocationList.add(snapshot.data.docs[i]['location']); + //sourceDistancesList = []; + sourceDistancesList.add( + distanceCalculator(currentLocation, markerLocation), + ); + } + } + + ///Getting the shortest distance in the Lists of Distances + setState(() { + shortestDistance = sourceDistancesList.reduce(min); + int indexOfClosestSource = + sourceDistancesList.indexOf(shortestDistance); + closestSourceID = sourceIDsList[indexOfClosestSource]; + closestSourceGeopoint = + sourceLocationList[indexOfClosestSource]; + closestSourceLocation = LatLng( + closestSourceGeopoint.latitude, + closestSourceGeopoint.longitude, + ); + }); + print('does current location change lets see:$currentLocation'); + print('list of distances is $sourceDistancesList'); + print('shortest distance within the list is $shortestDistance'); + print('shortest source ID within the list is $closestSourceID'); + }); + + if (shortestDistance == null) { + return CustomAlertHeroDialog( + child: Column( + children: [ + Text( + 'Calculating closest source', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 18), + ), + SizedBox(height: 10), + CircularProgressIndicator.adaptive(), + ], + ), + ); + } else { + return CustomAlertHeroDialog( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '${closestSourceID ?? 'Calculating'}', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + color: primarycolor), + ), + SizedBox(height: 10), + Text( + 'is closest to you, and marked as flowing', + textAlign: TextAlign.center, + ), + SizedBox(height: 10), + HeadlineTextBold( + title: '${shortestDistance.toStringAsFixed(2)} Km', + color: primarycolor, + ), + SizedBox(height: 30), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () async { + Feedback.forTap(context); + Navigator.of(context).pop( + FlowMaps().directionInfo = await FlowMaps() + .getDirections(currentLocation, + closestSourceLocation), + ); + setState(() {}); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: primarycolor, + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 25, vertical: 11.0), + child: BodyTextBold( + title: 'Lets go!', + color: Colors.white, + ), + ), + ), + ), + SizedBox(width: 20), + GestureDetector( + onTap: () async { + Feedback.forTap(context); + // directionInfo = await FlowMaps().getDirections( + // currentLocation, closestSourceLocation); + // Navigator.of(context).pop(directionInfo); + + sourceDistancesList = []; + sourceIDsList = []; + sourceLocationList = []; + sourceDistancesList = []; + Navigator.pop(context); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: Colors.white, + border: Border.all( + color: primarycolor, + )), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 10.0), + child: BodyText( + title: 'No thanks', + color: primarycolor, + ), + ), + ), + ), + ], + ), + ) + ], + ), + ); + } + } + }); + } +} + +class CustomAlertHeroDialog extends StatelessWidget { + final Widget child; + final String _heroShowClosestSourceTag = 'hero_show_closest_source_tag'; + + const CustomAlertHeroDialog({Key key, @required this.child}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Center( + child: Hero( + tag: _heroShowClosestSourceTag, + child: Material( + elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25), + ), + color: Colors.white, + child: Stack( + alignment: Alignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * 0.3, + width: MediaQuery.of(context).size.width * .8, + ), + Padding( + padding: const EdgeInsets.all(20.0), + child: SingleChildScrollView( + child: child, + ), + ), + ], + ), + ), + ), + ); + } +} From dfd69c922b3b6235f8cac3cdc5d3fae4620253c3 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:10:10 +0100 Subject: [PATCH 08/26] Changed some VSCode preferences --- .vscode/settings.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0b2a80b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "dart.previewFlutterUiGuides": true, + "dart.previewFlutterUiGuidesCustomTracking": true +} \ No newline at end of file From 36e48e5ddce381358600d8c075ac0b795de77248 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:10:47 +0100 Subject: [PATCH 09/26] Created a second list item widget for the Find screen --- lib/Components/sources_list_item.dart | 82 ++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 14 deletions(-) diff --git a/lib/Components/sources_list_item.dart b/lib/Components/sources_list_item.dart index 8a3a9ac..4e41824 100644 --- a/lib/Components/sources_list_item.dart +++ b/lib/Components/sources_list_item.dart @@ -3,14 +3,14 @@ import 'package:flow/constants.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/flutter_svg.dart'; -class WaterSourcesListItem extends StatelessWidget { +class WaterSourcesListItemSavedScreen extends StatelessWidget { final String id; final String distance; final String isflowingiconlink; final Widget iconButtonWidget; final Widget moreInfoIcon; - const WaterSourcesListItem({ + const WaterSourcesListItemSavedScreen({ Key key, this.id, this.distance, @@ -23,7 +23,7 @@ class WaterSourcesListItem extends StatelessWidget { return Container( height: 50, margin: EdgeInsets.fromLTRB(15, 0, 15, 8), - padding: EdgeInsets.all(10), + padding: EdgeInsets.fromLTRB(0, 10, 0, 10), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), @@ -48,17 +48,9 @@ class WaterSourcesListItem extends StatelessWidget { ], ), Spacer(), - Row( - children: [ - BodyTextBold( - title: distance, - color: primarycolor, - ), - BodyText( - title: ' approx.', - color: textcolor, - ), - ], + BodyTextBold( + title: distance, + color: primarycolor, ), Spacer(), SvgPicture.asset( @@ -73,3 +65,65 @@ class WaterSourcesListItem extends StatelessWidget { ); } } + +class WaterSourcesListItemFindScreen extends StatelessWidget { + final String id; + final String description; + final String isflowingiconlink; + final Widget iconButtonWidget; + final Widget moreInfoIcon; + final Color flowIconColor; + + const WaterSourcesListItemFindScreen({ + Key key, + this.id, + this.description, + this.isflowingiconlink, + this.iconButtonWidget, + this.moreInfoIcon, + this.flowIconColor, + }) : super(key: key); + + Widget build(BuildContext context) { + return Container( + height: 50, + margin: EdgeInsets.fromLTRB(15, 0, 15, 8), + padding: EdgeInsets.fromLTRB(10, 10, 0, 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + /*border: Border.all(color: primarycolor.withOpacity(.5), width: 1),*/ + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + children: [ + BodyText( + title: 'ID: ', + color: textcolor, + ), + BodyTextBold( + title: id, + color: primarycolor, + ), + ], + ), + SizedBox(width: 10), + BodyText( + title: description, + color: textcolor, + ), + Spacer(), + SvgPicture.asset( + isflowingiconlink, + color: flowIconColor, + ), + moreInfoIcon, + iconButtonWidget, + ], + ), + ); + } +} From 796f6bdf4e8a75de61f58f56f5070e51edf174be Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:11:24 +0100 Subject: [PATCH 10/26] Trying to fix issues with bottom sheet popup --- lib/Screens/FlowSavedScreen.dart | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/Screens/FlowSavedScreen.dart b/lib/Screens/FlowSavedScreen.dart index cf1ed22..5c31357 100644 --- a/lib/Screens/FlowSavedScreen.dart +++ b/lib/Screens/FlowSavedScreen.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flow/Components/bottom_sheet_info.dart'; import 'package:flow/Components/flow_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; @@ -8,6 +9,7 @@ import 'package:flow/Components/flow_app_bar.dart'; import 'package:flow/Components/sources_list_item.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; class FlowSavedScreen extends StatefulWidget { @@ -49,12 +51,16 @@ class _FlowSavedScreenState extends State { } else { typeTap = false; } - return WaterSourcesListItem( + print( + 'tap location from SP is ${flowList[index].savedTapLocationLatitude}'); + print('tap id from SP is ${flowList[index].savedID}'); + + return WaterSourcesListItemSavedScreen( id: flowList[index].savedID, distance: flowList[index].savedDistance.toString(), isflowingiconlink: ifIsFlowingIconLink, moreInfoIcon: IconButton( - padding: EdgeInsets.zero, + padding: EdgeInsets.all(0), enableFeedback: true, icon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-angle-small-down.svg', @@ -70,7 +76,10 @@ class _FlowSavedScreenState extends State { bottomSheetDescription: flowList[index].savedDescription, bottomSheetIsTypeTap: typeTap, bottomSheetIsFlowing: flowList[index].savedFlowing, - tapLocation: flowList[index].savedTapLocation, + tapLocation: LatLng( + flowList[index].savedTapLocationLatitude, + flowList[index].savedTapLocationLongitude, + ), ); }); }); @@ -90,7 +99,10 @@ class _FlowSavedScreenState extends State { savedDistance: flowList[index].savedDistance, savedFlowing: flowList[index].savedFlowing, savedTypeTap: flowList[index].savedTypeTap, - savedTapLocation: flowList[index].savedTapLocation, + savedTapLocationLatitude: + flowList[index].savedTapLocationLatitude, + savedTapLocationLongitude: + flowList[index].savedTapLocationLongitude, ), flowList[index].savedID, ); From ba6ffdf911ed2f36f3898c2c7880a40b632d5549 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:18:18 +0100 Subject: [PATCH 11/26] Small UI changes --- lib/Components/flow_bottom_nav_bar.dart | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/Components/flow_bottom_nav_bar.dart b/lib/Components/flow_bottom_nav_bar.dart index ba15a63..a5bb749 100755 --- a/lib/Components/flow_bottom_nav_bar.dart +++ b/lib/Components/flow_bottom_nav_bar.dart @@ -4,7 +4,6 @@ import 'package:flow/Screens/FlowSavedScreen.dart'; import 'package:flow/Screens/FlowAboutScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flow/constants.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -34,16 +33,16 @@ class _FlowBottomNavBarState extends State { bottomNavigationBar: BottomNavigationBar( backgroundColor: Colors.white, type: BottomNavigationBarType.fixed, - elevation: 10, - selectedItemColor: primarycolor, - unselectedItemColor: textcolor.withOpacity(.7), + elevation: 0, + selectedItemColor: Colors.black, + unselectedItemColor: Colors.black.withOpacity(.3), currentIndex: currentMenuIndex, onTap: (value) { currentMenuIndex = value; setState(() {}); }, - showUnselectedLabels: true, - showSelectedLabels: true, + showUnselectedLabels: false, + showSelectedLabels: false, selectedFontSize: 12, unselectedFontSize: 12, items: [ @@ -51,44 +50,44 @@ class _FlowBottomNavBarState extends State { label: ('Home'), icon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-home.svg', - color: textcolor.withOpacity(.9), + color: Colors.black.withOpacity(.3), ), activeIcon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-home.svg', - color: primarycolor, + color: Colors.black, ), ), BottomNavigationBarItem( label: 'Find', icon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-search.svg', - color: textcolor.withOpacity(.9), + color: Colors.black.withOpacity(.3), ), activeIcon: SvgPicture.asset( - 'Assets/icons/svgs/fi-rr-search.svg', - color: primarycolor, + 'Assets/icons/svgs/fi-sr-search.svg', + color: Colors.black, ), ), BottomNavigationBarItem( label: 'Saved', icon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-heart.svg', - color: textcolor.withOpacity(.9), + color: Colors.black.withOpacity(.3), ), activeIcon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-heart.svg', - color: primarycolor, + color: Colors.black, ), ), BottomNavigationBarItem( label: 'About', icon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-user.svg', - color: textcolor.withOpacity(.9), + color: Colors.black.withOpacity(.3), ), activeIcon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-user.svg', - color: primarycolor, + color: Colors.black, ), ), ], From 78a428574eb0b375b0ed6b93b4bb08afcc174f15 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:19:39 +0100 Subject: [PATCH 12/26] Removed unused import --- lib/Components/directions/.env.dart | 1 + .../search_closest_source_button.dart | 46 ++++++++++++ lib/Screens/AskingPermissions.dart | 72 ------------------- 3 files changed, 47 insertions(+), 72 deletions(-) create mode 100644 lib/Components/directions/.env.dart create mode 100644 lib/Components/search_closest_source_button.dart delete mode 100644 lib/Screens/AskingPermissions.dart diff --git a/lib/Components/directions/.env.dart b/lib/Components/directions/.env.dart new file mode 100644 index 0000000..e479422 --- /dev/null +++ b/lib/Components/directions/.env.dart @@ -0,0 +1 @@ +const String googleAPIKey = 'AIzaSyD8qJGXijP4NLfsI0vJG4Hzq0DsGhyd7YA'; diff --git a/lib/Components/search_closest_source_button.dart b/lib/Components/search_closest_source_button.dart new file mode 100644 index 0000000..2ad8010 --- /dev/null +++ b/lib/Components/search_closest_source_button.dart @@ -0,0 +1,46 @@ +import 'package:flow/Components/directions/show_closest_source_dialog.dart'; +import 'package:flow/Components/flow_maps.dart'; +import 'package:flow/constants.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'custom_dialog_route.dart'; +import 'directions/directions_model.dart'; + +class SearchClosestSourceButton extends StatelessWidget { + final String _heroShowClosestSourceTag = 'hero_show_closest_source_tag'; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () async { + Navigator.of(context).push(CustomHeroDialogRoute( + builder: (context) { + return ShowClosestSourceDialog(); + }, + )); + }, + child: Hero( + tag: _heroShowClosestSourceTag, + child: Material( + // decoration: BoxDecoration( + // // shape: BoxShape.circle, + // color: Colors.white, + // borderRadius: BorderRadius.circular(32), + // ), + color: Colors.white, + + elevation: 5, + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(32)), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: SvgPicture.asset( + 'Assets/icons/svgs/fi-rr-search.svg', + color: primarycolor, + ), + ), + ), + ), + ); + } +} diff --git a/lib/Screens/AskingPermissions.dart b/lib/Screens/AskingPermissions.dart deleted file mode 100644 index 68cb2c4..0000000 --- a/lib/Screens/AskingPermissions.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'package:flow/Components/flow_location.dart'; -import 'package:flow/constants.dart'; -import 'package:flutter/material.dart'; - -class FlowAskPermissions extends StatelessWidget { - @override - Widget build(BuildContext context) { - screenWidth = MediaQuery.of(context).size.width; - screenHeight = MediaQuery.of(context).size.width; - return Scaffold( - backgroundColor: purplecolor, - body: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: screenWidth * .2), - child: Image( - image: - AssetImage('Assets/images/placeholder_image_white.png'), - ), - ), - SizedBox( - height: 20, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: screenWidth * .1), - child: HeadlineTextBold( - title: 'Allow Flow to access your location?', - color: Colors.white), - ), - SizedBox( - height: 30, - ), - ], - ), - - Container( - width: double.infinity, - margin: const EdgeInsets.all(20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), - color: Colors.white, - ), - // ignore: deprecated_member_use - child: FlatButton( - child: HeadlineTextBold( - title: 'Allow Permissions', - color: primarycolor, - ), - onPressed: () {}, - ), - ), - SizedBox( - height: 20, - ), - // ignore: deprecated_member_use - FlatButton( - color: Colors.transparent, - onPressed: () {}, - child: HeadlineText( - title: 'Deny', - color: Colors.white, - )) - - ///Allow Permissions Buttons - ], - ), - ); - } -} From 5488f5bd85770aed754d856a6e1c55aba0b51af0 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:20:58 +0100 Subject: [PATCH 13/26] Removed Unused Import --- lib/Screens/FlowHomeScreen.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Screens/FlowHomeScreen.dart b/lib/Screens/FlowHomeScreen.dart index efb61af..559bc00 100644 --- a/lib/Screens/FlowHomeScreen.dart +++ b/lib/Screens/FlowHomeScreen.dart @@ -1,6 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flow/Components/Permissions.dart'; -import 'package:flow/Components/flow_location.dart'; import 'package:flow/Screens/FlowAskPermissionsScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; From 11a78467ed2bab216ccbf739806c0da3928f2b42 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:22:20 +0100 Subject: [PATCH 14/26] Made UI changes, Replaced distance with description snippet --- lib/Screens/FlowFindScreen.dart | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/Screens/FlowFindScreen.dart b/lib/Screens/FlowFindScreen.dart index 9d4b3e7..285d0c5 100644 --- a/lib/Screens/FlowFindScreen.dart +++ b/lib/Screens/FlowFindScreen.dart @@ -1,4 +1,5 @@ import 'package:flow/Components/bottom_sheet_info.dart'; +import 'package:flow/Components/flow_snackbar.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flow/Components/flow_app_bar.dart'; @@ -19,27 +20,37 @@ class _FlowFindScreenState extends State { final Stream flowFirestoreStream = FirebaseFirestore.instance.collection('flow_water_sources').snapshots(); String ifisflowingiconlink; + Color flowingColor; + String descriptionSnippet; ///method to build a list for every document index in snapshot Widget buildWaterSourcesList( BuildContext context, DocumentSnapshot document) { if (document['isFlowing'] == true) { ifisflowingiconlink = 'Assets/icons/svgs/fi-sr-flowing-filled.svg'; + flowingColor = primarycolor; } else // add icon for when the tap is flowing { ifisflowingiconlink = 'Assets/icons/svgs/fi-rr-not-flowing.svg'; + flowingColor = textcolor; + } + if (document['description'].toString().length < 20) { + descriptionSnippet = document['description']; + } else { + descriptionSnippet = document['description'].toString().substring(0, 20); } - return WaterSourcesListItem( + return WaterSourcesListItemFindScreen( id: document['ID'], isflowingiconlink: ifisflowingiconlink, - distance: 'N/A m', + flowIconColor: flowingColor, + description: '$descriptionSnippet...', moreInfoIcon: IconButton( padding: EdgeInsets.zero, enableFeedback: true, icon: SvgPicture.asset( 'Assets/icons/svgs/fi-rr-angle-small-down.svg', - color: primarycolor, + color: textcolor, ), onPressed: () { setState(() { @@ -89,18 +100,22 @@ class _FlowFindScreenState extends State { builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); + //return Text('Error: ${snapshot.error}'); + return FlowSnackBar(text: 'Error: ${snapshot.error}'); } //check for connection state and return appropriate messages switch (snapshot.connectionState) { case ConnectionState.waiting: return Center( - child: CircularProgressIndicator( + child: CircularProgressIndicator.adaptive( backgroundColor: Colors.transparent, ), ); case ConnectionState.none: - return BodyText(title: 'You are offline'); + //return BodyText(title: 'You are offline'); + return FlowSnackBar( + text: 'Oops, You are offline', + ); //this is the data we get default: From 4bb156e3d3927b5a48be6fdcfaf7010b1026a7c9 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:24:32 +0100 Subject: [PATCH 15/26] Updated dependencies --- pubspec.lock | 27 ++++++++++----------------- pubspec.yaml | 8 ++++---- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 495d70d..7eec805 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,21 +42,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "1.0.7" + version: "2.3.0" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.3" + version: "5.2.0" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.7" + version: "2.2.0" collection: dependency: transitive description: @@ -64,13 +64,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" cupertino_icons: dependency: "direct main" description: @@ -145,14 +138,14 @@ packages: name: flutter_polyline_points url: "https://pub.dartlang.org" source: hosted - version: "0.2.6" + version: "1.0.0" flutter_svg: dependency: "direct main" description: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "0.19.3" + version: "0.22.0" flutter_test: dependency: "direct dev" description: flutter @@ -246,14 +239,14 @@ packages: name: path_drawing url: "https://pub.dartlang.org" source: hosted - version: "0.4.1+1" + version: "0.5.1" path_parsing: dependency: transitive description: name: path_parsing url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.2.1" path_provider_linux: dependency: transitive description: @@ -288,7 +281,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "4.1.0" platform: dependency: transitive description: @@ -302,7 +295,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" process: dependency: transitive description: @@ -440,7 +433,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "5.1.2" sdks: dart: ">=2.12.0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b1a28fa..3ca40c5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 2.0.0+1 environment: sdk: ">=2.7.0 <3.0.0" @@ -28,13 +28,13 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - flutter_svg: ^0.19.1 + flutter_svg: ^0.22.0 google_maps_flutter: ^2.0.1 location: ^4.1.1 - cloud_firestore: ^1.0.3 + cloud_firestore: ^2.3.0 firebase_core: ^1.0.2 shared_preferences: ^2.0.5 - flutter_polyline_points: ^0.2.6 + flutter_polyline_points: ^1.0.0 dio: ^4.0.0 From 9dcf871e90fb0354d91aebd825b24300a8df5fb8 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:25:42 +0100 Subject: [PATCH 16/26] Little UI changes --- lib/Screens/FlowAskPermissionsScreen.dart | 74 +++++++++++------------ 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/lib/Screens/FlowAskPermissionsScreen.dart b/lib/Screens/FlowAskPermissionsScreen.dart index e80839c..4d9a64c 100644 --- a/lib/Screens/FlowAskPermissionsScreen.dart +++ b/lib/Screens/FlowAskPermissionsScreen.dart @@ -1,6 +1,7 @@ import 'package:flow/constants.dart'; import 'package:flutter/material.dart'; import 'package:flow/Components/Permissions.dart'; +import 'package:flutter_svg/flutter_svg.dart'; class FlowAskPermissions extends StatefulWidget { @override @@ -17,47 +18,44 @@ class _FlowAskPermissionsState extends State { body: SafeArea( child: Column( children: [ - Spacer(), - /// Image and text Area - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: screenWidth * .2), - child: Image( - image: - AssetImage('Assets/images/placeholder_image_white.png'), - ), - ), - SizedBox(height: 20), - Padding( - padding: EdgeInsets.symmetric(horizontal: screenWidth * .1), - child: Text( - 'Flow needs access to your location for certain features to work properly', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 16, - ), - ), - ), - SizedBox(height: 20), - Padding( - padding: EdgeInsets.symmetric(horizontal: screenWidth * .1), - child: Text( - 'Allow Flow to access your location?', - textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - ), - ), + Spacer(), + Container( + padding: EdgeInsets.only( + left: screenWidth * .1, right: screenHeight * .15), + //width: screenWidth * .8, + child: SvgPicture.asset( + 'Assets/illustrations/request-location-on.svg', + height: screenHeight * .5, + ), + ), + SizedBox(height: 30), + Padding( + padding: EdgeInsets.symmetric(horizontal: screenWidth * .1), + child: Text( + 'Flow needs access to your location for certain features to work properly', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 16, ), - SizedBox( - height: 10, + ), + ), + SizedBox(height: 20), + Padding( + padding: EdgeInsets.symmetric(horizontal: screenWidth * .1), + child: Text( + 'Allow Flow to access your location?', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: Colors.white, ), - ], + ), + ), + SizedBox( + height: 10, ), ///Allow Permissions Buttons From c0e853f4d93973445e22fa1f1cddda97474b72d5 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Tue, 24 Aug 2021 22:26:30 +0100 Subject: [PATCH 17/26] Saving Tap coordinates in SP --- lib/Components/flow_shared_preferences.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Components/flow_shared_preferences.dart b/lib/Components/flow_shared_preferences.dart index 3f2214c..e84a609 100644 --- a/lib/Components/flow_shared_preferences.dart +++ b/lib/Components/flow_shared_preferences.dart @@ -1,12 +1,11 @@ -import 'package:cloud_firestore/cloud_firestore.dart'; - class FlowSaved { String savedID; String savedDescription; String savedDistance; bool savedFlowing; String savedTypeTap; - GeoPoint savedTapLocation; + double savedTapLocationLatitude; + double savedTapLocationLongitude; //bool savedisSaved; FlowSaved({ @@ -15,7 +14,8 @@ class FlowSaved { this.savedDistance, this.savedFlowing, this.savedTypeTap, - this.savedTapLocation, + this.savedTapLocationLatitude, + this.savedTapLocationLongitude, // this.savedisSaved, }); @@ -27,7 +27,8 @@ class FlowSaved { this.savedDistance = map['Distance'], this.savedFlowing = map['Flowing'], this.savedTypeTap = map['TypeTap'], - this.savedTapLocation = map['Location']; + this.savedTapLocationLatitude = map['LocationLat'], + this.savedTapLocationLongitude = map['LocationLong']; // this.savedisSaved = map['isSaved']; ///convert from flowSaved Object to a map @@ -38,7 +39,8 @@ class FlowSaved { 'Distance': this.savedDistance, 'Flowing': this.savedFlowing, 'TypeTap': this.savedTypeTap, - 'Location': this.savedTapLocation, + 'LocationLat': this.savedTapLocationLatitude, + 'LocationLong': this.savedTapLocationLongitude, // 'isSaved': this.savedisSaved, }; } From 6f2ff4ead2237b8ae86d7473cbffc9ff7a240bf3 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Sun, 5 Sep 2021 20:08:47 +0100 Subject: [PATCH 18/26] Changed the api key --- lib/Components/directions/.env.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Components/directions/.env.dart b/lib/Components/directions/.env.dart index e479422..f4ebf4e 100644 --- a/lib/Components/directions/.env.dart +++ b/lib/Components/directions/.env.dart @@ -1 +1 @@ -const String googleAPIKey = 'AIzaSyD8qJGXijP4NLfsI0vJG4Hzq0DsGhyd7YA'; +const String googleAPIKey = 'AIzaSyD9wO2GB7X6X8MTM1avTDWscKgYyFhin28'; From bb2ba8c0a2f95208e38467b3e744d412ea194f4e Mon Sep 17 00:00:00 2001 From: nuilewis Date: Sun, 5 Sep 2021 20:23:17 +0100 Subject: [PATCH 19/26] adjusted names in about screen --- lib/Screens/FlowAboutScreen.dart | 104 +++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 19 deletions(-) diff --git a/lib/Screens/FlowAboutScreen.dart b/lib/Screens/FlowAboutScreen.dart index 11bcf26..34c3bb5 100644 --- a/lib/Screens/FlowAboutScreen.dart +++ b/lib/Screens/FlowAboutScreen.dart @@ -1,3 +1,5 @@ +import 'package:flow/Components/custom_dialog_route.dart'; +import 'package:flow/Components/directions/show_closest_source_dialog.dart'; import 'package:flow/constants.dart'; import 'package:flutter/material.dart'; @@ -26,7 +28,7 @@ class FlowAboutScreen extends StatelessWidget { ), ), SizedBox( - height: 30, + height: 20, ), HeadlineTextBold( title: 'Find water easily around Bambili', @@ -44,50 +46,114 @@ class FlowAboutScreen extends StatelessWidget { SizedBox( height: 15, ), + GestureDetector( + onTap: () { + Feedback.forTap(context); + Navigator.push( + context, + CustomHeroDialogRoute( + builder: (context) { + return TeamFlowNames(); + }, + ), + ); + }, + child: Material( + elevation: 0, + color: Colors.white, + child: Hero( + tag: 'teamflowherotag', + child: Text('Team Flow', + style: TextStyle( + color: primarycolor, + fontWeight: FontWeight.bold, + fontSize: 18)), + ), + ), + ), + SizedBox( + height: screenHeight * .05, + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Text( + 'This is a project by the Google Developer Student Clubs of the University of Bamenda', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } +} + +class TeamFlowNames extends StatelessWidget { + const TeamFlowNames({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Center( + child: Hero( + tag: 'teamflowherotag', + child: Material( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + color: Colors.white, + child: Stack( + alignment: Alignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + height: MediaQuery.of(context).size.height * 0.3, + ), + SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ BodyText( - title: 'Ida Delphine', + title: 'Alouzeh Brandone', color: primarycolor, ), SizedBox( - height: 5, + height: 10, ), BodyText( - title: 'Alouzeh Brandone', + title: 'Ida Delphine', color: primarycolor, ), SizedBox( - height: 5, + height: 10, ), BodyText( title: 'Nuikweh Lewis', color: primarycolor, ), SizedBox( - height: 5, + height: 10, ), BodyText( title: 'Chi Karl', color: primarycolor, ), SizedBox( - height: 15, - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: Text( - 'This is a project by the Google Developer Student Clubs of the University of Bamenda', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - ), - ), + height: 10, ), ], ), - ), + ) ], ), - ], + ), ), ); } From af9deb7ed5ed84f7247dc6f076b4674472de3af7 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Sun, 5 Sep 2021 20:24:51 +0100 Subject: [PATCH 20/26] changed api key --- android/app/google-services.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/google-services.json b/android/app/google-services.json index 9cca0ca..5b843ff 100644 --- a/android/app/google-services.json +++ b/android/app/google-services.json @@ -20,7 +20,7 @@ ], "api_key": [ { - "current_key": "AIzaSyBkw-O_rAY5UTYDmj3Rl6-kWjg57Ze48nw" + "current_key": "AIzaSyD9wO2GB7X6X8MTM1avTDWscKgYyFhin28" } ], "services": { From 36ce80a5a20067e5195366c8057b8f39d350a24a Mon Sep 17 00:00:00 2001 From: nuilewis Date: Sun, 5 Sep 2021 20:25:39 +0100 Subject: [PATCH 21/26] worked on Shared prefs, adjusted some stuff --- lib/Components/bottom_sheet_info.dart | 25 +++++----------- lib/Components/flow_location.dart | 1 + lib/Components/flow_maps.dart | 43 +++++++++++++++------------ lib/Screens/FlowFindScreen.dart | 6 +++- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/lib/Components/bottom_sheet_info.dart b/lib/Components/bottom_sheet_info.dart index 78ce01c..213f3d2 100644 --- a/lib/Components/bottom_sheet_info.dart +++ b/lib/Components/bottom_sheet_info.dart @@ -1,4 +1,3 @@ -import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flow/Components/directions/distance_calculator.dart'; import 'package:flutter/material.dart'; import 'package:flow/constants.dart'; @@ -19,7 +18,7 @@ class BottomSheetInfo extends StatefulWidget { final bool bottomSheetIsTypeTap; final bool bottomSheetIsFlowing; final String distance; - final GeoPoint tapLocation; + final LatLng tapLocation; BottomSheetInfo({ Key key, @@ -101,18 +100,6 @@ class BottomSheetInfoState extends State { print('current location data is $currentLocation'); return currentLocation; - - // PermissionStatus currentPermissionStatus; - // if (currentPermissionStatus == PermissionStatus.granted) { - // print('get current locationf from bottom sheet is running'); - // final LocationData currentLocData = await getLocation(); - // currentLocation = - // LatLng(currentLocData.latitude, currentLocData.longitude); - // - // print('current location data is $currentLocation'); - // - // return currentLocation; - // } } ///method to call the distance calculator @@ -142,8 +129,9 @@ class BottomSheetInfoState extends State { ifIsFlowing = 'Not Flowing'; } - markerLocation = - LatLng(widget.tapLocation.latitude, widget.tapLocation.longitude); + // markerLocation = + // LatLng(widget.tapLocation.latitude, widget.tapLocation.longitude); + markerLocation = widget.tapLocation; // if (estDistance == null) { // setState(() { @@ -310,7 +298,8 @@ class BottomSheetInfoState extends State { savedDistance: '$estDistance Km', savedFlowing: widget.bottomSheetIsFlowing, savedTypeTap: ifIsTypeTap, - //savedTapLocation: widget.tapLocation, + savedTapLocationLatitude: markerLocation.latitude.toDouble(), + savedTapLocationLongitude: markerLocation.longitude.toDouble(), // savedisSaved: isSaved, )); @@ -339,6 +328,8 @@ class BottomSheetInfoState extends State { savedDistance: widget.distance.toString(), savedFlowing: widget.bottomSheetIsFlowing, savedTypeTap: ifIsTypeTap, + savedTapLocationLatitude: markerLocation.latitude.toDouble(), + savedTapLocationLongitude: markerLocation.longitude.toDouble(), // savedisSaved: isSaved, ), widget.bottomSheetID, diff --git a/lib/Components/flow_location.dart b/lib/Components/flow_location.dart index 2c2de17..47a6097 100644 --- a/lib/Components/flow_location.dart +++ b/lib/Components/flow_location.dart @@ -15,6 +15,7 @@ getLocation() async { return currentLocation; }, ); + return currentPosition; } // class MyLocation extends StatefulWidget { diff --git a/lib/Components/flow_maps.dart b/lib/Components/flow_maps.dart index 69a43c5..75e0687 100755 --- a/lib/Components/flow_maps.dart +++ b/lib/Components/flow_maps.dart @@ -1,4 +1,5 @@ import 'package:flow/Components/Permissions.dart'; +import 'package:flow/Components/custom_dialog_route.dart'; import 'package:flow/constants.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -11,14 +12,16 @@ import 'package:location/location.dart'; import 'directions/directions_repository.dart'; import 'directions/directions_model.dart'; import 'bottom_sheet_info.dart'; +import 'directions/nav_instructions.dart'; import 'flow_location.dart'; import 'flow_snackbar.dart'; import 'search_closest_source_button.dart'; // ignore: must_be_immutable class FlowMaps extends StatefulWidget { - FlowMaps() : super(); + FlowMaps({this.directioninformation}) : super(); Directions directionInfo; + final Directions directioninformation; ///Get Directions func getDirections(LatLng origin, LatLng destination) async { @@ -220,34 +223,36 @@ class _FlowMapsState extends State { ['isTypeTap'], bottomSheetIsFlowing: snapshot.data.docs[i] ['isFlowing'], - tapLocation: markerLocation, + tapLocation: LatLng( + snapshot.data.docs[i]['location'].latitude, + snapshot.data.docs[i]['location'].longitude), // distance: directionInfo.totalDistance, ); }); - // NavigationInstructions( - // tapID: snapshot.data.docs[i]['ID'], - // tapDescription: snapshot.data.docs[i]['description'], - // time: dirInfoFromSheet.totalDistance, - // distance: dirInfoFromSheet.totalDistance, - // navInfo: dirInfoFromSheet, - // ); + + // if (dirInfoFromSheet != null) { + // Navigator.push(context, CustomHeroDialogRoute( + // builder: (context) { + // return NavigationInstructions( + // tapID: snapshot.data.docs[i]['ID'], + // tapDescription: snapshot.data.docs[i] + // ['description'], + // time: dirInfoFromSheet.totalDuration, + // distance: dirInfoFromSheet.totalDistance, + // navInfo: dirInfoFromSheet, + // ); + // }, + // )); + // } + + directionInfo = widget.directioninformation; directionInfo = dirInfoFromSheet; setState(() {}); }, //load bottom sheet ), ); - - // ///Calculating distances and adding to the List; - // sourceDistancesList - // .add(distanceCalculator(currentLocation, markerLocation)); } // end of loop - // calculateClosestSource(currentLocation, markerLocation); - - ///Getting the shortest distance in the List of Distances - // shortestDistance = sourceDistancesList.reduce(min); - // print('list of distances is $sourceDistancesList'); - // print('shortest distance within the list is $shortestDistance'); return GoogleMap( initialCameraPosition: CameraPosition( diff --git a/lib/Screens/FlowFindScreen.dart b/lib/Screens/FlowFindScreen.dart index 285d0c5..fb53157 100644 --- a/lib/Screens/FlowFindScreen.dart +++ b/lib/Screens/FlowFindScreen.dart @@ -9,6 +9,7 @@ import 'package:flow/Components/sources_list_item.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/svg.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; class FlowFindScreen extends StatefulWidget { @override @@ -34,6 +35,8 @@ class _FlowFindScreenState extends State { ifisflowingiconlink = 'Assets/icons/svgs/fi-rr-not-flowing.svg'; flowingColor = textcolor; } + + //Extracting a snippet from the description if (document['description'].toString().length < 20) { descriptionSnippet = document['description']; } else { @@ -62,7 +65,8 @@ class _FlowFindScreenState extends State { bottomSheetDescription: document['description'], bottomSheetIsTypeTap: document['isTypeTap'], bottomSheetIsFlowing: document['isFlowing'], - tapLocation: document['location'], + tapLocation: LatLng(document['location'].latitude, + document['location'].longitude), ); }); }); From cf999d9e39545e731c1b070706106ebf5f9df2fb Mon Sep 17 00:00:00 2001 From: nuilewis Date: Sun, 5 Sep 2021 20:26:34 +0100 Subject: [PATCH 22/26] fixed continuous distance calculation problem --- .../show_closest_source_dialog.dart | 105 +++++++++++------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/lib/Components/directions/show_closest_source_dialog.dart b/lib/Components/directions/show_closest_source_dialog.dart index e504e6d..5cea738 100644 --- a/lib/Components/directions/show_closest_source_dialog.dart +++ b/lib/Components/directions/show_closest_source_dialog.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flow/Components/bottom_sheet_info.dart'; import 'package:flow/Components/flow_location.dart'; import 'package:flow/constants.dart'; import 'package:flutter/material.dart'; @@ -46,6 +47,7 @@ class _ShowClosestSourceDialogState extends State { getLoc() async { LocationData currentLoc = await getLocation(); currentLocation = LatLng(currentLoc.latitude, currentLoc.longitude); + return currentLocation; } @@ -82,43 +84,48 @@ class _ShowClosestSourceDialogState extends State { ); default: Future.delayed(Duration(seconds: 3), () { - for (int i = 0; i < snapshot.data.docs.length; i++) { - markerLocation = LatLng( - snapshot.data.docs[i]['location'].latitude, - snapshot.data.docs[i]['location'].longitude); - // sourceDistancesList = []; - // sourceIDsList = []; - // sourceLocationList = []; - // sourceDistancesList = []; - if (snapshot.data.docs[i]['isFlowing'] == true) { + if (sourceDistancesList.isEmpty) { + for (int i = 0; i < snapshot.data.docs.length; i++) { + markerLocation = LatLng( + snapshot.data.docs[i]['location'].latitude, + snapshot.data.docs[i]['location'].longitude); + // sourceDistancesList = []; // sourceIDsList = []; - sourceIDsList.add(snapshot.data.docs[i]['ID']); - //sourceLocationList = []; - sourceLocationList.add(snapshot.data.docs[i]['location']); - //sourceDistancesList = []; - sourceDistancesList.add( - distanceCalculator(currentLocation, markerLocation), - ); + // sourceLocationList = []; + // sourceDistancesList = []; + if (snapshot.data.docs[i]['isFlowing'] == true) { + // sourceIDsList = []; + sourceIDsList.add(snapshot.data.docs[i]['ID']); + //sourceLocationList = []; + sourceLocationList.add(snapshot.data.docs[i]['location']); + //sourceDistancesList = []; + sourceDistancesList.add( + distanceCalculator(currentLocation, markerLocation), + ); + } } - } - ///Getting the shortest distance in the Lists of Distances - setState(() { - shortestDistance = sourceDistancesList.reduce(min); - int indexOfClosestSource = - sourceDistancesList.indexOf(shortestDistance); - closestSourceID = sourceIDsList[indexOfClosestSource]; - closestSourceGeopoint = - sourceLocationList[indexOfClosestSource]; - closestSourceLocation = LatLng( - closestSourceGeopoint.latitude, - closestSourceGeopoint.longitude, - ); - }); - print('does current location change lets see:$currentLocation'); - print('list of distances is $sourceDistancesList'); - print('shortest distance within the list is $shortestDistance'); - print('shortest source ID within the list is $closestSourceID'); + ///Getting the shortest distance in the Lists of Distances + setState(() { + shortestDistance = sourceDistancesList.reduce(min); + int indexOfClosestSource = + sourceDistancesList.indexOf(shortestDistance); + closestSourceID = sourceIDsList[indexOfClosestSource]; + closestSourceGeopoint = + sourceLocationList[indexOfClosestSource]; + closestSourceLocation = LatLng( + closestSourceGeopoint.latitude, + closestSourceGeopoint.longitude, + ); + }); + print( + 'does current location change lets see:$currentLocation'); + print('list of distances is $sourceDistancesList'); + print( + 'shortest distance within the list is $shortestDistance'); + print( + 'shortest source ID within the list is $closestSourceID'); + } }); if (shortestDistance == null) { @@ -166,12 +173,24 @@ class _ShowClosestSourceDialogState extends State { GestureDetector( onTap: () async { Feedback.forTap(context); - Navigator.of(context).pop( - FlowMaps().directionInfo = await FlowMaps() + FlowMaps( + directioninformation: await FlowMaps() .getDirections(currentLocation, closestSourceLocation), ); - setState(() {}); + // showBottomSheet( + // context: context, + // builder: (BuildContext context) { + // return BottomSheetInfo( + // bottomSheetID: closestSourceID, + // bottomSheetDescription: + // closestSourceDescription, + // bottomSheetIsFlowing: true, + // bottomSheetIsTypeTap: true, + // tapLocation: closestSourceLocation, + // ); + // }); + Navigator.of(context).pop(); }, child: Container( decoration: BoxDecoration( @@ -195,11 +214,15 @@ class _ShowClosestSourceDialogState extends State { // directionInfo = await FlowMaps().getDirections( // currentLocation, closestSourceLocation); // Navigator.of(context).pop(directionInfo); + for (var i = 0; + i < sourceDistancesList.length; + i++) { + sourceDistancesList.remove(i); + sourceIDsList.remove(i); + sourceLocationList.remove(i); + sourceDistancesList.remove(i); + } - sourceDistancesList = []; - sourceIDsList = []; - sourceLocationList = []; - sourceDistancesList = []; Navigator.pop(context); }, child: Container( From bf557827afb11941d62f9dc08bbc5680ae528f39 Mon Sep 17 00:00:00 2001 From: nuilewis Date: Sun, 5 Sep 2021 20:26:53 +0100 Subject: [PATCH 23/26] Adjusted stuff --- lib/Components/custom_dialog_route.dart | 67 +++++----- .../directions/nav_instructions.dart | 122 ++++++++++++------ 2 files changed, 117 insertions(+), 72 deletions(-) diff --git a/lib/Components/custom_dialog_route.dart b/lib/Components/custom_dialog_route.dart index e04801a..cb8fc5f 100644 --- a/lib/Components/custom_dialog_route.dart +++ b/lib/Components/custom_dialog_route.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; ///{@template custom hero_dialod_route} @@ -6,35 +5,39 @@ import 'package:flutter/material.dart'; /// ///Best used with a [Hero] animation -class CustomHeroDialogRoute extends PageRoute { - -CustomHeroDialogRoute({ - @required WidgetBuilder builder, - RouteSettings settings, - bool fullscreenDialog = false, -}) : _builder = builder, super(settings: settings, fullscreenDialog: fullscreenDialog); - -final WidgetBuilder _builder; - -@override -bool get opaque => false; -@override -bool get barrierDismissible => true; -@override -Duration get transitionDuration => const Duration(milliseconds:300); -@override -bool get maintainState=> true; - -@override -Color get barrierColor => Colors.black54; -@override -Widget buildTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child){ return child;} - -@override -Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation){ - return _builder(context); +class CustomHeroDialogRoute extends PageRoute { + CustomHeroDialogRoute({ + @required WidgetBuilder builder, + RouteSettings settings, + bool fullscreenDialog = false, + }) : _builder = builder, + super(settings: settings, fullscreenDialog: fullscreenDialog); + + final WidgetBuilder _builder; + + @override + bool get opaque => false; + @override + bool get barrierDismissible => true; + @override + Duration get transitionDuration => const Duration(milliseconds: 300); + @override + bool get maintainState => true; + + @override + Color get barrierColor => Colors.black54; + @override + Widget buildTransitions(BuildContext context, Animation animation, + Animation secondaryAnimation, Widget child) { + return child; + } + + @override + Widget buildPage(BuildContext context, Animation animation, + Animation secondaryAnimation) { + return _builder(context); + } + + @override + String get barrierLabel => 'Popup dialog open'; } -@override -String get barrierLabel => 'Popup dialog open'; - -} \ No newline at end of file diff --git a/lib/Components/directions/nav_instructions.dart b/lib/Components/directions/nav_instructions.dart index 5113077..1f84ca8 100644 --- a/lib/Components/directions/nav_instructions.dart +++ b/lib/Components/directions/nav_instructions.dart @@ -21,51 +21,93 @@ class NavigationInstructions extends StatelessWidget { @override Widget build(BuildContext context) { - return DraggableScrollableSheet( - minChildSize: .2, - maxChildSize: .6, - builder: ( - context, - scrollController, - ) { - return SingleChildScrollView( - controller: scrollController, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.vertical(top: Radius.circular(15)), - color: primarycolor, - ), - child: Stack( - children: [ - Column( - children: [ - Text('Navigating To..'), - Text(tapID), - Text(tapDescription), - Row( + Size screenSize = MediaQuery.of(context).size; + return Material( + child: DraggableScrollableSheet( + minChildSize: .3, + maxChildSize: .6, + builder: ( + context, + scrollController, + ) { + return SingleChildScrollView( + controller: scrollController, + child: Container( + height: screenSize.height * .5, + decoration: BoxDecoration( + borderRadius: BorderRadius.vertical(top: Radius.circular(15)), + color: Colors.white, + ), + child: Stack( + children: [ + Positioned( + top: 5, + left: 5, + child: Text( + 'Navigating To..', + style: TextStyle( + fontSize: 42, + fontWeight: FontWeight.bold, + color: Colors.black12), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(20, 40, 0, 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(distance), - Text(time), + HeadlineTextBold( + title: tapID, + color: primarycolor, + ), + SizedBox(height: 10), + BodyText( + title: tapDescription, + color: textcolor, + ), + // Row( + // children: [ + // Text(distance), + // Text(time), + // ], + // ) ], - ) - ], - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, + ), ), - child: SingleChildScrollView( - // child: ListView.builder( - // itemBuilder: , - // ), + Positioned( + top: screenSize.height * .2, + left: 0, + right: 0, + child: Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + ), + child: SingleChildScrollView( + child: Column( + children: [ + Text('sup'), + Text('sup'), + Text('sup'), + Text('sup'), + Text('sup'), + Text('sup'), + Text('sup'), + ], + ), + // child: ListView.builder( + // itemBuilder: , + // ), ), - ), - ], + ), + ), + ], + ), ), - ), - ); - }); + ); + }), + ); } } From 000c4a3436aeac3861902880eccb67eb0225742f Mon Sep 17 00:00:00 2001 From: nuilewis <72214279+nuilewis@users.noreply.github.com> Date: Sun, 5 Sep 2021 20:59:01 +0100 Subject: [PATCH 24/26] Removed exposed API key --- lib/Components/directions/.env.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Components/directions/.env.dart b/lib/Components/directions/.env.dart index f4ebf4e..081affc 100644 --- a/lib/Components/directions/.env.dart +++ b/lib/Components/directions/.env.dart @@ -1 +1 @@ -const String googleAPIKey = 'AIzaSyD9wO2GB7X6X8MTM1avTDWscKgYyFhin28'; +const String googleAPIKey = 'YOUR API KEY HERE'; From ef0913fc38ff4ce07ced1bcff3f6e8dfaa5573d2 Mon Sep 17 00:00:00 2001 From: nuilewis <72214279+nuilewis@users.noreply.github.com> Date: Sun, 5 Sep 2021 21:02:04 +0100 Subject: [PATCH 25/26] Removed exposed api key --- android/app/google-services.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/google-services.json b/android/app/google-services.json index 5b843ff..73e38eb 100644 --- a/android/app/google-services.json +++ b/android/app/google-services.json @@ -20,7 +20,7 @@ ], "api_key": [ { - "current_key": "AIzaSyD9wO2GB7X6X8MTM1avTDWscKgYyFhin28" + "current_key": "YOUR GOOGLE MAPS API KEY HERE" } ], "services": { @@ -36,4 +36,4 @@ } ], "configuration_version": "1" -} \ No newline at end of file +} From d39e5f43df6975464a83577a36ddecc937511b2a Mon Sep 17 00:00:00 2001 From: nuilewis <72214279+nuilewis@users.noreply.github.com> Date: Sun, 5 Sep 2021 21:03:46 +0100 Subject: [PATCH 26/26] Removed exposed API key --- android/app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 796a8ef..7eaebac 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ android:icon="@mipmap/ic_launcher"> + android:value="YOUR GOOGLE MAPS API KEY HERE" />