diff --git a/android/gradle.properties b/android/gradle.properties index 94adc3a..a673820 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true +android.enableR8=true diff --git a/lib/Screens/homeScreen.dart b/lib/Screens/homeScreen.dart index 57a850f..22362ae 100644 --- a/lib/Screens/homeScreen.dart +++ b/lib/Screens/homeScreen.dart @@ -26,6 +26,7 @@ class _HomeScreenState extends State { @override void initState() { super.initState(); + _getData(); } @override @@ -52,93 +53,97 @@ class _HomeScreenState extends State { final mediaQuery = MediaQuery.of(context); return SafeArea( - child: Scaffold( - body: true + child: Consumer( + builder: (BuildContext context, WeatherProvider value, Widget child) { + return Scaffold( + body: + weatherData.loading ? Center( - child: CircularProgressIndicator( - backgroundColor: myContext.primaryColor, + child: CircularProgressIndicator( + backgroundColor: myContext.primaryColor, + ), + ) + : weatherData.isLocationError + ? LocationError() + : Stack( + children: [ + Column( + children: [ + SearchBar(), + SmoothPageIndicator( + controller: _pageController, + count: 2, + effect: ExpandingDotsEffect( + activeDotColor: myContext.primaryColor, + dotHeight: 6, + dotWidth: 6, + ), ), - ) - : weatherData.loading - ? Center( - child: CircularProgressIndicator( - backgroundColor: myContext.primaryColor, - ), - ) - : weatherData.isLocationError - ? LocationError() - : Stack( - children: [ - SearchBar(), - SmoothPageIndicator( - controller: _pageController, - count: 2, - effect: ExpandingDotsEffect( - activeDotColor: myContext.primaryColor, - dotHeight: 6, - dotWidth: 6, - ), + weatherData.isRequestError + ? RequestError() + : Expanded( + child: PageView( + controller: _pageController, + children: [ + Container( + padding: const EdgeInsets.all(10), + width: mediaQuery.size.width, + child: RefreshIndicator( + onRefresh: () => + _refreshData(context), + backgroundColor: Colors.blue, + child: ListView( + children: [ + FadeIn( + delay: 0, + child: MainWeather( + wData: weatherData)), + FadeIn( + delay: 0.33, + child: WeatherInfo( + wData: weatherData + .currentWeather), + ), + FadeIn( + delay: 0.66, + child: HourlyForecast( + weatherData.hourlyWeather), + ), + ], ), - weatherData.isRequestError - ? RequestError() - : Expanded( - child: PageView( - controller: _pageController, - children: [ - Container( - padding: const EdgeInsets.all(10), - width: mediaQuery.size.width, - child: RefreshIndicator( - onRefresh: () => - _refreshData(context), - backgroundColor: Colors.blue, - child: ListView( - children: [ - FadeIn( - delay: 0, - child: MainWeather( - wData: weatherData)), - FadeIn( - delay: 0.33, - child: WeatherInfo( - wData: weatherData - .currentWeather), - ), - FadeIn( - delay: 0.66, - child: HourlyForecast( - weatherData.hourlyWeather), - ), - ], - ), - ), - ), - Container( - height: mediaQuery.size.height, - width: mediaQuery.size.width, - child: ListView( - children: [ - FadeIn( - delay: 0.33, - child: SevenDayForecast( - wData: weatherData, - dWeather: - weatherData.sevenDayWeather, - ), - ), - FadeIn( - delay: 0.66, - child: WeatherDetail( - wData: weatherData)), - ], - ), - ), - ], - ), - ), - ], + ), + ), + Container( + height: mediaQuery.size.height, + width: mediaQuery.size.width, + child: ListView( + children: [ + FadeIn( + delay: 0.33, + child: SevenDayForecast( + wData: weatherData, + dWeather: + weatherData.sevenDayWeather, + ), + ), + FadeIn( + delay: 0.66, + child: WeatherDetail( + wData: weatherData)), + ], + ), ), - ), - ); + ], + ), + ),], + ), + + + ], + ), + ); + } + + )); } } diff --git a/lib/Screens/hourlyWeatherScreen.dart b/lib/Screens/hourlyWeatherScreen.dart index 21d3468..a57793d 100644 --- a/lib/Screens/hourlyWeatherScreen.dart +++ b/lib/Screens/hourlyWeatherScreen.dart @@ -35,6 +35,7 @@ class HourlyScreen extends StatelessWidget { fontWeight: FontWeight.w400, ), ), + Spacer(flex: 1), Text( '${weather.dailyTemp.toStringAsFixed(1)}°', style: TextStyle( diff --git a/lib/main.dart b/lib/main.dart index 636ac8b..a9c3e0d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,7 +10,7 @@ import 'package:logger/logger.dart'; var logger = Logger(); var config = { - 'OpenWeatherApiKey': 'fdb61777bda2658e2b20d16554abc84a', + 'OpenWeatherApiKey': '1052b4f753b364740d9482c50881076d', }; 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..b273c99 100644 --- a/lib/models/weather.dart +++ b/lib/models/weather.dart @@ -30,7 +30,7 @@ class Weather with ChangeNotifier { }); factory Weather.fromJson(Map json) { - return Weather(); + //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..48d306d 100644 --- a/lib/provider/weatherProvider.dart +++ b/lib/provider/weatherProvider.dart @@ -16,7 +16,7 @@ class WeatherProvider with ChangeNotifier { List hourly24Weather = []; List fiveDayWeather = []; List sevenDayWeather = []; - bool loading; + bool loading = true; bool isRequestError = false; bool isLocationError = false; diff --git a/lib/widgets/WeatherInfo.dart b/lib/widgets/WeatherInfo.dart index 7254455..2476936 100644 --- a/lib/widgets/WeatherInfo.dart +++ b/lib/widgets/WeatherInfo.dart @@ -6,7 +6,7 @@ class WeatherInfo extends StatelessWidget { final wData; WeatherInfo({this.wData}); - Widget _weatherInfoBuilder(String header, String body, IconData icon, + Widget _weatherInfoBuilder(color, String header, String body, IconData icon, double rightPad, double iconSize) { return Container( padding: EdgeInsets.symmetric(horizontal: 15), @@ -17,7 +17,7 @@ class WeatherInfo extends StatelessWidget { padding: EdgeInsets.only(bottom: 15, right: rightPad), child: Icon( icon, - color: Colors.green, + color: color, size: iconSize, ), ), @@ -46,6 +46,7 @@ class WeatherInfo extends StatelessWidget { @override Widget build(BuildContext context) { + final myContext = Theme.of(context); return Container( padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20), height: MediaQuery.of(context).size.height / 6, @@ -66,6 +67,7 @@ class WeatherInfo extends StatelessWidget { children: [ SizedBox( child: _weatherInfoBuilder( + myContext.primaryColor, 'Precipitation', '${wData.precip}%', WeatherIcons.wiRaindrops, @@ -80,6 +82,7 @@ class WeatherInfo extends StatelessWidget { ), SizedBox( child: _weatherInfoBuilder( + myContext.primaryColor, 'UV Index', UvIndex.mapUviValueToString(uvi: wData.uvi), WeatherIcons.wiDaySunny, diff --git a/lib/widgets/hourlyForecast.dart b/lib/widgets/hourlyForecast.dart index 8a51eee..63c4e75 100644 --- a/lib/widgets/hourlyForecast.dart +++ b/lib/widgets/hourlyForecast.dart @@ -71,6 +71,7 @@ class HourlyForecast extends StatelessWidget { @override Widget build(BuildContext context) { + final myContext = Theme.of(context); return Container( margin: EdgeInsets.symmetric(horizontal: 15), width: MediaQuery.of(context).size.width, @@ -93,7 +94,7 @@ class HourlyForecast extends StatelessWidget { TextButton( child: Text( 'See More', - style: TextStyle(color: Colors.green), + style: TextStyle(color: myContext.primaryColor), ), 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..41a93c1 100644 --- a/lib/widgets/weatherDetail.dart +++ b/lib/widgets/weatherDetail.dart @@ -6,7 +6,7 @@ class WeatherDetail extends StatelessWidget { WeatherDetail({this.wData}); - Widget _gridWeatherBuilder(String header, String body, IconData icon) { + Widget _gridWeatherBuilder(String header, String body, IconData icon, color) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), @@ -28,7 +28,7 @@ class WeatherDetail extends StatelessWidget { padding: const EdgeInsets.only(bottom: 15, right: 5), child: Icon( icon, - color: Colors.green, + color: color, size: 35, ), ), @@ -61,6 +61,7 @@ class WeatherDetail extends StatelessWidget { @override Widget build(BuildContext context) { + final myContext = Theme.of(context); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -87,15 +88,15 @@ class WeatherDetail extends StatelessWidget { ), children: [ _gridWeatherBuilder('${wData.weather.humidity}%', 'Humidity', - WeatherIcons.wiRaindrop), + WeatherIcons.wiRaindrop, myContext.primaryColor), _gridWeatherBuilder('${wData.weather.windSpeed} km/h', 'Wind', - WeatherIcons.wiStrongWind), + WeatherIcons.wiStrongWind, myContext.primaryColor), _gridWeatherBuilder( '${wData.weather.feelsLike.toStringAsFixed(1)}°C', 'Feels Like', - WeatherIcons.wiCelsius), + WeatherIcons.wiCelsius, myContext.primaryColor), _gridWeatherBuilder('${wData.weather.pressure} hPa', 'Pressure', - WeatherIcons.wiBarometer), + WeatherIcons.wiBarometer, myContext.primaryColor), ], ), ), diff --git a/pubspec.lock b/pubspec.lock index fae9c43..d036093 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,56 +7,56 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.15.0-nullsafety.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -106,7 +106,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.2" location: dependency: "direct main" description: @@ -141,35 +141,35 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.0-nullsafety.3" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "0.0.4" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.0-nullsafety.1" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.9.2" plugin_platform_interface: dependency: transitive description: @@ -216,28 +216,28 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.0-nullsafety.1" supercharged: dependency: "direct main" description: @@ -258,28 +258,28 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.12.0-0.0 <3.0.0" - flutter: ">=1.16.0" + dart: ">=2.10.0-110 <2.11.0" + flutter: ">=1.16.0 <2.0.0"