Skip to content

Commit 4cae26d

Browse files
authored
Merge pull request #61 from durul/master
Animations TODO completed.
2 parents fbd206f + cf7c807 commit 4cae26d

File tree

5 files changed

+81
-21
lines changed

5 files changed

+81
-21
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ There is two major version for the app released before.
6060
* Core Location
6161

6262
## TODO
63-
* App indexing like CoreSpotlight and `NSUserActivity`
63+
* <s>App indexing like CoreSpotlight and `NSUserActivity`</s>
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/AppDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
1716
func application(_ application: UIApplication,
1817
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1918
// Override point for customization after application launch.
@@ -51,5 +50,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5150
// applicationDidEnterBackground:.
5251
}
5352

54-
5553
}

SwiftWeather/WeatherViewController.swift

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,108 @@
44
//
55

66
import UIKit
7+
import CoreSpotlight
8+
import MobileCoreServices
79

10+
//MARK: - UIViewController Properties
811
class WeatherViewController: UIViewController {
912

13+
//MARK: - IBOutlets
1014
@IBOutlet weak var locationLabel: UILabel!
1115
@IBOutlet weak var iconLabel: UILabel!
1216
@IBOutlet weak var temperatureLabel: UILabel!
1317
@IBOutlet var forecastViews: [ForecastView]!
1418

19+
let identifier = "WeatherIdentifier"
20+
21+
//MARK: - Super Methods
1522
override func viewDidLoad() {
1623
super.viewDidLoad()
1724
viewModel = WeatherViewModel()
1825
viewModel?.startLocationService()
1926
}
2027

28+
override func viewWillAppear(_ animated: Bool) {
29+
super.viewWillAppear(animated)
30+
31+
locationLabel.center.x -= view.bounds.width
32+
iconLabel.center.x -= view.bounds.width
33+
temperatureLabel.center.x -= view.bounds.width
34+
35+
iconLabel.alpha = 0.0
36+
locationLabel.alpha = 0.0
37+
temperatureLabel.alpha = 0.0
38+
}
39+
40+
override func viewDidAppear(_ animated: Bool) {
41+
super.viewDidAppear(animated)
42+
43+
UIView.animate(withDuration: 0.5, animations: {
44+
self.locationLabel.center.x += self.view.bounds.width
45+
})
46+
47+
UIView.animate(withDuration: 0.5, delay: 0.3, usingSpringWithDamping: 0.2, initialSpringVelocity: 0.0, options: [], animations: {
48+
self.iconLabel.center.x += self.view.bounds.width
49+
}, completion: nil)
50+
51+
UIView.animate(withDuration: 0.5, delay: 0.4, usingSpringWithDamping: 0.2, initialSpringVelocity: 0.0, options: [], animations: {
52+
self.temperatureLabel.center.x += self.view.bounds.width
53+
}, completion: nil)
54+
55+
56+
UIView.animate(withDuration: 0.5, delay: 0.3, options: [], animations: {
57+
self.iconLabel.alpha = 1.0
58+
}, completion: nil)
59+
60+
UIView.animate(withDuration: 0.5, delay: 0.4, options: [], animations: {
61+
self.locationLabel.alpha = 1.0
62+
}, completion: nil)
63+
64+
UIView.animate(withDuration: 0.5, delay: 0.5, options: [], animations: {
65+
self.temperatureLabel.alpha = 1.0
66+
}, completion: nil)
67+
68+
}
69+
70+
2171
// MARK: ViewModel
2272
var viewModel: WeatherViewModel? {
2373
didSet {
24-
viewModel?.location.observe {
74+
viewModel?.location.observe {
2575
[unowned self] in
2676
self.locationLabel.text = $0
27-
}
28-
29-
viewModel?.iconText.observe {
77+
78+
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeText as String)
79+
attributeSet.title = self.locationLabel.text
80+
81+
let item = CSSearchableItem(uniqueIdentifier: self.identifier, domainIdentifier: "com.rushjet.SwiftWeather", attributeSet: attributeSet)
82+
CSSearchableIndex.default().indexSearchableItems([item]){error in
83+
if let error = error {
84+
print("Indexing error: \(error.localizedDescription)")
85+
} else {
86+
print("Location item successfully indexed")
87+
}
88+
}
89+
}
90+
91+
viewModel?.iconText.observe {
3092
[unowned self] in
3193
self.iconLabel.text = $0
32-
}
33-
34-
viewModel?.temperature.observe {
94+
}
95+
96+
viewModel?.temperature.observe {
3597
[unowned self] in
3698
self.temperatureLabel.text = $0
37-
}
38-
39-
viewModel?.forecasts.observe {
99+
}
100+
101+
viewModel?.forecasts.observe {
40102
[unowned self] (forecastViewModels) in
41103
if forecastViewModels.count >= 4 {
42-
for (index, forecastView) in self.forecastViews.enumerated() {
43-
forecastView.loadViewModel(forecastViewModels[index])
44-
}
104+
for (index, forecastView) in self.forecastViews.enumerated() {
105+
forecastView.loadViewModel(forecastViewModels[index])
106+
}
107+
}
45108
}
46109
}
47110
}
48111
}
49-
}

0 commit comments

Comments
 (0)