Skip to content

Commit

Permalink
Added Image attributting
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ved committed Jun 17, 2023
1 parent 2a7ef31 commit 6771659
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
14 changes: 13 additions & 1 deletion lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ class HomeScreen extends StatefulWidget {
class _HomeScreenState extends State<HomeScreen> {
late TextEditingController inputController;
late String cityNameInput;
String? locationName, country, description, backgroundImageUrl, airQuality;
String? locationName,
country,
description,
backgroundImageUrl,
airQuality,
imageAttribute;
dynamic temperature,
minTemp,
maxTemp,
Expand All @@ -45,6 +50,7 @@ class _HomeScreenState extends State<HomeScreen> {
CheckCondition(condition: weather['weather'][0]['id']);
weatherIcon = checkCondition.getIcon();
backgroundImageUrl = checkCondition.getBackground();
imageAttribute = checkCondition.getAttribute();
country = weather['sys']['country'];
locationName = weather['name'];
description = weather['weather'][0]['description'];
Expand Down Expand Up @@ -228,6 +234,12 @@ class _HomeScreenState extends State<HomeScreen> {
o3: o3,
airQuality: airQuality,
)),
Text(
"$imageAttribute",
style: const TextStyle(
color: Colors.white,
),
),
],
),
),
Expand Down
21 changes: 20 additions & 1 deletion lib/util/switches.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CheckCondition {
case 2:
return 'assets/thunderstorm.jpg';
case 3:
return 'assets/drizzle.jpg';
return 'assets/rain.jpg';
case 5:
return 'assets/rain.jpg';
case 6:
Expand All @@ -49,4 +49,23 @@ class CheckCondition {
return 'assets/clouds.jpg';
}
}

String getAttribute() {
switch (code) {
case 2:
return 'Image by Gordon Johnson from Pixabay';
case 3:
return 'Image by Amy Art-Dreams from Pixabay';
case 5:
return 'Image by Amy Art-Dreams from Pixabay';
case 6:
return 'Image by Ieva from Pixabay';
case 7:
return 'Image by asrulaqroni on Freepik';
case 8:
return 'Image by coolvector on Freepik';
default:
return 'Image by asrulaqroni on Freepik';
}
}
}

0 comments on commit 6771659

Please sign in to comment.