Skip to content
Snippets Groups Projects
Commit ab702a51 authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Fix missing success screen on onboarding

parent 20d8acac
No related branches found
No related tags found
1 merge request!95Fix missing success screen on onboarding
...@@ -110,6 +110,9 @@ extension NavigatorKey: DependencyKey { ...@@ -110,6 +110,9 @@ extension NavigatorKey: DependencyKey {
PresentOnboardingEmailNavigator( PresentOnboardingEmailNavigator(
OnboardingEmailController.init OnboardingEmailController.init
), ),
PresentOnboardingSuccessNavigator(
OnboardingSuccessController.init(_:)
),
PresentOnboardingPhoneNavigator( PresentOnboardingPhoneNavigator(
OnboardingPhoneController.init OnboardingPhoneController.init
), ),
......
import UIKit
/// Sets `OnboardingSuccess` on a given navigation controller stack
public struct PresentOnboardingSuccess: Action {
/// - Parameters:
/// - isEmail: Flag to differentiate email from phone number
/// - navigationController: Navigation controller on which stack should be set
/// - animated: Animate the transition
public init(
isEmail: Bool,
on navigationController: UINavigationController,
animated: Bool = true
) {
self.isEmail = isEmail
self.navigationController = navigationController
self.animated = animated
}
/// Flag to differentiate email from phone number
public var isEmail: Bool
/// Navigation controller on which stack should be set
public var navigationController: UINavigationController
/// Animate the transition
public var animated: Bool
}
/// Performs `PresentOnboardingSuccess` action
public struct PresentOnboardingSuccessNavigator: TypedNavigator {
/// View controller which should be set in navigation stack
var viewController: (Bool) -> UIViewController
/// - Parameters:
/// - viewController: View controller which should be set in navigation stack
public init(_ viewController: @escaping (Bool) -> UIViewController) {
self.viewController = viewController
}
public func perform(_ action: PresentOnboardingSuccess, completion: @escaping () -> Void) {
let target = viewController(action.isEmail)
action.navigationController.setViewControllers([target], animated: action.animated)
if action.animated, let coordinator = action.navigationController.transitionCoordinator {
coordinator.animate(alongsideTransition: nil, completion: { _ in completion() })
} else {
completion()
}
}
}
...@@ -864,8 +864,10 @@ ...@@ -864,8 +864,10 @@
= "Your #email# has been successfully #added#."; = "Your #email# has been successfully #added#.";
"onboarding.success.phone.title" "onboarding.success.phone.title"
= "Your #phone# has been successfully #added#."; = "Your #phone# has been successfully #added#.";
"onboarding.success.action" "onboarding.success.action.next"
= "Next"; = "Next";
"onboarding.success.action.done"
= "Done";
// OnboardingFeature - Start // OnboardingFeature - Start
......
...@@ -791,8 +791,12 @@ public enum Localized { ...@@ -791,8 +791,12 @@ public enum Localized {
public static let title = Localized.tr("Localizable", "onboarding.start.title") public static let title = Localized.tr("Localizable", "onboarding.start.title")
} }
public enum Success { public enum Success {
public enum Action {
/// Done
public static let done = Localized.tr("Localizable", "onboarding.success.action.done")
/// Next /// Next
public static let action = Localized.tr("Localizable", "onboarding.success.action") public static let next = Localized.tr("Localizable", "onboarding.success.action.next")
}
public enum Email { public enum Email {
/// Your #email# has been successfully #added#. /// Your #email# has been successfully #added#.
public static let title = Localized.tr("Localizable", "onboarding.success.email.title") public static let title = Localized.tr("Localizable", "onboarding.success.email.title")
......
...@@ -115,14 +115,10 @@ public final class OnboardingCodeController: UIViewController { ...@@ -115,14 +115,10 @@ public final class OnboardingCodeController: UIViewController {
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [unowned self] in .sink { [unowned self] in
guard $0 == true else { return } guard $0 == true else { return }
if isEmail { navigator.perform(PresentOnboardingSuccess(
navigator.perform(PresentOnboardingPhone(on: navigationController!)) isEmail: isEmail,
} else {
navigator.perform(PresentSearch(
fromOnboarding: true,
on: navigationController! on: navigationController!
)) ))
}
}.store(in: &cancellables) }.store(in: &cancellables)
screenView screenView
......
import UIKit
import Combine
import AppResources
import Dependencies
import AppNavigation
public final class OnboardingSuccessController: UIViewController {
@Dependency(\.navigator) var navigator
@Dependency(\.app.statusBar) var statusBar
private lazy var screenView = OnboardingSuccessView()
private let isEmail: Bool
private var cancellables = Set<AnyCancellable>()
public init(_ isEmail: Bool) {
self.isEmail = isEmail
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { nil }
public override func loadView() {
view = screenView
}
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let gradient = CAGradientLayer()
gradient.colors = [
UIColor(red: 122/255, green: 235/255, blue: 239/255, alpha: 1).cgColor,
UIColor(red: 56/255, green: 204/255, blue: 232/255, alpha: 1).cgColor,
UIColor(red: 63/255, green: 186/255, blue: 253/255, alpha: 1).cgColor,
UIColor(red: 98/255, green: 163/255, blue: 255/255, alpha: 1).cgColor
]
gradient.startPoint = CGPoint(x: 0, y: 0)
gradient.endPoint = CGPoint(x: 1, y: 1)
gradient.frame = screenView.bounds
screenView.layer.insertSublayer(gradient, at: 0)
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
statusBar.set(.lightContent)
navigationController?.navigationBar
.customize(translucent: true)
}
public override func viewDidLoad() {
super.viewDidLoad()
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .left
paragraph.lineHeightMultiple = 1.1
let attrString = NSMutableAttributedString(
string: isEmail ?
Localized.Onboarding.Success.Email.title : Localized.Onboarding.Success.Phone.title,
attributes: [
.font: Fonts.Mulish.bold.font(size: 39.0),
.foregroundColor: Asset.neutralWhite.color
]
)
attrString.addAttribute(
name: .foregroundColor,
value: Asset.neutralBody.color,
betweenCharacters: "#"
)
screenView.titleLabel.numberOfLines = 0
screenView.titleLabel.attributedText = attrString
screenView.nextButton.set(
style: .white,
title: isEmail ?
Localized.Onboarding.Success.Action.next :
Localized.Onboarding.Success.Action.done
)
screenView
.nextButton
.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
guard isEmail == true else {
navigator.perform(PresentSearch(
fromOnboarding: true,
on: navigationController!
))
return
}
navigator.perform(
PresentOnboardingPhone(
on: navigationController!
))
}.store(in: &cancellables)
}
}
...@@ -90,9 +90,10 @@ public final class OnboardingUsernameController: UIViewController { ...@@ -90,9 +90,10 @@ public final class OnboardingUsernameController: UIViewController {
viewModel viewModel
.statePublisher .statePublisher
.filter(\.didConfirm)
.removeDuplicates()
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [unowned self] in .sink { [unowned self] _ in
guard $0.didConfirm == true else { return }
navigator.perform(PresentOnboardingWelcome(on: navigationController!)) navigator.perform(PresentOnboardingWelcome(on: navigationController!))
}.store(in: &cancellables) }.store(in: &cancellables)
......
import UIKit
import Shared
import AppResources
final class OnboardingSuccessView: UIView {
let titleLabel = UILabel()
let imageView = UIImageView()
let nextButton = CapsuleButton()
init() {
super.init(frame: .zero)
imageView.image = Asset.onboardingSuccess.image
addSubview(imageView)
addSubview(titleLabel)
addSubview(nextButton)
imageView.snp.makeConstraints {
$0.top.equalTo(safeAreaLayoutGuide).offset(40)
$0.left.equalToSuperview().offset(40)
}
titleLabel.snp.makeConstraints {
$0.top.equalTo(imageView.snp.bottom).offset(40)
$0.left.equalToSuperview().offset(40)
$0.right.equalToSuperview().offset(-90)
}
nextButton.snp.makeConstraints {
$0.left.equalToSuperview().offset(24)
$0.right.equalToSuperview().offset(-24)
$0.bottom.equalToSuperview().offset(-60)
}
}
required init?(coder: NSCoder) { nil }
}
...@@ -13,7 +13,7 @@ final class RestoreSuccessView: UIView { ...@@ -13,7 +13,7 @@ final class RestoreSuccessView: UIView {
iconImageView.contentMode = .center iconImageView.contentMode = .center
iconImageView.image = Asset.onboardingSuccess.image iconImageView.image = Asset.onboardingSuccess.image
nextButton.set(style: .white, title: Localized.Onboarding.Success.action) nextButton.set(style: .white, title: Localized.Onboarding.Success.Action.next)
subtitleLabel.numberOfLines = 0 subtitleLabel.numberOfLines = 0
subtitleLabel.textColor = Asset.neutralWhite.color subtitleLabel.textColor = Asset.neutralWhite.color
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment