Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Apr 28, 2024
1 parent 1935b24 commit b75972b
Showing 1 changed file with 109 additions and 113 deletions.
222 changes: 109 additions & 113 deletions lib/src/weather/weather_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,116 +191,112 @@ class WeatherModel extends SafeChangeNotifier {
}
}


// TODO: Location services in Ubuntu are very unprecise, disabling for now
// if (cityName == null || _position == null) {
// _position = await _getCurrentPosition();
// if (position != null) {
// _weatherData = await loadWeatherByPosition(
// latitude: position!.latitude,
// longitude: position!.longitude,
// );
// _fiveDaysForCast = await loadForeCastByPosition(
// longitude: position!.longitude,
// latitude: position!.latitude,
// );
// _cityFromPosition = await loadCityFromPosition();
// if (_cityFromPosition != null) {
// _locationsService.setLastLocation(_cityFromPosition);
// _locationsService.addFavLocation(_cityFromPosition!);
// }
// }
// }


// Position? _position;
// Position? get position => _position;


// String? _cityFromPosition;
// String? get cityFromPosition => _cityFromPosition;


// Future<String> loadCityFromPosition() async {
// if (position == null) {
// return '';
// }

// Address address = await _geoCoder.getAddressFromLatLng(
// latitude: _position!.latitude,
// longitude: _position!.longitude,
// );

// return address.displayName;
// }

// Future<List<WeatherData>?> loadForeCastByPosition({
// required double longitude,
// required double latitude,
// }) async {
// try {
// final weatherForecastData =
// (await _openWeather.fiveDaysWeatherForecastByLocation(
// longitude: longitude,
// latitude: latitude,
// weatherUnits: WeatherUnits.METRIC,
// ));

// return weatherForecastData.forecastData;
// } on Exception catch (e) {
// error = e.toString();
// return null;
// }
// }

// Future<WeatherData?> loadWeatherByPosition({
// required double latitude,
// required double longitude,
// }) async {
// try {
// final weatherData = await _openWeather.currentWeatherByLocation(
// latitude: latitude,
// longitude: longitude,
// weatherUnits: WeatherUnits.METRIC,
// );
// return weatherData;
// } on Exception catch (e) {
// error = e.toString();
// return null;
// }
// }

// Future<Position?> _getCurrentPosition() async {
// final hasPermission = await _handlePermission();

// if (!hasPermission) {
// return null;
// }

// final position = await _geolocatorPlatform.getCurrentPosition();
// return position;
// }

// Future<bool> _handlePermission() async {
// bool serviceEnabled;
// LocationPermission permission;

// serviceEnabled = await _geolocatorPlatform.isLocationServiceEnabled();
// if (!serviceEnabled) {
// return false;
// }

// permission = await _geolocatorPlatform.checkPermission();
// if (permission == LocationPermission.denied) {
// permission = await _geolocatorPlatform.requestPermission();
// if (permission == LocationPermission.denied) {
// return false;
// }
// }

// if (permission == LocationPermission.deniedForever) {
// return false;
// }

// return true;
// }
// TODO: Location services in Ubuntu are very unprecise, disabling for now
// if (cityName == null || _position == null) {
// _position = await _getCurrentPosition();
// if (position != null) {
// _weatherData = await loadWeatherByPosition(
// latitude: position!.latitude,
// longitude: position!.longitude,
// );
// _fiveDaysForCast = await loadForeCastByPosition(
// longitude: position!.longitude,
// latitude: position!.latitude,
// );
// _cityFromPosition = await loadCityFromPosition();
// if (_cityFromPosition != null) {
// _locationsService.setLastLocation(_cityFromPosition);
// _locationsService.addFavLocation(_cityFromPosition!);
// }
// }
// }

// Position? _position;
// Position? get position => _position;

// String? _cityFromPosition;
// String? get cityFromPosition => _cityFromPosition;

// Future<String> loadCityFromPosition() async {
// if (position == null) {
// return '';
// }

// Address address = await _geoCoder.getAddressFromLatLng(
// latitude: _position!.latitude,
// longitude: _position!.longitude,
// );

// return address.displayName;
// }

// Future<List<WeatherData>?> loadForeCastByPosition({
// required double longitude,
// required double latitude,
// }) async {
// try {
// final weatherForecastData =
// (await _openWeather.fiveDaysWeatherForecastByLocation(
// longitude: longitude,
// latitude: latitude,
// weatherUnits: WeatherUnits.METRIC,
// ));

// return weatherForecastData.forecastData;
// } on Exception catch (e) {
// error = e.toString();
// return null;
// }
// }

// Future<WeatherData?> loadWeatherByPosition({
// required double latitude,
// required double longitude,
// }) async {
// try {
// final weatherData = await _openWeather.currentWeatherByLocation(
// latitude: latitude,
// longitude: longitude,
// weatherUnits: WeatherUnits.METRIC,
// );
// return weatherData;
// } on Exception catch (e) {
// error = e.toString();
// return null;
// }
// }

// Future<Position?> _getCurrentPosition() async {
// final hasPermission = await _handlePermission();

// if (!hasPermission) {
// return null;
// }

// final position = await _geolocatorPlatform.getCurrentPosition();
// return position;
// }

// Future<bool> _handlePermission() async {
// bool serviceEnabled;
// LocationPermission permission;

// serviceEnabled = await _geolocatorPlatform.isLocationServiceEnabled();
// if (!serviceEnabled) {
// return false;
// }

// permission = await _geolocatorPlatform.checkPermission();
// if (permission == LocationPermission.denied) {
// permission = await _geolocatorPlatform.requestPermission();
// if (permission == LocationPermission.denied) {
// return false;
// }
// }

// if (permission == LocationPermission.deniedForever) {
// return false;
// }

// return true;
// }

0 comments on commit b75972b

Please sign in to comment.