Merge branch 'feature/3620_launchscreen_animation' into 'develop'

Messenger-3620 launchscreen animation

See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!28
This commit is contained in:
Frank Rotermund
2022-10-18 10:36:49 +00:00
12 changed files with 112 additions and 30 deletions
@@ -19,21 +19,7 @@
<view key="view" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clearsContextBeforeDrawing="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" insetsLayoutMarginsFromSafeArea="NO" image="launch_screen_logo" translatesAutoresizingMaskIntoConstraints="NO" id="IcW-17-3Qq">
<rect key="frame" x="147" y="308" width="120" height="120"/>
<color key="tintColor" red="0.050980392156862744" green="0.74117647058823533" blue="0.54509803921568623" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="IcW-17-3Qq" secondAttribute="height" multiplier="1:1" id="nyP-l5-s1B"/>
<constraint firstAttribute="width" constant="120" id="v1s-rq-3ay"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="IcW-17-3Qq" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="F70-sn-ghB"/>
<constraint firstItem="IcW-17-3Qq" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="nJz-qK-nMP"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -42,7 +28,6 @@
</scene>
</scenes>
<resources>
<image name="launch_screen_logo" width="240" height="240"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="iN0-l3-epB" customClass="LaunchLoadingView" customModule="Riot" customModuleProvider="target">
<view contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="iN0-l3-epB" customClass="LaunchLoadingView" customModule="Element" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
@@ -96,7 +96,6 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
// MARK: - Public
// $$$ must be fixed maybe this does not work
func start() {
// TODO: Manage a separate flow for soft logout that just uses AuthenticationCoordinator
if authenticationService.softLogoutCredentials != nil {
@@ -115,6 +114,8 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
}
} else if BuildSettings.authScreenShowRegister {
showSplashScreen()
} else if BwiBuildSettings.showBUMLottieAnimation {
showBwiSplashScreen()
} else {
showLegacyAuthenticationScreen()
}
@@ -154,7 +155,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
coordinator.start()
add(childCoordinator: coordinator)
self.navigationRouter.setRootModule(coordinator, popCompletion: nil)
self.navigationRouter.setRootModule(coordinator, hideNavigationBar: true, animated: false, popCompletion: nil)
}
/// Displays the next view in the flow after the splash screen.
@@ -162,7 +163,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
// splashScreenResult = result
showLegacyAuthenticationScreen()
}
/// Show an empty screen when configuring soft logout flow
private func showEmptyScreen() {
MXLog.debug("[OnboardingCoordinator] showEmptyScreen")
@@ -287,7 +288,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
coordinator.start()
add(childCoordinator: coordinator)
if navigationRouter.modules.isEmpty || forceAsRootModule {
if navigationRouter.modules.isEmpty || forceAsRootModule || BwiBuildSettings.showBUMLottieAnimation {
navigationRouter.setRootModule(coordinator, popCompletion: nil)
} else {
navigationRouter.push(coordinator, animated: true) { [weak self] in
+1
View File
@@ -45,6 +45,7 @@ targets:
- package: Mapbox
- package: OrderedCollections
- package: SwiftOGG
- package: Lottie
- package: DeviceKit
configFiles:
+1
View File
@@ -45,6 +45,7 @@ targets:
- package: Mapbox
- package: OrderedCollections
- package: SwiftOGG
- package: Lottie
- package: DeviceKit
configFiles:
+1
View File
@@ -42,6 +42,7 @@ targets:
- package: Mapbox
- package: OrderedCollections
- package: SwiftOGG
- package: Lottie
- package: DeviceKit
configFiles:
@@ -26,7 +26,7 @@ final class OnboardingSplashScreenCoordinator: OnboardingSplashScreenCoordinator
// MARK: Private
private let onboardingSplashScreenHostingController: VectorHostingController
private let onboardingSplashScreenHostingController: UIViewController
private var onboardingSplashScreenViewModel: OnboardingSplashScreenViewModelProtocol
private var indicatorPresenter: UserIndicatorTypePresenterProtocol
+3
View File
@@ -121,6 +121,9 @@ final class BwiBuildSettings: NSObject {
// login with matrix id should only be enabled in some configurations
static let bwiEnableLoginWithMatrixID = true
// show app specific loading icons instead of the rotating element logo
static let showBUMLottieAnimation = true
// DMs don't need all roomsettings (like changing avatar, name, topic)
static let showUnrelatedRoomSettingsForDirectMessages = false
@@ -0,0 +1,57 @@
//
/*
* Copyright (c) 2022 BWI GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import UIKit
import Lottie
extension NSNotification.Name {
static let cancelLaunchLoadingAnimation = NSNotification.Name(rawValue: "cancelLaunchLoadingAnimation")
}
class BUMLaunchLoadingViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
let animationView = LottieAnimationView(name: "bum_lottie_animation")
animationView.loopMode = .playOnce
animationView.contentMode = .scaleAspectFit
animationView.play()
view.addSubview(animationView)
animationView.translatesAutoresizingMaskIntoConstraints = false
animationView.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true
animationView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
gestureRecognizer.numberOfTapsRequired = 1
view.addGestureRecognizer(gestureRecognizer)
}
override func viewWillAppear(_ animated: Bool) {
navigationController?.setNavigationBarHidden(true, animated: false)
}
@objc func handleTap(_ sender: UITapGestureRecognizer? = nil) {
NotificationCenter.default.post(name: .cancelLaunchLoadingAnimation, object: nil, userInfo: nil)
}
}
@@ -28,6 +28,7 @@ final class OnboardingBwiSplashScreenCoordinator: OnboardingBwiSplashScreenCoord
private let onboardingSplashScreenHostingController: UIViewController
private var onboardingSplashScreenViewModel: OnboardingBwiSplashScreenViewModelProtocol
private var timer: Timer?
// MARK: Public
@@ -40,20 +41,39 @@ final class OnboardingBwiSplashScreenCoordinator: OnboardingBwiSplashScreenCoord
@available(iOS 14.0, *)
init() {
let viewModel = OnboardingBwiSplashScreenViewModel()
let view = OnboardingBwiSplashScreen(viewModel: viewModel.context)
onboardingSplashScreenViewModel = viewModel
let hostingController = VectorHostingController(rootView: view)
hostingController.vc_removeBackTitle()
onboardingSplashScreenHostingController = hostingController
if BwiBuildSettings.showBUMLottieAnimation {
onboardingSplashScreenHostingController = BUMLaunchLoadingViewController()
} else {
let view = OnboardingBwiSplashScreen(viewModel: viewModel.context)
let hostingController = VectorHostingController(rootView: view)
hostingController.vc_removeBackTitle()
onboardingSplashScreenHostingController = hostingController
}
NotificationCenter.default.addObserver(self, selector: #selector(cancelAnimation(_:)), name: .cancelLaunchLoadingAnimation, object: nil)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
// MARK: - Public
func start() {
onboardingSplashScreenViewModel.completion = { [weak self] result in
guard let self = self else { return }
switch result {
case .login:
self.completion?(result)
if BwiBuildSettings.showBUMLottieAnimation {
timer?.invalidate()
timer = Timer.scheduledTimer(withTimeInterval: 5, repeats: false) { timer in
timer.invalidate()
self.completion?(.login)
}
} else {
onboardingSplashScreenViewModel.completion = { [weak self] result in
guard let self = self else { return }
switch result {
case .login:
self.completion?(result)
}
}
}
}
@@ -61,4 +81,12 @@ final class OnboardingBwiSplashScreenCoordinator: OnboardingBwiSplashScreenCoord
func toPresentable() -> UIViewController {
return self.onboardingSplashScreenHostingController
}
@objc func cancelAnimation(_ sender: UITapGestureRecognizer? = nil) {
timer?.invalidate()
timer = nil
self.completion?(.login)
}
}
+4
View File
@@ -53,6 +53,10 @@ packages:
SwiftOGG:
url: https://github.com/vector-im/swift-ogg
branch: main
Lottie:
url: https://github.com/airbnb/lottie-ios.git
minVersion: 3.5.0
maxVersion: 3.5.0
DeviceKit:
url: https://github.com/devicekit/DeviceKit
majorVersion: 4.7.0