Skip to content

Commit

Permalink
Merge pull request #4 from Ashutosh4192/check
Browse files Browse the repository at this point in the history
Check
  • Loading branch information
ashutosh-3474 authored Apr 12, 2024
2 parents 1cf2994 + a4f8f84 commit 1d1a343
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 21 deletions.
Binary file added assets/wallpaper/broken_clouds.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/clear_sky.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/few_clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/mist.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/rain.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/scattered_clouds.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/shower_rain.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/snow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wallpaper/thunderstorm.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 36 additions & 11 deletions lib/Pages/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:weather/weather.dart';
import 'package:weather_app/Pages/splash_screen.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
Expand All @@ -25,6 +26,32 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
RefreshController _refreshController =
RefreshController(initialRefresh: false);

String? wallpaper;
String getwallpaper(String des) {
if (des == "clear sky") {
return "assets/wallpaper/clear_sky.jpg";
} else if (des == "few clouds") {
return "assets/wallpaper/few_clouds.png";
} else if (des == "scattered clouds") {
return "assets/wallpaper/scattered_clouds.jpg";
} else if (des == "broken clouds") {
return "assets/wallpaper/broken_clouds.jpg";
} else if (des == "shower rain") {
return "assets/wallpaper/shower_rain.jpg";
} else if (des == "rain") {
return "assets/wallpaper/rain.jpg";
} else if (des == "thunderstrom") {
return "assets/wallpaper/thunderstrom.jpg";
} else if (des == "snow") {
return "assets/wallpaper/snow.jpg";
} else if (des == "mist" || des == "haze") {
return "assets/wallpaper/mist.jpg";
} else {
return "assets/wallpaper/clear_sky.jpg";
}
}

String? weathericon;
String geticon(String des) {
if (des == "clear sky") {
Expand Down Expand Up @@ -59,7 +86,7 @@ class _MyHomePageState extends State<MyHomePage> {
builder: (context) => MyHomePage(
w: w,
location: location,
wf: widget.wf,
wf: widget.wf,
)));
} on OpenWeatherAPIException catch (ex) {
return showDialog(
Expand Down Expand Up @@ -89,15 +116,12 @@ class _MyHomePageState extends State<MyHomePage> {
body: Container(
constraints: BoxConstraints.expand(),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
Colors.lightBlue.shade400,
Colors.purple.shade400,
],
image: DecorationImage(
image: AssetImage(
getwallpaper(widget.w.weatherDescription.toString()),
),
),
fit: BoxFit.cover,
)),
child: Column(
children: [
Padding(
Expand Down Expand Up @@ -136,8 +160,9 @@ class _MyHomePageState extends State<MyHomePage> {
height: 100,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(geticon(
widget.w.weatherDescription.toString())))),
image: AssetImage(
geticon(widget.w.weatherDescription.toString())),
)),
),
Center(
child: Container(
Expand Down
15 changes: 5 additions & 10 deletions lib/Pages/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:location/location.dart';
Location location = new Location();
bool _serviceEnabled = false;
PermissionStatus? _permissionGranted;

//sdfgfgf
Future<dynamic> getLoc() async {
_serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
Expand Down Expand Up @@ -42,15 +42,11 @@ class _SplashScreenState extends State<SplashScreen> {
Weather w;

LocationData _loc = await getLoc();

try {

w = await widget.wf
.currentWeatherByLocation(_loc.latitude!,_loc.longitude!

);


w = await widget.wf
.currentWeatherByLocation(_loc.latitude!, _loc.longitude!);

Navigator.pushReplacement(
context,
MaterialPageRoute(
Expand Down Expand Up @@ -90,7 +86,6 @@ class _SplashScreenState extends State<SplashScreen> {
return Scaffold(
body: Container(
child: Center(child: Lottie.asset("assets/aniamtion/11.json")),

),
);
}
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ flutter:
assets:
- assets/images/
- assets/aniamtion/
- assets/wallpaper/
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

Expand Down

0 comments on commit 1d1a343

Please sign in to comment.