Skip to content

Commit 9e68f25

Browse files
committed
Update the launch animation with an activity indicator
1 parent 2ce8978 commit 9e68f25

File tree

5 files changed

+77
-24
lines changed

5 files changed

+77
-24
lines changed
1.01 KB
Loading

iCookTV/Base.lproj/Localizable.strings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Copyright © 2016 Polydice, Inc. All rights reserved.
77
*/
88

9-
"Tagline" = "icook.tw";
9+
"Upper tagline" = "icook.tw";
10+
11+
"Lower tagline" = "";
1012

1113
"\nContact [email protected] for support." = "Please contact us at [email protected] if this issue keeps happening.";

iCookTV/LaunchViewController.swift

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,79 @@ class LaunchViewController: UIViewController {
3737
return _imageView
3838
}()
3939

40-
private lazy var taglineLabel: UILabel = {
41-
let _label = UILabel()
42-
_label.font = UIFont.tvFontForTagline()
43-
_label.textColor = UIColor.tvTaglineColor()
44-
_label.text = "Tagline".localizedString
45-
_label.textAlignment = .Center
46-
_label.numberOfLines = 0
47-
_label.alpha = 0
48-
return _label
40+
private lazy var activityIndicator: UIActivityIndicatorView = {
41+
let _indicator = UIActivityIndicatorView(activityIndicatorStyle: .WhiteLarge)
42+
_indicator.color = UIColor.Palette.GreyishBrown
43+
_indicator.hidesWhenStopped = true
44+
return _indicator
4945
}()
5046

51-
private var taglineConstraint: NSLayoutConstraint?
47+
private lazy var upperTaglineLabel: UILabel = {
48+
let _upper = UILabel.taglineLabel()
49+
_upper.text = "Upper tagline".localizedString
50+
return _upper
51+
}()
52+
53+
private lazy var lowerTaglineLabel: UILabel = {
54+
let _lower = UILabel.taglineLabel()
55+
_lower.text = "Lower tagline".localizedString
56+
return _lower
57+
}()
58+
59+
private var upperTaglineConstraint: NSLayoutConstraint?
60+
private var lowerTaglineConstraint: NSLayoutConstraint?
5261

5362
// MARK: - UIViewController
5463

5564
override func loadView() {
5665
super.loadView()
5766
view.backgroundColor = UIColor.tvBackgroundColor()
5867
view.addSubview(loadingImageView)
59-
view.addSubview(taglineLabel)
68+
view.addSubview(activityIndicator)
69+
view.addSubview(upperTaglineLabel)
70+
view.addSubview(lowerTaglineLabel)
6071

6172
loadingImageView.translatesAutoresizingMaskIntoConstraints = false
62-
taglineLabel.translatesAutoresizingMaskIntoConstraints = false
73+
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
74+
upperTaglineLabel.translatesAutoresizingMaskIntoConstraints = false
75+
lowerTaglineLabel.translatesAutoresizingMaskIntoConstraints = false
6376

6477
loadingImageView.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
65-
loadingImageView.centerYAnchor.constraintEqualToAnchor(view.centerYAnchor, constant: -45).active = true
78+
loadingImageView.bottomAnchor.constraintEqualToAnchor(view.centerYAnchor, constant: 50).active = true
79+
80+
activityIndicator.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor, constant: 5).active = true
81+
activityIndicator.topAnchor.constraintEqualToAnchor(loadingImageView.bottomAnchor, constant: 60).active = true
6682

67-
taglineConstraint = taglineLabel.topAnchor.constraintEqualToAnchor(loadingImageView.bottomAnchor, constant: 100)
68-
taglineConstraint?.active = true
69-
taglineLabel.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
83+
upperTaglineConstraint = upperTaglineLabel.topAnchor.constraintEqualToAnchor(activityIndicator.bottomAnchor, constant: 100)
84+
upperTaglineConstraint?.active = true
85+
upperTaglineLabel.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
86+
87+
lowerTaglineConstraint = lowerTaglineLabel.topAnchor.constraintEqualToAnchor(upperTaglineLabel.bottomAnchor, constant: 100)
88+
lowerTaglineConstraint?.active = true
89+
lowerTaglineLabel.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
7090
}
7191

7292
override func viewDidLoad() {
7393
super.viewDidLoad()
94+
activityIndicator.startAnimating()
7495
fetchCategories()
7596
}
7697

7798
override func viewDidAppear(animated: Bool) {
7899
super.viewDidAppear(animated)
79-
UIView.animateWithDuration(0.5) {
80-
self.taglineLabel.alpha = 1
81-
self.taglineConstraint?.constant = 50
82-
self.view.layoutIfNeeded()
83-
}
100+
101+
UIView.animateKeyframesWithDuration(0.9, delay: 0, options: [], animations: {
102+
UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 0.6) {
103+
self.upperTaglineLabel.alpha = 1
104+
self.upperTaglineConstraint?.constant = 40
105+
self.view.layoutIfNeeded()
106+
}
107+
UIView.addKeyframeWithRelativeStartTime(0.2, relativeDuration: 0.7) {
108+
self.lowerTaglineLabel.alpha = 1
109+
self.lowerTaglineConstraint?.constant = 0
110+
self.view.layoutIfNeeded()
111+
}
112+
}, completion: nil)
84113
}
85114

86115
// MARK: - Private Methods
@@ -104,3 +133,21 @@ class LaunchViewController: UIViewController {
104133
}
105134

106135
}
136+
137+
138+
////////////////////////////////////////////////////////////////////////////////
139+
140+
141+
private extension UILabel {
142+
143+
private class func taglineLabel() -> UILabel {
144+
let label = UILabel()
145+
label.font = UIFont.tvFontForTagline()
146+
label.textColor = UIColor.tvTaglineColor()
147+
label.textAlignment = .Center
148+
label.numberOfLines = 0
149+
label.alpha = 0
150+
return label
151+
}
152+
153+
}

iCookTV/en.lproj/Localizable.strings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Copyright © 2016 Polydice, Inc. All rights reserved.
77
*/
88

9-
"Tagline" = "icook.tw";
9+
"Upper tagline" = "icook.tw";
10+
11+
"Lower tagline" = "";
1012

1113
"\nContact [email protected] for support." = "Please contact us at [email protected] if this issue keeps happening.";

iCookTV/zh-Hant.lproj/Localizable.strings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
"Home" = "首頁";
1414

15-
"Tagline" = "愛料理食譜社群\nicook.tw";
15+
"Upper tagline" = "愛料理食譜社群";
16+
17+
"Lower tagline" = "icook.tw";
1618

1719
"You haven't watched any video." = "先看些影片吧!";
1820

0 commit comments

Comments
 (0)