From bc5ab22f6955baf8b9af73cdfa6fee341abe65d6 Mon Sep 17 00:00:00 2001 From: PrestoSole Date: Sun, 27 Dec 2020 16:11:09 +0300 Subject: [PATCH] Removed the get current location's weather button --- .flutter-plugins-dependencies | 2 +- .../android/en-US/full_description.txt | 1 - lib/screens/location_screen.dart | 60 +++++++------ lib/services/location.dart | 84 +++++++++---------- lib/services/weather.dart | 23 +++-- pubspec.lock | 14 ---- pubspec.yaml | 3 +- 7 files changed, 84 insertions(+), 103 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 895ad770..63c53f02 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-2.0.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-6.1.13\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.12+4\\\\","dependencies":[]}],"android":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-2.0.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-6.1.13\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.12+4\\\\","dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_macos-0.1.0+7\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+11\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]},{"name":"shared_preferences_linux","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_linux-0.0.2+4\\\\","dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.4+3\\\\","dependencies":[]},{"name":"shared_preferences_windows","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_windows-0.0.1+3\\\\","dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_for_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_for_web-0.3.1+4\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+7\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"geolocator","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2020-12-18 12:50:02.429605","version":"1.22.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-2.0.2\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.12+4\\\\","dependencies":[]}],"android":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-2.0.2\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.12+4\\\\","dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_macos-0.1.0+7\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+11\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]},{"name":"shared_preferences_linux","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_linux-0.0.2+4\\\\","dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.4+3\\\\","dependencies":[]},{"name":"shared_preferences_windows","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_windows-0.0.1+3\\\\","dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_for_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_for_web-0.3.1+4\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+7\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2020-12-27 16:09:17.342761","version":"1.22.5"} \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/full_description.txt b/fastlane/metadata/android/en-US/full_description.txt index bcc4544c..b2e65535 100644 --- a/fastlane/metadata/android/en-US/full_description.txt +++ b/fastlane/metadata/android/en-US/full_description.txt @@ -1,5 +1,4 @@ A simple and fast weather app that uses the OpenWeatherMap API. * Simple design -* Gives the current location's weather * Works with any city in the world \ No newline at end of file diff --git a/lib/screens/location_screen.dart b/lib/screens/location_screen.dart index bd8995d6..67af9222 100644 --- a/lib/screens/location_screen.dart +++ b/lib/screens/location_screen.dart @@ -1,11 +1,9 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:clima/services/location.dart'; import 'package:clima/services/networking.dart'; import 'package:clima/services/weather.dart'; import 'package:clima/utilities/constants.dart'; import 'package:clima/utilities/reusable_widgets.dart'; import 'package:flutter/material.dart'; -import 'package:geolocator/geolocator.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'city_screen.dart'; @@ -41,22 +39,22 @@ class _LocationScreenState extends State { _scaffoldKey.currentState.removeCurrentSnackBar(); final dynamic weatherData = await future; updateUI(weatherData); - } on LocationServicesTurnedOff { - _scaffoldKey.currentState.showSnackBar( - await snackBar( - text: 'Location is turned off.', - action: SnackBarAction( - label: 'Turn on', - onPressed: () async { - await Geolocator.openLocationSettings(); - }, - ), - ), - ); - } on LocationPermissionDenied { - _scaffoldKey.currentState.showSnackBar( - await snackBar(text: 'Permission denied.'), - ); + // } on LocationServicesTurnedOff { + // _scaffoldKey.currentState.showSnackBar( + // await snackBar( + // text: 'Location is turned off.', + // action: SnackBarAction( + // label: 'Turn on', + // onPressed: () async { + // await Geolocator.openLocationSettings(); + // }, + // ), + // ), + // ); + // } on LocationPermissionDenied { + // _scaffoldKey.currentState.showSnackBar( + // await snackBar(text: 'Permission denied.'), + // ); } on NoInternetConnection { _scaffoldKey.currentState.showSnackBar( await snackBar(text: 'No network connection.'), @@ -155,19 +153,19 @@ class _LocationScreenState extends State { ), /// The get current geographic location's weather button. - IconButton( - icon: const Icon(Icons.location_on_outlined), - tooltip: "Get current geographic location's weather", - onPressed: () { - setState(() { - isVisible = true; - }); - errorHandler( - future: weather.getLocationWeather(), - errorMessage: "Can't connect to server.", - ); - }, - ), + // IconButton( + // icon: const Icon(Icons.location_on_outlined), + // tooltip: "Get current geographic location's weather", + // onPressed: () { + // setState(() { + // isVisible = true; + // }); + // errorHandler( + // future: weather.getLocationWeather(), + // errorMessage: "Can't connect to server.", + // ); + // }, + // ), ], ), body: Container( diff --git a/lib/services/location.dart b/lib/services/location.dart index 99188016..2b626970 100644 --- a/lib/services/location.dart +++ b/lib/services/location.dart @@ -1,42 +1,42 @@ -import 'package:geolocator/geolocator.dart'; - -class LocationServicesTurnedOff implements Exception {} - -class LocationPermissionDenied implements Exception {} - -class Location { - double latitude; - double longitude; - - /// This function is responsible to get the latitude and longitude using the Geolocator package. - Future getCurrentLocation() async { - final bool isLocationServiceEnabled = - await Geolocator.isLocationServiceEnabled(); - final LocationPermission permission = await Geolocator.checkPermission(); - if (isLocationServiceEnabled) { - if (permission == LocationPermission.whileInUse || - permission == LocationPermission.always) { - final Position position = await Geolocator.getCurrentPosition( - desiredAccuracy: LocationAccuracy.low); - - latitude = position.latitude; - longitude = position.longitude; - } else if (permission == LocationPermission.denied) { - await Geolocator.requestPermission(); - final LocationPermission permissionAgain = - await Geolocator.checkPermission(); - if (permissionAgain == LocationPermission.denied || - permissionAgain == LocationPermission.deniedForever) { - throw LocationPermissionDenied(); - } else { - await getCurrentLocation(); - } - } else { - await Geolocator.openAppSettings(); - throw LocationPermissionDenied(); - } - } else { - throw LocationServicesTurnedOff(); - } - } -} +// import 'package:geolocator/geolocator.dart'; +// +// class LocationServicesTurnedOff implements Exception {} +// +// class LocationPermissionDenied implements Exception {} +// +// class Location { +// double latitude; +// double longitude; +// +// /// This function is responsible to get the latitude and longitude using the Geolocator package. +// Future getCurrentLocation() async { +// final bool isLocationServiceEnabled = +// await Geolocator.isLocationServiceEnabled(); +// final LocationPermission permission = await Geolocator.checkPermission(); +// if (isLocationServiceEnabled) { +// if (permission == LocationPermission.whileInUse || +// permission == LocationPermission.always) { +// final Position position = await Geolocator.getCurrentPosition( +// desiredAccuracy: LocationAccuracy.low); +// +// latitude = position.latitude; +// longitude = position.longitude; +// } else if (permission == LocationPermission.denied) { +// await Geolocator.requestPermission(); +// final LocationPermission permissionAgain = +// await Geolocator.checkPermission(); +// if (permissionAgain == LocationPermission.denied || +// permissionAgain == LocationPermission.deniedForever) { +// throw LocationPermissionDenied(); +// } else { +// await getCurrentLocation(); +// } +// } else { +// await Geolocator.openAppSettings(); +// throw LocationPermissionDenied(); +// } +// } else { +// throw LocationServicesTurnedOff(); +// } +// } +// } diff --git a/lib/services/weather.dart b/lib/services/weather.dart index e98db38c..10ab8c9f 100644 --- a/lib/services/weather.dart +++ b/lib/services/weather.dart @@ -1,4 +1,3 @@ -import 'package:clima/services/location.dart'; import 'package:clima/services/networking.dart'; const String apiKey = '4bef3adf2fcb90307c2bf5feac75a2ba'; @@ -16,17 +15,17 @@ class WeatherModel { } /// This function gets the weatherData using geographic coordinates. - Future getLocationWeather() async { - final Location location = Location(); - await location.getCurrentLocation(); - - final NetworkHelper networkHelper = NetworkHelper( - '$openWeatherMapURL?lat=${location.latitude}&lon=${location.longitude}&appid=$apiKey&units=metric', - ); - - final dynamic weatherData = await networkHelper.getData(); - return weatherData; - } + // Future getLocationWeather() async { + // final Location location = Location(); + // await location.getCurrentLocation(); + // + // final NetworkHelper networkHelper = NetworkHelper( + // '$openWeatherMapURL?lat=${location.latitude}&lon=${location.longitude}&appid=$apiKey&units=metric', + // ); + // + // final dynamic weatherData = await networkHelper.getData(); + // return weatherData; + // } /// This function returns the right weather icon for the right condition. String getWeatherIcon(int condition) { diff --git a/pubspec.lock b/pubspec.lock index 12154f14..c74200d5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -121,20 +121,6 @@ packages: description: flutter source: sdk version: "0.0.0" - geolocator: - dependency: "direct main" - description: - name: geolocator - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.13" - geolocator_platform_interface: - dependency: transitive - description: - name: geolocator_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.8" http: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index ad513b03..e5d61a57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: clima description: A new Flutter application. -version: 0.1+2 +version: 1.0+1 environment: sdk: ">=2.1.0 <3.0.0" @@ -14,7 +14,6 @@ dependencies: shared_preferences: ^0.5.12+4 connectivity: ^2.0.1 auto_size_text: ^2.1.0 - geolocator: ^6.1.13 http: ^0.12.0+2 flutter_spinkit: ^4.1.2+1 lint: ^1.4.0-dev.d210.1