From 6481ec579c5a2c6ae197f579c3351c92deb91324 Mon Sep 17 00:00:00 2001 From: nugaa Date: Sat, 20 Mar 2021 11:38:28 +0000 Subject: [PATCH] Commit #1 --- lib/Screens/homeScreen.dart | 9 +++---- lib/Screens/hourlyWeatherScreen.dart | 26 +++++++++++++-------- lib/main.dart | 6 ++--- lib/models/weather.dart | 1 - lib/provider/weatherProvider.dart | 20 ++++++++-------- lib/widgets/WeatherInfo.dart | 2 +- lib/widgets/hourlyForecast.dart | 3 ++- lib/widgets/sevenDayForecast.dart | 2 +- lib/widgets/weatherDetail.dart | 2 +- pubspec.lock | 35 +++++++++++----------------- pubspec.yaml | 14 +++++------ 11 files changed, 60 insertions(+), 60 deletions(-) diff --git a/lib/Screens/homeScreen.dart b/lib/Screens/homeScreen.dart index 57a850f..c3e92cf 100644 --- a/lib/Screens/homeScreen.dart +++ b/lib/Screens/homeScreen.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../provider/weatherProvider.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; +import '../provider/weatherProvider.dart'; import '../widgets/WeatherInfo.dart'; import '../widgets/fadeIn.dart'; import '../widgets/hourlyForecast.dart'; @@ -10,8 +10,8 @@ import '../widgets/locationError.dart'; import '../widgets/mainWeather.dart'; import '../widgets/requestError.dart'; import '../widgets/searchBar.dart'; -import '../widgets/weatherDetail.dart'; import '../widgets/sevenDayForecast.dart'; +import '../widgets/weatherDetail.dart'; class HomeScreen extends StatefulWidget { static const routeName = '/homeScreen'; @@ -26,6 +26,7 @@ class _HomeScreenState extends State { @override void initState() { super.initState(); + _getData(); } @override @@ -53,7 +54,7 @@ class _HomeScreenState extends State { return SafeArea( child: Scaffold( - body: true + body: _isLoading ? Center( child: CircularProgressIndicator( backgroundColor: myContext.primaryColor, @@ -67,7 +68,7 @@ class _HomeScreenState extends State { ) : weatherData.isLocationError ? LocationError() - : Stack( + : Column( children: [ SearchBar(), SmoothPageIndicator( diff --git a/lib/Screens/hourlyWeatherScreen.dart b/lib/Screens/hourlyWeatherScreen.dart index 21d3468..11442bf 100644 --- a/lib/Screens/hourlyWeatherScreen.dart +++ b/lib/Screens/hourlyWeatherScreen.dart @@ -26,6 +26,7 @@ class HourlyScreen extends StatelessWidget { ], ), child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( hours ?? '', @@ -35,16 +36,21 @@ class HourlyScreen extends StatelessWidget { fontWeight: FontWeight.w400, ), ), - Text( - '${weather.dailyTemp.toStringAsFixed(1)}°', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w400, - ), - ), - Padding( - padding: const EdgeInsets.only(left: 15, bottom: 15), - child: MapString.mapStringToIcon(weather.condition, context, 25), + Row( + children: [ + Text( + '${weather.dailyTemp.toStringAsFixed(1)}°', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), + Padding( + padding: const EdgeInsets.only(left: 15, bottom: 15), + child: + MapString.mapStringToIcon(weather.condition, context, 25), + ), + ], ), ], ), diff --git a/lib/main.dart b/lib/main.dart index 636ac8b..1c71cd0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,15 +2,15 @@ import 'package:feep_competition2021/Screens/hourlyWeatherScreen.dart'; import 'package:feep_competition2021/Screens/weeklyWeatherScreen.dart'; import 'package:feep_competition2021/provider/weatherProvider.dart'; import 'package:flutter/material.dart'; +import 'package:logger/logger.dart'; import 'package:provider/provider.dart'; import 'Screens/homeScreen.dart'; -import 'package:logger/logger.dart'; var logger = Logger(); var config = { - 'OpenWeatherApiKey': 'fdb61777bda2658e2b20d16554abc84a', + 'OpenWeatherApiKey': '8b555328cd72a4d8abeb070e965abfc5', }; void main() { @@ -35,7 +35,7 @@ class MyApp extends StatelessWidget { elevation: 0, ), scaffoldBackgroundColor: Colors.white, - primaryColor: Colors.green, + primaryColor: Colors.blue, accentColor: Colors.white, visualDensity: VisualDensity.adaptivePlatformDensity, ), diff --git a/lib/models/weather.dart b/lib/models/weather.dart index b442a25..0835c3b 100644 --- a/lib/models/weather.dart +++ b/lib/models/weather.dart @@ -30,7 +30,6 @@ class Weather with ChangeNotifier { }); factory Weather.fromJson(Map json) { - return Weather(); return Weather( temp: json['main']['temp'], tempMax: json['main']['temp_max'], diff --git a/lib/provider/weatherProvider.dart b/lib/provider/weatherProvider.dart index 28258c7..7fa9b12 100644 --- a/lib/provider/weatherProvider.dart +++ b/lib/provider/weatherProvider.dart @@ -1,8 +1,8 @@ +import 'dart:convert'; + import 'package:feep_competition2021/models/dailyWeather.dart'; import 'package:flutter/material.dart'; - import 'package:http/http.dart' as http; -import 'dart:convert'; import 'package:location/location.dart'; import '../main.dart'; @@ -29,10 +29,10 @@ class WeatherProvider with ChangeNotifier { final locData = await Location().getLocation(); var latitude = locData.latitude; var longitude = locData.longitude; - var url = - 'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&units=metric&appid=$apiKey'; - var dailyUrl = - 'https://api.openweathermap.org/data/2.5/onecall?lat=$latitude&lon=$longitude&units=metric&exclude=minutely,current&appid=$apiKey'; + var url = Uri.parse( + 'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&units=metric&appid=$apiKey'); + var dailyUrl = Uri.parse( + 'https://api.openweathermap.org/data/2.5/onecall?lat=$latitude&lon=$longitude&units=metric&exclude=minutely,current&appid=$apiKey'); try { final response = await http.get(url); final extractedData = @@ -94,8 +94,8 @@ class WeatherProvider with ChangeNotifier { isRequestError = false; isLocationError = false; - var url = - 'https://api.openweathermap.org/data/2.5/weather?q=$location&units=metric&appid=$apiKey'; + var url = Uri.parse( + 'https://api.openweathermap.org/data/2.5/weather?q=$location&units=metric&appid=$apiKey'); try { final response = await http.get(url); final extractedData = json.decode(response.body) as Map; @@ -110,8 +110,8 @@ class WeatherProvider with ChangeNotifier { var longitude = weather.long; print(latitude); print(longitude); - var dailyUrl = - 'https://api.openweathermap.org/data/2.5/onecall?lat=$latitude&lon=$longitude&units=metric&exclude=minutely,current&appid=$apiKey'; + var dailyUrl = Uri.parse( + 'https://api.openweathermap.org/data/2.5/onecall?lat=$latitude&lon=$longitude&units=metric&exclude=minutely,current&appid=$apiKey'); try { final response = await http.get(dailyUrl); final dailyData = json.decode(response.body) as Map; diff --git a/lib/widgets/WeatherInfo.dart b/lib/widgets/WeatherInfo.dart index 7254455..ed6479a 100644 --- a/lib/widgets/WeatherInfo.dart +++ b/lib/widgets/WeatherInfo.dart @@ -17,7 +17,7 @@ class WeatherInfo extends StatelessWidget { padding: EdgeInsets.only(bottom: 15, right: rightPad), child: Icon( icon, - color: Colors.green, + color: Colors.blue, size: iconSize, ), ), diff --git a/lib/widgets/hourlyForecast.dart b/lib/widgets/hourlyForecast.dart index 8a51eee..2c44be4 100644 --- a/lib/widgets/hourlyForecast.dart +++ b/lib/widgets/hourlyForecast.dart @@ -2,6 +2,7 @@ import 'package:feep_competition2021/Screens/hourlyWeatherScreen.dart'; import 'package:feep_competition2021/models/dailyWeather.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; + import '../helper/utils.dart'; class HourlyForecast extends StatelessWidget { @@ -93,7 +94,7 @@ class HourlyForecast extends StatelessWidget { TextButton( child: Text( 'See More', - style: TextStyle(color: Colors.green), + style: TextStyle(color: Colors.blue), ), onPressed: () { Navigator.of(context).pushNamed(HourlyScreen.routeName); diff --git a/lib/widgets/sevenDayForecast.dart b/lib/widgets/sevenDayForecast.dart index 34c4b5f..a3a30d3 100644 --- a/lib/widgets/sevenDayForecast.dart +++ b/lib/widgets/sevenDayForecast.dart @@ -106,7 +106,7 @@ class SevenDayForecast extends StatelessWidget { SizedBox(height: 15), Expanded( child: ListView( - scrollDirection: Axis.vertical, + scrollDirection: Axis.horizontal, children: [ Row( children: dWeather diff --git a/lib/widgets/weatherDetail.dart b/lib/widgets/weatherDetail.dart index 92fc40b..875eb94 100644 --- a/lib/widgets/weatherDetail.dart +++ b/lib/widgets/weatherDetail.dart @@ -28,7 +28,7 @@ class WeatherDetail extends StatelessWidget { padding: const EdgeInsets.only(bottom: 15, right: 5), child: Icon( icon, - color: Colors.green, + color: Colors.blue, size: 35, ), ), diff --git a/pubspec.lock b/pubspec.lock index fae9c43..4f098bd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -85,21 +85,21 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" intl: dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" js: dependency: transitive description: @@ -113,28 +113,28 @@ packages: name: location url: "https://pub.dartlang.org" source: hosted - version: "3.2.4" + version: "4.1.1" location_platform_interface: dependency: transitive description: name: location_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.1.0" location_web: dependency: transitive description: name: location_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "3.0.0" logger: dependency: "direct main" description: name: logger url: "https://pub.dartlang.org" source: hosted - version: "0.9.4" + version: "1.0.0" matcher: dependency: transitive description: @@ -176,28 +176,21 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.3" - sa_v1_migration: - dependency: transitive - description: - name: sa_v1_migration - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" + version: "5.0.0" simple_animations: dependency: "direct main" description: name: simple_animations url: "https://pub.dartlang.org" source: hosted - version: "2.5.1" + version: "3.0.3" sky_engine: dependency: transitive description: flutter @@ -244,14 +237,14 @@ packages: name: supercharged url: "https://pub.dartlang.org" source: hosted - version: "1.12.0" + version: "2.0.0" supercharged_dart: dependency: transitive description: name: supercharged_dart url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "2.0.0" term_glyph: dependency: transitive description: @@ -281,5 +274,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" - flutter: ">=1.16.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3e9a109..e1affa6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,18 +9,18 @@ environment: sdk: ">=2.7.0 <3.0.0" dependencies: - logger: ^0.9.4 + logger: ^1.0.0 flutter: sdk: flutter cupertino_icons: ^1.0.0 - http: ^0.12.2 - intl: ^0.16.1 - provider: ^4.3.3 - location: ^3.0.0 - supercharged: ^1.12.0 + http: ^0.13.1 + intl: ^0.17.0 + provider: ^5.0.0 + location: ^4.1.1 + supercharged: ^2.0.0 flutter_weather_icons: ^1.0.2 smooth_page_indicator: ^0.2.0 - simple_animations: ^2.5.1 + simple_animations: ^3.0.3 dev_dependencies: