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

[Challenge]: Fix issues #7

Open
wants to merge 12 commits 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
18 changes: 11 additions & 7 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
include ':app'

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
68 changes: 68 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
9985CEAEBE16AE0D25737B44 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63D9C26AEF524410E483D1D5 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -29,9 +30,11 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0EC74BF8ED8859F82C674713 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
63D9C26AEF524410E483D1D5 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand All @@ -42,19 +45,41 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AD262D8317B0459D8DDC94B0 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
E7EB12E104E98696079B1A19 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9985CEAEBE16AE0D25737B44 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3003D846E30BD3C7B0CD8E4B /* Frameworks */ = {
isa = PBXGroup;
children = (
63D9C26AEF524410E483D1D5 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
52E43011FD2E054158EF61CE /* Pods */ = {
isa = PBXGroup;
children = (
AD262D8317B0459D8DDC94B0 /* Pods-Runner.debug.xcconfig */,
E7EB12E104E98696079B1A19 /* Pods-Runner.release.xcconfig */,
0EC74BF8ED8859F82C674713 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
Expand All @@ -72,6 +97,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
52E43011FD2E054158EF61CE /* Pods */,
3003D846E30BD3C7B0CD8E4B /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -105,12 +132,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
2BC1B98943CABA2040336670 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
1AF5985B47F0AA2BFEF5ED2C /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -169,6 +198,45 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1AF5985B47F0AA2BFEF5ED2C /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
2BC1B98943CABA2040336670 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
3 changes: 3 additions & 0 deletions ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location in the background.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when open and in the background.</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
16 changes: 4 additions & 12 deletions lib/Screens/homeScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class HomeScreen extends StatefulWidget {

class _HomeScreenState extends State<HomeScreen> {
PageController _pageController = PageController();
bool _isLoading;

@override
void initState() {
super.initState();
_getData();
}

@override
Expand All @@ -35,10 +35,8 @@ class _HomeScreenState extends State<HomeScreen> {
}

Future<void> _getData() async {
_isLoading = true;
final weatherData = Provider.of<WeatherProvider>(context, listen: false);
weatherData.getWeatherData();
_isLoading = false;
}

Future<void> _refreshData(BuildContext context) async {
Expand All @@ -53,21 +51,15 @@ class _HomeScreenState extends State<HomeScreen> {

return SafeArea(
child: Scaffold(
body: true
? Center(
child: CircularProgressIndicator(
backgroundColor: myContext.primaryColor,
),
)
: weatherData.loading
body: weatherData.loading
? Center(
child: CircularProgressIndicator(
backgroundColor: myContext.primaryColor,
),
)
: weatherData.isLocationError
? LocationError()
: Stack(
: Column(
children: [
SearchBar(),
SmoothPageIndicator(
Expand All @@ -91,7 +83,7 @@ class _HomeScreenState extends State<HomeScreen> {
child: RefreshIndicator(
onRefresh: () =>
_refreshData(context),
backgroundColor: Colors.blue,
backgroundColor: myContext.primaryColor,
child: ListView(
children: [
FadeIn(
Expand Down
25 changes: 15 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,20 @@ 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, 35),
),
],
),
],
),
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': 'ea43c1109bc0f41d9bc4859aa2090a30',
};

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
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 @@ -7,7 +7,7 @@ class WeatherInfo extends StatelessWidget {
WeatherInfo({this.wData});

Widget _weatherInfoBuilder(String header, String body, IconData icon,
double rightPad, double iconSize) {
double rightPad, double iconSize, Color color) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
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 @@ -71,6 +72,7 @@ class WeatherInfo extends StatelessWidget {
WeatherIcons.wiRaindrops,
0,
50,
myContext.primaryColor
),
),
VerticalDivider(
Expand All @@ -85,6 +87,7 @@ class WeatherInfo extends StatelessWidget {
WeatherIcons.wiDaySunny,
15,
30,
myContext.primaryColor
),
),
],
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/hourlyForecast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ 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 +95,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
Loading