Skip to content

Commit 5eb4c0b

Browse files
committed
Animations TODO completed.
Added Animation support.
1 parent fbd206f commit 5eb4c0b

File tree

4 files changed

+87
-42
lines changed

4 files changed

+87
-42
lines changed

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ SPEC CHECKSUMS:
1515

1616
PODFILE CHECKSUM: 2ec46d3741ab466dee64c9e763366836879c1f6e
1717

18-
COCOAPODS: 1.2.0
18+
COCOAPODS: 1.2.1.beta.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ There is two major version for the app released before.
6363
* App indexing like CoreSpotlight and `NSUserActivity`
6464
* <s>Unit Tests</s>
6565
* UI Tests
66-
* Animations
66+
* <s>Animations</s>
6767

6868
## How to build
6969

SwiftWeather.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@
446446
);
447447
runOnlyForDeploymentPostprocessing = 0;
448448
shellPath = /bin/sh;
449-
shellScript = "diff \"${PODS_ROOT}/../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";
449+
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";
450450
showEnvVarsInLog = 0;
451451
};
452452
3211EE071253F1D6513A17BA /* [CP] Embed Pods Frameworks */ = {
@@ -506,7 +506,7 @@
506506
);
507507
runOnlyForDeploymentPostprocessing = 0;
508508
shellPath = /bin/sh;
509-
shellScript = "diff \"${PODS_ROOT}/../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";
509+
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";
510510
showEnvVarsInLog = 0;
511511
};
512512
ADD0EBFC1C562E52002D8392 /* ShellScript */ = {

SwiftWeather/WeatherViewController.swift

Lines changed: 83 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,90 @@
55

66
import UIKit
77

8+
//MARK: - UIViewController Properties
89
class WeatherViewController: UIViewController {
9-
10-
@IBOutlet weak var locationLabel: UILabel!
11-
@IBOutlet weak var iconLabel: UILabel!
12-
@IBOutlet weak var temperatureLabel: UILabel!
13-
@IBOutlet var forecastViews: [ForecastView]!
14-
15-
override func viewDidLoad() {
16-
super.viewDidLoad()
17-
viewModel = WeatherViewModel()
18-
viewModel?.startLocationService()
19-
}
20-
21-
// MARK: ViewModel
22-
var viewModel: WeatherViewModel? {
23-
didSet {
24-
viewModel?.location.observe {
25-
[unowned self] in
26-
self.locationLabel.text = $0
27-
}
28-
29-
viewModel?.iconText.observe {
30-
[unowned self] in
31-
self.iconLabel.text = $0
32-
}
33-
34-
viewModel?.temperature.observe {
35-
[unowned self] in
36-
self.temperatureLabel.text = $0
37-
}
38-
39-
viewModel?.forecasts.observe {
40-
[unowned self] (forecastViewModels) in
41-
if forecastViewModels.count >= 4 {
42-
for (index, forecastView) in self.forecastViews.enumerated() {
43-
forecastView.loadViewModel(forecastViewModels[index])
44-
}
10+
11+
//MARK: - IBOutlets
12+
@IBOutlet weak var locationLabel: UILabel!
13+
@IBOutlet weak var iconLabel: UILabel!
14+
@IBOutlet weak var temperatureLabel: UILabel!
15+
@IBOutlet var forecastViews: [ForecastView]!
16+
17+
//MARK: - Super Methods
18+
override func viewDidLoad() {
19+
super.viewDidLoad()
20+
viewModel = WeatherViewModel()
21+
viewModel?.startLocationService()
22+
}
23+
24+
override func viewWillAppear(_ animated: Bool) {
25+
super.viewWillAppear(animated)
26+
27+
locationLabel.center.x -= view.bounds.width
28+
iconLabel.center.x -= view.bounds.width
29+
temperatureLabel.center.x -= view.bounds.width
30+
31+
iconLabel.alpha = 0.0
32+
locationLabel.alpha = 0.0
33+
temperatureLabel.alpha = 0.0
34+
}
35+
36+
override func viewDidAppear(_ animated: Bool) {
37+
super.viewDidAppear(animated)
38+
39+
UIView.animate(withDuration: 0.5, animations: {
40+
self.locationLabel.center.x += self.view.bounds.width
41+
})
42+
43+
UIView.animate(withDuration: 0.5, delay: 0.3, usingSpringWithDamping: 0.2, initialSpringVelocity: 0.0, options: [], animations: {
44+
self.iconLabel.center.x += self.view.bounds.width
45+
}, completion: nil)
46+
47+
UIView.animate(withDuration: 0.5, delay: 0.4, usingSpringWithDamping: 0.2, initialSpringVelocity: 0.0, options: [], animations: {
48+
self.temperatureLabel.center.x += self.view.bounds.width
49+
}, completion: nil)
50+
51+
52+
UIView.animate(withDuration: 0.5, delay: 0.3, options: [], animations: {
53+
self.iconLabel.alpha = 1.0
54+
}, completion: nil)
55+
56+
UIView.animate(withDuration: 0.5, delay: 0.4, options: [], animations: {
57+
self.locationLabel.alpha = 1.0
58+
}, completion: nil)
59+
60+
UIView.animate(withDuration: 0.5, delay: 0.5, options: [], animations: {
61+
self.temperatureLabel.alpha = 1.0
62+
}, completion: nil)
63+
64+
}
65+
66+
// MARK: ViewModel
67+
var viewModel: WeatherViewModel? {
68+
didSet {
69+
viewModel?.location.observe {
70+
[unowned self] in
71+
self.locationLabel.text = $0
72+
}
73+
74+
viewModel?.iconText.observe {
75+
[unowned self] in
76+
self.iconLabel.text = $0
77+
}
78+
79+
viewModel?.temperature.observe {
80+
[unowned self] in
81+
self.temperatureLabel.text = $0
82+
}
83+
84+
viewModel?.forecasts.observe {
85+
[unowned self] (forecastViewModels) in
86+
if forecastViewModels.count >= 4 {
87+
for (index, forecastView) in self.forecastViews.enumerated() {
88+
forecastView.loadViewModel(forecastViewModels[index])
89+
}
90+
}
91+
}
4592
}
46-
}
4793
}
48-
}
4994
}

0 commit comments

Comments
 (0)