deep-linking-sample/Apps/Wikipedia/Wikipedia/Code/WMFWelcomeAnimationViewControllers.swift
Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

102 lines
3.0 KiB
Swift

class WMFWelcomeAnimationViewController: ThemeableViewController {
var welcomePageType:WMFWelcomePageType = .intro
private var hasAlreadyAnimated = false
private(set) var animationView: WMFWelcomeAnimationView? = nil
override func viewDidLoad() {
super.viewDidLoad()
guard let animationView = animationView else {
return
}
view.wmf_addSubviewWithConstraintsToEdges(animationView)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if !hasAlreadyAnimated {
guard let animationView = animationView else {
return
}
animationView.beginAnimations()
}
hasAlreadyAnimated = true
}
override func apply(theme: Theme) {
super.apply(theme: theme)
guard viewIfLoaded != nil else {
return
}
animationView?.apply(theme: theme)
}
}
class WMFWelcomeAnimationForgroundViewController: WMFWelcomeAnimationViewController {
override var animationView: WMFWelcomeAnimationView? {
return animationViewForWelcomePageType
}
private lazy var animationViewForWelcomePageType: WMFWelcomeAnimationView? = {
switch welcomePageType {
case .intro:
return WMFWelcomeIntroductionAnimationView()
case .exploration:
return WMFWelcomeExplorationAnimationView()
case .languages:
return WMFWelcomeLanguagesAnimationView()
case .analytics:
return WMFWelcomeAnalyticsAnimationView()
}
}()
override func viewDidLoad() {
super.viewDidLoad()
guard let animationView = animationView else {
return
}
switch welcomePageType {
case .exploration:
fallthrough
case .languages:
fallthrough
case .analytics:
animationView.hasCircleBackground = true
default:
break
}
}
}
class WMFWelcomeAnimationBackgroundViewController: WMFWelcomeAnimationViewController {
override var animationView: WMFWelcomeAnimationView? {
return animationViewForWelcomePageType
}
private lazy var animationViewForWelcomePageType: WMFWelcomeAnimationView? = {
switch welcomePageType {
case .intro:
return nil
case .exploration:
return WMFWelcomeExplorationAnimationBackgroundView()
case .languages:
return WMFWelcomeLanguagesAnimationBackgroundView()
case .analytics:
return WMFWelcomeAnalyticsAnimationBackgroundView()
}
}()
override func viewDidLoad() {
super.viewDidLoad()
view.wmf_addHorizontalAndVerticalParallax(amount: 12)
}
override func apply(theme: Theme) {
super.apply(theme: theme)
guard viewIfLoaded != nil else {
return
}
view.backgroundColor = theme.colors.paperBackground
}
}