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

Correções #2

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
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
173 changes: 89 additions & 84 deletions lib/Screens/homeScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();
_getData();
}

@override
Expand All @@ -52,93 +53,97 @@ class _HomeScreenState extends State<HomeScreen> {
final mediaQuery = MediaQuery.of(context);

return SafeArea(
child: Scaffold(
body: true
child: Consumer<WeatherProvider>(
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)),
],
),
),
),
);
],
),
),],
),


],
),
);
}

));
}
}
1 change: 1 addition & 0 deletions lib/Screens/hourlyWeatherScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class HourlyScreen extends StatelessWidget {
fontWeight: FontWeight.w400,
),
),
Spacer(flex: 1),
Text(
'${weather.dailyTemp.toStringAsFixed(1)}°',
style: TextStyle(
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:logger/logger.dart';
var logger = Logger();

var config = {
'OpenWeatherApiKey': 'fdb61777bda2658e2b20d16554abc84a',
'OpenWeatherApiKey': '1052b4f753b364740d9482c50881076d',
};

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
2 changes: 1 addition & 1 deletion lib/models/weather.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Weather with ChangeNotifier {
});

factory Weather.fromJson(Map<String, dynamic> json) {
return Weather();
//return Weather();
return Weather(
temp: json['main']['temp'],
tempMax: json['main']['temp_max'],
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/weatherProvider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WeatherProvider with ChangeNotifier {
List<DailyWeather> hourly24Weather = [];
List<DailyWeather> fiveDayWeather = [];
List<DailyWeather> sevenDayWeather = [];
bool loading;
bool loading = true;
bool isRequestError = false;
bool isLocationError = false;

Expand Down
7 changes: 5 additions & 2 deletions lib/widgets/WeatherInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
),
),
Expand Down Expand Up @@ -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,
Expand All @@ -66,6 +67,7 @@ class WeatherInfo extends StatelessWidget {
children: [
SizedBox(
child: _weatherInfoBuilder(
myContext.primaryColor,
'Precipitation',
'${wData.precip}%',
WeatherIcons.wiRaindrops,
Expand All @@ -80,6 +82,7 @@ class WeatherInfo extends StatelessWidget {
),
SizedBox(
child: _weatherInfoBuilder(
myContext.primaryColor,
'UV Index',
UvIndex.mapUviValueToString(uvi: wData.uvi),
WeatherIcons.wiDaySunny,
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/hourlyForecast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
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
13 changes: 7 additions & 6 deletions lib/widgets/weatherDetail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
),
),
Expand Down Expand Up @@ -61,6 +61,7 @@ class WeatherDetail extends StatelessWidget {

@override
Widget build(BuildContext context) {
final myContext = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand All @@ -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),
],
),
),
Expand Down
Loading