Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
Add Walhalla & Modify UI
Browse files Browse the repository at this point in the history
  • Loading branch information
knchst0704 committed Dec 24, 2015
1 parent 038808a commit 087abbd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions GoodWeather/Classes/Controller/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit
import MapKit
import Walhalla

class ViewController: UIViewController, CLLocationManagerDelegate, UITableViewDataSource, UITableViewDelegate {

Expand All @@ -21,6 +22,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate, UITableViewDa
@IBOutlet weak var backgroundImageView: UIImageView!

var manager: CLLocationManager!
var indicator: UIActivityIndicatorView!

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -41,6 +43,10 @@ class ViewController: UIViewController, CLLocationManagerDelegate, UITableViewDa
imageView.tintColor = .whiteColor()

backgroundImageView.image = Utility.makeGradient(self.view.frame)

indicator = UIActivityIndicatorView(activityIndicatorStyle: .Gray)
indicator.center = self.view.center
self.view.addSubview(indicator)
}

override func didReceiveMemoryWarning() {
Expand Down Expand Up @@ -84,14 +90,19 @@ class ViewController: UIViewController, CLLocationManagerDelegate, UITableViewDa

func refreshWeather(lat: Double, lon: Double) {

indicator.startAnimating()

weak var weakSelf = self

ModelManager.sharedInstance.getDailyWeather(lat, lon: lon, callback: {(error) in
if error == nil {
weakSelf?.tableView.reloadData()
weakSelf?.indicator.stopAnimating()
} else {
print(error)

weakSelf?.indicator.stopAnimating()

let alert = UIAlertController(title: "Error", message: "Oops! Please try again!!", preferredStyle: .Alert)
let retryAction = UIAlertAction(title: "Try Again!", style: .Default, handler: { action in
weakSelf?.manager.requestLocation()
Expand All @@ -111,6 +122,12 @@ class ViewController: UIViewController, CLLocationManagerDelegate, UITableViewDa
weakSelf?.maxLabel.text = String(format: "%g°", (weather?.temp_max)!)
weakSelf?.imageView.image = UIImage(named: (weather?.main)!)?.imageWithRenderingMode(.AlwaysTemplate)
weakSelf?.descriptionLabel.text = weather?.description!

Walhalla.performAnimation((weakSelf?.nameLabel)!, duration: 1.0, delay: 0, type: .FadeIn)
Walhalla.performAnimation((weakSelf?.minLabel)!, duration: 1.0, delay: 0, type: .FadeIn)
Walhalla.performAnimation((weakSelf?.maxLabel)!, duration: 1.0, delay: 0, type: .FadeIn)
Walhalla.performAnimation((weakSelf?.imageView)!, duration: 1.0, delay: 0, type: .FadeIn)
Walhalla.performAnimation((weakSelf?.descriptionLabel)!, duration: 1.0, delay: 0, type: .FadeIn)
} else {
print(error)
// show alert
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use_frameworks!

target 'GoodWeather' do
pod 'MisterFusion'
pod 'Walhalla'
pod 'SwiftyJSON'
pod 'Alamofire'
end
Expand Down
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- Alamofire (3.1.3)
- MisterFusion (0.6.0)
- SwiftyJSON (2.3.1)
- Walhalla (0.1.0)

DEPENDENCIES:
- Alamofire
- MisterFusion
- SwiftyJSON
- Walhalla

SPEC CHECKSUMS:
Alamofire: 9f93b56389e48def9220dd57d1f44b1927229a5a
MisterFusion: 4c0bed7dcee6f2d86f9900a1963a46ce4ec989b8
SwiftyJSON: 592b53bee5ef3dd9b3bebc6b9cb7ee35426ae8c3
Walhalla: 6d93769dec99c188bd4112f8cb1857dd2a874bc4

COCOAPODS: 0.39.0

0 comments on commit 087abbd

Please sign in to comment.