Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit #1 #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/Screens/homeScreen.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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';
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';
Expand All @@ -26,6 +26,7 @@ class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();
_getData();
}

@override
Expand Down Expand Up @@ -53,7 +54,7 @@ class _HomeScreenState extends State<HomeScreen> {

return SafeArea(
child: Scaffold(
body: true
body: _isLoading
? Center(
child: CircularProgressIndicator(
backgroundColor: myContext.primaryColor,
Expand All @@ -67,7 +68,7 @@ class _HomeScreenState extends State<HomeScreen> {
)
: weatherData.isLocationError
? LocationError()
: Stack(
: Column(
children: [
SearchBar(),
SmoothPageIndicator(
Expand Down
26 changes: 16 additions & 10 deletions lib/Screens/hourlyWeatherScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class HourlyScreen extends StatelessWidget {
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
hours ?? '',
Expand All @@ -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),
),
],
),
],
),
Expand Down
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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,
),
Expand Down
1 change: 0 additions & 1 deletion lib/models/weather.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Weather with ChangeNotifier {
});

factory Weather.fromJson(Map<String, dynamic> json) {
return Weather();
return Weather(
temp: json['main']['temp'],
tempMax: json['main']['temp_max'],
Expand Down
20 changes: 10 additions & 10 deletions lib/provider/weatherProvider.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 =
Expand Down Expand Up @@ -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<String, dynamic>;
Expand All @@ -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<String, dynamic>;
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/WeatherInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/hourlyForecast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/sevenDayForecast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SevenDayForecast extends StatelessWidget {
SizedBox(height: 15),
Expanded(
child: ListView(
scrollDirection: Axis.vertical,
scrollDirection: Axis.horizontal,
children: [
Row(
children: dWeather
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/weatherDetail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
Expand Down
35 changes: 14 additions & 21 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
14 changes: 7 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down