Skip to content

Commit 5afa068

Browse files
author
Giorgio Ruscigno
committed
Update JetpackPrologueViewController, add feature flagged logic to replace the existing prologue with the new Jetpack prologue screen
1 parent eb54078 commit 5afa068

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

WordPress/Jetpack/Classes/NUX/JetpackPrologueViewController.swift

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ class JetpackPrologueViewController: UIViewController {
1818
// Start color is the background color with no alpha because if we use clear it will fade to black
1919
// instead of just disappearing
2020
let startColor = JetpackPrologueStyleGuide.backgroundColor.withAlphaComponent(0)
21+
let midTopColor = JetpackPrologueStyleGuide.backgroundColor.withAlphaComponent(0.9)
22+
let midBottomColor = JetpackPrologueStyleGuide.backgroundColor.withAlphaComponent(0.2)
2123
let endColor = JetpackPrologueStyleGuide.backgroundColor
2224

23-
gradientLayer.colors = [startColor.cgColor, endColor.cgColor]
24-
gradientLayer.locations = [0.0, 0.9]
25+
gradientLayer.colors = FeatureFlag.newLandingScreen.enabled ?
26+
[endColor.cgColor, midTopColor.cgColor, midBottomColor.cgColor, startColor.cgColor] :
27+
[startColor.cgColor, endColor.cgColor]
28+
29+
gradientLayer.locations = FeatureFlag.newLandingScreen.enabled ? [0.0, 0.2, 0.5, 1.0] : [0.0, 0.9]
2530

2631
return gradientLayer
2732
}()
@@ -30,20 +35,39 @@ class JetpackPrologueViewController: UIViewController {
3035
super.viewDidLoad()
3136

3237
view.backgroundColor = JetpackPrologueStyleGuide.backgroundColor
33-
view.addSubview(starFieldView)
38+
if FeatureFlag.newLandingScreen.enabled {
39+
let viewModel = JetpackPromptsViewModel()
40+
let jetpackAnimatedView = UIView.embedSwiftUIView(JetpackLandingScreenView(viewModel: viewModel))
41+
view.addSubview(jetpackAnimatedView)
42+
view.pinSubviewToAllEdges(jetpackAnimatedView)
43+
} else {
44+
view.addSubview(starFieldView)
45+
}
3446
view.layer.addSublayer(gradientLayer)
35-
36-
titleLabel.text = NSLocalizedString("Site security and performance\nfrom your pocket", comment: "Prologue title label, the \n force splits it into 2 lines.")
37-
titleLabel.textColor = JetpackPrologueStyleGuide.Title.textColor
38-
titleLabel.font = JetpackPrologueStyleGuide.Title.font
39-
47+
if FeatureFlag.newLandingScreen.enabled {
48+
stackView.isHidden = true
49+
titleLabel.isHidden = true
50+
let logoImageView = UIImageView(image: UIImage(named: "jetpack-logo"))
51+
logoImageView.translatesAutoresizingMaskIntoConstraints = false
52+
view.addSubview(logoImageView)
53+
NSLayoutConstraint.activate([
54+
logoImageView.widthAnchor.constraint(equalToConstant: 72),
55+
logoImageView.heightAnchor.constraint(equalTo: logoImageView.widthAnchor),
56+
logoImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
57+
logoImageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 72)
58+
])
59+
} else {
60+
titleLabel.text = NSLocalizedString("Site security and performance\nfrom your pocket", comment: "Prologue title label, the \n force splits it into 2 lines.")
61+
titleLabel.textColor = JetpackPrologueStyleGuide.Title.textColor
62+
titleLabel.font = JetpackPrologueStyleGuide.Title.font
63+
}
4064
// Move the layers to appear below everything else
41-
starFieldView.layer.zPosition = Constants.starLayerPosition
42-
gradientLayer.zPosition = Constants.gradientLayerPosition
43-
44-
addParallax()
45-
46-
updateLabel(for: traitCollection)
65+
if !FeatureFlag.newLandingScreen.enabled {
66+
starFieldView.layer.zPosition = Constants.starLayerPosition
67+
gradientLayer.zPosition = Constants.gradientLayerPosition
68+
addParallax()
69+
updateLabel(for: traitCollection)
70+
}
4771
}
4872

4973
func updateLabel(for traitCollection: UITraitCollection) {
@@ -56,14 +80,15 @@ class JetpackPrologueViewController: UIViewController {
5680

5781
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
5882
super.traitCollectionDidChange(previousTraitCollection)
59-
83+
guard !FeatureFlag.newLandingScreen.enabled else { return }
6084
updateLabel(for: traitCollection)
6185
}
6286

6387
override func viewDidLayoutSubviews() {
6488
super.viewDidLayoutSubviews()
65-
66-
starFieldView.frame = view.bounds
89+
if !FeatureFlag.newLandingScreen.enabled {
90+
starFieldView.frame = view.bounds
91+
}
6792
gradientLayer.frame = view.bounds
6893
}
6994

0 commit comments

Comments
 (0)