Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions OneWelcomeExampleApp/Interactors/LogoutInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import UIKit

protocol LogoutInteractorProtocol: AnyObject {
func logout()
func dashboard()
}

class LogoutInteractor: LogoutInteractorProtocol {
Expand All @@ -25,6 +26,10 @@ class LogoutInteractor: LogoutInteractorProtocol {
return SharedUserClient.instance
}

func dashboard() {
self.dashboardPresenter?.presentWelcomeView()
}

func logout() {
userClient.logoutUser { _, error in
if let error = error {
Expand Down
19 changes: 19 additions & 0 deletions OneWelcomeExampleApp/Presenters/DashboardPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protocol DashboardViewToPresenterProtocol: AnyObject {
func popToDashboardView()
func presetAppToWebView()
func updateView()
func dashboard()
}

class DashboardPresenter: DashboardInteractorToPresenterProtocol {
Expand Down Expand Up @@ -77,7 +78,25 @@ extension DashboardPresenter: DashboardViewToPresenterProtocol {
func logout() {
logoutInteractor.logout()
}

func presentLogoutAlert() {
let message = "Are you sure you want to login other profile?"
let alert = UIAlertController(title: "Login other profile", message: message, preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alert.addAction(cancelAction)

let disconnectAction = UIAlertAction(title: "Select a new profile", style: .default) { _ in
self.logoutInteractor.dashboard()
}
alert.addAction(disconnectAction)

navigationController.present(alert, animated: true, completion: nil)
}

func dashboard() {
presentLogoutAlert()
}

func popToDashboardView() {
navigationController.popToViewController(dashboardViewController, animated: true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class DashboardViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
profileNameLabel.text = userProfileName
makeProfileNameLabelTappable()
}

@IBAction func logoutPressed(_: Any) {
Expand All @@ -51,4 +52,14 @@ class DashboardViewController: UIViewController {
func updateView() {
app2webButton.stopAnimation()
}

@objc func profileNameTapped() {
dashboardViewToPresenterProtocol?.dashboard()
}

func makeProfileNameLabelTappable() {
let gest = UITapGestureRecognizer(target: self, action: #selector(profileNameTapped))
profileNameLabel.addGestureRecognizer(gest)
profileNameLabel.isUserInteractionEnabled = true
}
}