diff --git a/lib/screens/home.dart b/lib/screens/home.dart index fa623f0..8973ce2 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -19,7 +19,12 @@ class HomeScreen extends StatefulWidget { class _HomeScreenState extends State { late TextEditingController inputController; late String cityNameInput; - String? locationName, country, description, backgroundImageUrl, airQuality; + String? locationName, + country, + description, + backgroundImageUrl, + airQuality, + imageAttribute; dynamic temperature, minTemp, maxTemp, @@ -45,6 +50,7 @@ class _HomeScreenState extends State { 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']; @@ -228,6 +234,12 @@ class _HomeScreenState extends State { o3: o3, airQuality: airQuality, )), + Text( + "$imageAttribute", + style: const TextStyle( + color: Colors.white, + ), + ), ], ), ), diff --git a/lib/util/switches.dart b/lib/util/switches.dart index 7a14c4d..956f3da 100644 --- a/lib/util/switches.dart +++ b/lib/util/switches.dart @@ -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: @@ -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'; + } + } }