From 8c96a9359a4876924bd8f8ecfdabd792c95edc00 Mon Sep 17 00:00:00 2001 From: johnny Date: Sun, 16 Aug 2020 11:20:09 +1000 Subject: [PATCH] added permissions and fixed map rotation --- ios/Podfile.lock | 18 +++++ ios/Runner.xcodeproj/project.pbxproj | 4 ++ ios/Runner/Info.plist | 8 ++- lib/components/bottom_sheet.dart | 12 ++-- lib/data/area_update_card_lists.dart | 17 +++++ lib/screens/home_screen.dart | 100 ++++++++++++++++----------- pubspec.lock | 28 ++++++++ pubspec.yaml | 1 + 8 files changed, 141 insertions(+), 47 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d7da224..7a81a33 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2,6 +2,10 @@ PODS: - Flutter (1.0.0) - flutter_plugin_android_lifecycle (0.0.1): - Flutter + - "geolocator (5.3.2+2)": + - Flutter + - google_api_availability (2.0.4): + - Flutter - google_maps_flutter (0.0.1): - Flutter - GoogleMaps (< 3.10) @@ -10,6 +14,8 @@ PODS: - GoogleMaps/Base (2.7.0) - GoogleMaps/Maps (2.7.0): - GoogleMaps/Base + - "location_permissions (3.0.0+1)": + - Flutter - path_provider (0.0.1): - Flutter - path_provider_linux (0.0.1): @@ -22,7 +28,10 @@ PODS: DEPENDENCIES: - Flutter (from `Flutter`) - flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`) + - geolocator (from `.symlinks/plugins/geolocator/ios`) + - google_api_availability (from `.symlinks/plugins/google_api_availability/ios`) - google_maps_flutter (from `.symlinks/plugins/google_maps_flutter/ios`) + - location_permissions (from `.symlinks/plugins/location_permissions/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) - path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`) @@ -37,8 +46,14 @@ EXTERNAL SOURCES: :path: Flutter flutter_plugin_android_lifecycle: :path: ".symlinks/plugins/flutter_plugin_android_lifecycle/ios" + geolocator: + :path: ".symlinks/plugins/geolocator/ios" + google_api_availability: + :path: ".symlinks/plugins/google_api_availability/ios" google_maps_flutter: :path: ".symlinks/plugins/google_maps_flutter/ios" + location_permissions: + :path: ".symlinks/plugins/location_permissions/ios" path_provider: :path: ".symlinks/plugins/path_provider/ios" path_provider_linux: @@ -51,8 +66,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: 0e3d915762c693b495b44d77113d4970485de6ec flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35 + geolocator: f7622e0e7e2a24718285b73916d60c4a54b9f5b6 + google_api_availability: 15fa42a8cd83c0a6738507ffe6e87096f12abcb8 google_maps_flutter: c7f9c73576de1fbe152a227bfd6e6c4ae8088619 GoogleMaps: f79af95cb24d869457b1f961c93d3ce8b2f3b848 + location_permissions: 7e0f9aa0f60deb8ff93ddf0e2a164c7e8197bc94 path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index ad4df2c..8ceab83 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -262,6 +262,8 @@ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${PODS_ROOT}/../Flutter/Flutter.framework", "${BUILT_PRODUCTS_DIR}/flutter_plugin_android_lifecycle/flutter_plugin_android_lifecycle.framework", + "${BUILT_PRODUCTS_DIR}/geolocator/geolocator.framework", + "${BUILT_PRODUCTS_DIR}/google_api_availability/google_api_availability.framework", "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", "${BUILT_PRODUCTS_DIR}/xs_progress_hud/xs_progress_hud.framework", ); @@ -269,6 +271,8 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_plugin_android_lifecycle.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/geolocator.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/google_api_availability.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/xs_progress_hud.framework", ); diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index e688ecf..80ca159 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -43,5 +43,11 @@ io.flutter.embedded_views_preview YES - + NSLocationWhenInUseUsageDescription + needed for map + NSCameraUsageDescription + Can I use the camera please? + NSMicrophoneUsageDescription + Can I use the mic please? + diff --git a/lib/components/bottom_sheet.dart b/lib/components/bottom_sheet.dart index af5c06c..3df3b91 100644 --- a/lib/components/bottom_sheet.dart +++ b/lib/components/bottom_sheet.dart @@ -17,12 +17,12 @@ class CustomBottomSheet extends StatelessWidget { List areaUpdateCardsList; CustomBottomSheet({ - this.imageURL, - this.reports, - this.location, - this.isSafe, - this.rfsResponse, - this.areaUpdateCardsList, + @required this.imageURL, + @required this.reports, + @required this.location, + @required this.isSafe, + @required this.rfsResponse, + @required this.areaUpdateCardsList, }); @override diff --git a/lib/data/area_update_card_lists.dart b/lib/data/area_update_card_lists.dart index 878461b..6a9136b 100644 --- a/lib/data/area_update_card_lists.dart +++ b/lib/data/area_update_card_lists.dart @@ -18,3 +18,20 @@ final sydney = [ color: Colors.red.shade700, ), ]; + +final gundabrookaUpdateCardList = [ + AreaUpdateCard( + title: "Area now declared DANGEROUS", + color: Colors.red.shade700, + textOne: "RFS has been dispatched to outbreak", + textTwo: "evacuate as soon as possible", + icon: FontAwesomeIcons.bell, + ), + AreaUpdateCard( + title: "Caution is advises", + textOne: "Hot and dry weather upwards", + textTwo: "of 48 degrees", + icon: FontAwesomeIcons.info, + color: Colors.orange.shade400, + ), +]; diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 1b18060..dc44894 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -5,8 +5,7 @@ import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:signal_flutter_v2/components/bottom_sheet.dart'; import 'package:signal_flutter_v2/data/area_update_card_lists.dart'; - -//REMOVE THIS GOOGLE_MAPS_API_KEY = 'AIzaSyAr31utYalU_q4_Lh1GtqZrCDgg0VBlcHI' +import 'package:geolocator/geolocator.dart'; class HomeScreen extends StatefulWidget { @override @@ -17,7 +16,7 @@ class _HomeScreenState extends State { GoogleMapController _mapController; Set _markers = HashSet(); BitmapDescriptor _customIcon; - + Position _position; // @override // void initState() { // super.initState(); @@ -28,39 +27,51 @@ class _HomeScreenState extends State { // }); // } + @override + void initState() { + // TODO: implement initState + super.initState(); + getPosition(); + } + + void getPosition() async { + _position = await Geolocator() + .getCurrentPosition(desiredAccuracy: LocationAccuracy.high); + } + //The initial method that runs everytime Google Maps Opens void _onMapCreated(GoogleMapController controller) { _mapController = controller; setState(() { - _markers.add( - Marker( - //todo change marker id -> unique - markerId: MarkerId("0"), - position: LatLng(-33.8688, 151.2093), - onTap: () { - showCupertinoModalBottomSheet( - context: context, - builder: (context, scrollController) { - return Opacity( - opacity: 0.8, - child: Scaffold( - body: CustomBottomSheet( - location: "Sydney", - reports: "124", - isSafe: true, - rfsResponse: "none", - areaUpdateCardsList: sydney, - imageURL: - "https://www.nationalparks.nsw.gov.au/-/media/npws/images/parks/gundabooka-national-park/little-mountain-walking-track/little-mountain-track-01.jpg"), - ), - ); - }); - }, - infoWindow: InfoWindow( - title: "Sydney", - snippet: "No Fire", - )), - ); + // _markers.add( + // Marker( + // //todo change marker id -> unique + // markerId: MarkerId("0"), + // position: LatLng(-33.8688, 151.2093), + // onTap: () { + // showCupertinoModalBottomSheet( + // context: context, + // builder: (context, scrollController) { + // return Opacity( + // opacity: 0.8, + // child: Scaffold( + // body: CustomBottomSheet( + // location: "Sydney", + // reports: "124", + // isSafe: true, + // rfsResponse: "none", + // areaUpdateCardsList: sydney, + // imageURL: + // "https://www.nationalparks.nsw.gov.au/-/media/npws/images/parks/gundabooka-national-park/little-mountain-walking-track/little-mountain-track-01.jpg"), + // ), + // ); + // }); + // }, + // infoWindow: InfoWindow( + // title: "Sydney", + // snippet: "No Fire", + // )), + // ); _addMarkerList(); }); } @@ -71,16 +82,23 @@ class _HomeScreenState extends State { //todo change marker id -> unique markerId: MarkerId("1"), position: LatLng(-30.501446, 145.702932), - onTap: () { - showCupertinoModalBottomSheet( - context: context, - builder: (context, scrollController) { - return Container(); - }); - }, + onTap: () => { + showCupertinoModalBottomSheet( + context: context, + builder: (context, scrollController) { + return CustomBottomSheet( + imageURL: + "https://www.nationalparks.nsw.gov.au/-/media/npws/images/parks/gundabooka-national-park/valley-of-eagles/valley-of-eagles-walk-01.jpg", + reports: "432", + location: "Gundabrooka", + isSafe: false, + rfsResponse: "in area", + areaUpdateCardsList: gundabrookaUpdateCardList); + }), + }, infoWindow: InfoWindow( title: "Gunderbrooka", - snippet: "No Fire", + snippet: "🔥🔥🔥", )), ); _markers.add( @@ -247,6 +265,8 @@ class _HomeScreenState extends State { children: [ GoogleMap( onMapCreated: _onMapCreated, + myLocationEnabled: true, + myLocationButtonEnabled: false, initialCameraPosition: CameraPosition( target: LatLng(-33.8688, 151.2093), zoom: 12, diff --git a/pubspec.lock b/pubspec.lock index 3a37dda..de918db 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -64,6 +64,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + equatable: + dependency: transitive + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.3" file: dependency: transitive description: @@ -102,6 +109,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "8.8.1" + geolocator: + dependency: "direct main" + description: + name: geolocator + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.2+2" + google_api_availability: + dependency: transitive + description: + name: google_api_availability + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" google_fonts: dependency: "direct main" description: @@ -151,6 +172,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" + location_permissions: + dependency: transitive + description: + name: location_permissions + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0+1" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8d959d7..35ae3ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,7 @@ dependencies: google_maps_flutter: ^0.5.30 modal_bottom_sheet: ^0.2.0+1 font_awesome_flutter: ^8.8.1 + geolocator: ^5.3.2+2 dev_dependencies: flutter_test: