Enable missing parallax-effect (IOS-134) (#1008)
This commit is contained in:
parent
ba372e9013
commit
21f57d3623
|
@ -13,12 +13,10 @@ import MastodonLocalization
|
||||||
|
|
||||||
fileprivate extension CGFloat {
|
fileprivate extension CGFloat {
|
||||||
static let cloudsStartPosition = -20.0
|
static let cloudsStartPosition = -20.0
|
||||||
|
static let centerHillStartPosition = 20.0
|
||||||
static let airplaneStartPosition = -178.0
|
static let airplaneStartPosition = -178.0
|
||||||
static let leftHillStartPosition = 30.0
|
static let leftHillStartPosition = 30.0
|
||||||
static let rightHillStartPosition = -125.0
|
static let rightHillStartPosition = -125.0
|
||||||
static let leftHillSpeed = 6.0
|
|
||||||
static let centerHillSpeed = 40.0
|
|
||||||
static let rightHillSpeed = 6.0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class WelcomeIllustrationView: UIView {
|
final class WelcomeIllustrationView: UIView {
|
||||||
|
@ -61,7 +59,6 @@ final class WelcomeIllustrationView: UIView {
|
||||||
let imageView = UIImageView(image: Asset.Scene.Welcome.Illustration.cloudBase.image)
|
let imageView = UIImageView(image: Asset.Scene.Welcome.Illustration.cloudBase.image)
|
||||||
imageView.translatesAutoresizingMaskIntoConstraints = false
|
imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
imageView.contentMode = .scaleAspectFill
|
imageView.contentMode = .scaleAspectFill
|
||||||
// imageView.alpha = 0.3
|
|
||||||
return imageView
|
return imageView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -115,9 +112,9 @@ extension WelcomeIllustrationView {
|
||||||
|
|
||||||
addSubview(centerHillImageView)
|
addSubview(centerHillImageView)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
leftAnchor.constraint(equalTo: centerHillImageView.leftAnchor),
|
leftAnchor.constraint(equalTo: centerHillImageView.leftAnchor, constant: .centerHillStartPosition),
|
||||||
bottomAnchor.constraint(equalTo: centerHillImageView.bottomAnchor),
|
bottomAnchor.constraint(equalTo: centerHillImageView.bottomAnchor),
|
||||||
rightAnchor.constraint(equalTo: centerHillImageView.rightAnchor),
|
centerHillImageView.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1.1),
|
||||||
])
|
])
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
|
@ -130,11 +127,6 @@ extension WelcomeIllustrationView {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setup() {
|
func setup() {
|
||||||
|
|
||||||
// set illustration
|
|
||||||
guard superview == nil else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
contentMode = .scaleAspectFit
|
contentMode = .scaleAspectFit
|
||||||
|
|
||||||
cloudBaseImageView.addMotionEffect(
|
cloudBaseImageView.addMotionEffect(
|
||||||
|
|
|
@ -215,25 +215,14 @@ extension WelcomeViewController {
|
||||||
self.navigationItem.leftBarButtonItem = needsShowDismissEntry ? self.dismissBarButtonItem : nil
|
self.navigationItem.leftBarButtonItem = needsShowDismissEntry ? self.dismissBarButtonItem : nil
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
}
|
|
||||||
|
|
||||||
|
setupIllustrationLayout()
|
||||||
override func viewSafeAreaInsetsDidChange() {
|
|
||||||
super.viewSafeAreaInsetsDidChange()
|
|
||||||
|
|
||||||
var overlap: CGFloat = 5
|
|
||||||
// shift illustration down for non-notch phone
|
|
||||||
if view.safeAreaInsets.bottom == 0 {
|
|
||||||
overlap += 56
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
||||||
view.layoutIfNeeded()
|
view.layoutIfNeeded()
|
||||||
|
|
||||||
setupIllustrationLayout()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var computedTopAnchorInset: CGFloat {
|
private var computedTopAnchorInset: CGFloat {
|
||||||
|
|
Loading…
Reference in New Issue