Skip to content

First Commit #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
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
36 changes: 20 additions & 16 deletions Clima.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
objects = {

/* Begin PBXBuildFile section */
18EE1B9E2BBC028F00F5C30D /* WeatherManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EE1B9D2BBC028F00F5C30D /* WeatherManager.swift */; };
18EE1BA02BBC0CAF00F5C30D /* WeatherData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EE1B9F2BBC0CAF00F5C30D /* WeatherData.swift */; };
18EE1BA22BBC2CD800F5C30D /* weatherModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EE1BA12BBC2CD800F5C30D /* weatherModel.swift */; };
ADAA27B1231BBFAF00365194 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADAA27B0231BBFAF00365194 /* AppDelegate.swift */; };
ADAA27B3231BBFAF00365194 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */; };
ADAA27B5231BBFAF00365194 /* WeatherViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADAA27B4231BBFAF00365194 /* WeatherViewController.swift */; };
ADAA27B8231BBFAF00365194 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ADAA27B6231BBFAF00365194 /* Main.storyboard */; };
ADAA27BA231BBFB300365194 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ADAA27B9231BBFB300365194 /* Assets.xcassets */; };
ADAA27BD231BBFB300365194 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ADAA27BB231BBFB300365194 /* LaunchScreen.storyboard */; };
ADAA27C6231BC02C00365194 /* light_background.pdf in Resources */ = {isa = PBXBuildFile; fileRef = ADAA27C4231BC02B00365194 /* light_background.pdf */; };
ADAA27C7231BC02C00365194 /* dark_background.pdf in Resources */ = {isa = PBXBuildFile; fileRef = ADAA27C5231BC02B00365194 /* dark_background.pdf */; };
ADAA27CE231BC87F00365194 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = ADAA27CD231BC87F00365194 /* README.md */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
18EE1B9D2BBC028F00F5C30D /* WeatherManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherManager.swift; sourceTree = "<group>"; };
18EE1B9F2BBC0CAF00F5C30D /* WeatherData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherData.swift; sourceTree = "<group>"; };
18EE1BA12BBC2CD800F5C30D /* weatherModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = weatherModel.swift; sourceTree = "<group>"; };
ADAA27AD231BBFAF00365194 /* Clima.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Clima.app; sourceTree = BUILT_PRODUCTS_DIR; };
ADAA27B0231BBFAF00365194 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -27,8 +31,6 @@
ADAA27B9231BBFB300365194 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
ADAA27BC231BBFB300365194 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
ADAA27BE231BBFB300365194 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
ADAA27C4231BC02B00365194 /* light_background.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = light_background.pdf; sourceTree = "<group>"; };
ADAA27C5231BC02B00365194 /* dark_background.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = dark_background.pdf; sourceTree = "<group>"; };
ADAA27CD231BC87F00365194 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -43,6 +45,16 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
18EE1B9C2BBC027B00F5C30D /* model */ = {
isa = PBXGroup;
children = (
18EE1B9D2BBC028F00F5C30D /* WeatherManager.swift */,
18EE1B9F2BBC0CAF00F5C30D /* WeatherData.swift */,
18EE1BA12BBC2CD800F5C30D /* weatherModel.swift */,
);
path = model;
sourceTree = "<group>";
};
ADAA27A4231BBFAF00365194 = {
isa = PBXGroup;
children = (
Expand All @@ -63,16 +75,14 @@
ADAA27AF231BBFAF00365194 /* Clima */ = {
isa = PBXGroup;
children = (
18EE1B9C2BBC027B00F5C30D /* model */,
ADAA27B0231BBFAF00365194 /* AppDelegate.swift */,
ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */,
ADAA27CA231BC3FA00365194 /* Model */,
ADAA27C9231BC3F200365194 /* View */,
ADAA27C8231BC3E500365194 /* Controller */,
ADAA27B9231BBFB300365194 /* Assets.xcassets */,
ADAA27BB231BBFB300365194 /* LaunchScreen.storyboard */,
ADAA27BE231BBFB300365194 /* Info.plist */,
ADAA27C5231BC02B00365194 /* dark_background.pdf */,
ADAA27C4231BC02B00365194 /* light_background.pdf */,
);
path = Clima;
sourceTree = "<group>";
Expand All @@ -93,13 +103,6 @@
path = View;
sourceTree = "<group>";
};
ADAA27CA231BC3FA00365194 /* Model */ = {
isa = PBXGroup;
children = (
);
path = Model;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -159,11 +162,9 @@
buildActionMask = 2147483647;
files = (
ADAA27CE231BC87F00365194 /* README.md in Resources */,
ADAA27C7231BC02C00365194 /* dark_background.pdf in Resources */,
ADAA27BD231BBFB300365194 /* LaunchScreen.storyboard in Resources */,
ADAA27BA231BBFB300365194 /* Assets.xcassets in Resources */,
ADAA27B8231BBFAF00365194 /* Main.storyboard in Resources */,
ADAA27C6231BC02C00365194 /* light_background.pdf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -175,7 +176,10 @@
buildActionMask = 2147483647;
files = (
ADAA27B5231BBFAF00365194 /* WeatherViewController.swift in Sources */,
18EE1BA02BBC0CAF00F5C30D /* WeatherData.swift in Sources */,
ADAA27B1231BBFAF00365194 /* AppDelegate.swift in Sources */,
18EE1B9E2BBC028F00F5C30D /* WeatherManager.swift in Sources */,
18EE1BA22BBC2CD800F5C30D /* weatherModel.swift in Sources */,
ADAA27B3231BBFAF00365194 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Clima.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
34 changes: 24 additions & 10 deletions Clima/Assets.xcassets/background.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "background.png",
"scale" : "1x"
"filename" : "light_background.pdf",
"idiom" : "universal"
},
{
"idiom" : "universal",
"scale" : "2x"
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"filename" : "light_background 1.pdf",
"idiom" : "universal"
},
{
"idiom" : "universal",
"scale" : "3x"
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "dark_background.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
}
Binary file not shown.
File renamed without changes.
Binary file not shown.
58 changes: 52 additions & 6 deletions Clima/Controller/WeatherViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,64 @@
//

import UIKit
import CoreLocation

class WeatherViewController: UIViewController {

class WeatherViewController: UIViewController, UITextFieldDelegate, WeatherManagerDelegate {


@IBOutlet weak var conditionImageView: UIImageView!
@IBOutlet weak var temperatureLabel: UILabel!
@IBOutlet weak var cityLabel: UILabel!
@IBOutlet weak var searchTextField: UITextField!
var weatherManager = WeatherManager()
let locationManager = CLLocationManager()

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
weatherManager.delegate = self
searchTextField.delegate = self

}



@IBAction func searchPressed(_ sender: UIButton) {
print(searchTextField.text!)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
searchTextField.endEditing(true)
print(searchTextField.text!)
return true
}
func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
if textField.text != ""{
return true
} else{
textField.placeholder = "Type Something"
return false
}

}
func textFieldDidEndEditing(_ textField: UITextField) {
if let city = searchTextField.text{
weatherManager.FetchWeather(cityName: city)

}
searchTextField.text = ""
}

func didUpdateWeather(_ weatherManager: WeatherManager, weather: WeatherModel){
print(weather.tempertureString)
DispatchQueue.main.async {
self.temperatureLabel.text = weather.tempertureString
self.cityLabel.text = weather.cityName
self.conditionImageView.image = UIImage(systemName: weather.conditionName)
}




}
func didFailWithError(error: Error) {
print(error)
}

}

2 changes: 2 additions & 0 deletions Clima/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Clime need to your location for show weather data never you</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
Loading