Skip to content

Commit

Permalink
What’s new screen (After Login Experience) (#131)
Browse files Browse the repository at this point in the history
* Add whats new screen

* add whats new logic after user login

* code style fixes

add accessibility support
add feature flag to Config

* Add tests

* change the done button icon and add the fade-in animation to the previous button

* Update Config.swift

change whatsNewEnabled to false

* fix mock files

* add test file to project
  • Loading branch information
IvanStepanok authored Oct 27, 2023
1 parent 9952bb9 commit 6fbe09d
Show file tree
Hide file tree
Showing 54 changed files with 2,622 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class SignInViewModel: ObservableObject {
let user = try await interactor.login(username: username, password: password)
analytics.setUserID("\(user.id)")
analytics.userLogin(method: .password)
router.showMainScreen()
router.showMainOrWhatsNewScreen()
} catch let error {
isShowProgress = false
if let validationError = error.validationError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class SignUpViewModel: ObservableObject {
analytics.setUserID("\(user.id)")
analytics.registrationSuccess()
isShowProgress = false
router.showMainScreen()
router.showMainOrWhatsNewScreen()

} catch let error {
isShowProgress = false
Expand Down
40 changes: 20 additions & 20 deletions Authorization/AuthorizationTests/AuthorizationMock.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,9 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
perform?(`controllers`)
}

open func showMainScreen() {
addInvocation(.m_showMainScreen)
let perform = methodPerformValue(.m_showMainScreen) as? () -> Void
open func showMainOrWhatsNewScreen() {
addInvocation(.m_showMainOrWhatsNewScreen)
let perform = methodPerformValue(.m_showMainOrWhatsNewScreen) as? () -> Void
perform?()
}

Expand Down Expand Up @@ -816,7 +816,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
case m_backWithFade
case m_dismiss__animated_animated(Parameter<Bool>)
case m_removeLastView__controllers_controllers(Parameter<Int>)
case m_showMainScreen
case m_showMainOrWhatsNewScreen
case m_showLoginScreen
case m_showRegisterScreen
case m_showForgotPasswordScreen
Expand Down Expand Up @@ -849,7 +849,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers"))
return Matcher.ComparisonResult(results)

case (.m_showMainScreen, .m_showMainScreen): return .match
case (.m_showMainOrWhatsNewScreen, .m_showMainOrWhatsNewScreen): return .match

case (.m_showLoginScreen, .m_showLoginScreen): return .match

Expand Down Expand Up @@ -901,7 +901,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
case .m_backWithFade: return 0
case let .m_dismiss__animated_animated(p0): return p0.intValue
case let .m_removeLastView__controllers_controllers(p0): return p0.intValue
case .m_showMainScreen: return 0
case .m_showMainOrWhatsNewScreen: return 0
case .m_showLoginScreen: return 0
case .m_showRegisterScreen: return 0
case .m_showForgotPasswordScreen: return 0
Expand All @@ -918,7 +918,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
case .m_backWithFade: return ".backWithFade()"
case .m_dismiss__animated_animated: return ".dismiss(animated:)"
case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)"
case .m_showMainScreen: return ".showMainScreen()"
case .m_showMainOrWhatsNewScreen: return ".showMainOrWhatsNewScreen()"
case .m_showLoginScreen: return ".showLoginScreen()"
case .m_showRegisterScreen: return ".showRegisterScreen()"
case .m_showForgotPasswordScreen: return ".showForgotPasswordScreen()"
Expand Down Expand Up @@ -949,7 +949,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)}
public static func dismiss(animated: Parameter<Bool>) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))}
public static func removeLastView(controllers: Parameter<Int>) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))}
public static func showMainScreen() -> Verify { return Verify(method: .m_showMainScreen)}
public static func showMainOrWhatsNewScreen() -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen)}
public static func showLoginScreen() -> Verify { return Verify(method: .m_showLoginScreen)}
public static func showRegisterScreen() -> Verify { return Verify(method: .m_showRegisterScreen)}
public static func showForgotPasswordScreen() -> Verify { return Verify(method: .m_showForgotPasswordScreen)}
Expand Down Expand Up @@ -978,8 +978,8 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
public static func removeLastView(controllers: Parameter<Int>, perform: @escaping (Int) -> Void) -> Perform {
return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform)
}
public static func showMainScreen(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_showMainScreen, performs: perform)
public static func showMainOrWhatsNewScreen(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_showMainOrWhatsNewScreen, performs: perform)
}
public static func showLoginScreen(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_showLoginScreen, performs: perform)
Expand Down Expand Up @@ -1151,9 +1151,9 @@ open class BaseRouterMock: BaseRouter, Mock {
perform?(`controllers`)
}

open func showMainScreen() {
addInvocation(.m_showMainScreen)
let perform = methodPerformValue(.m_showMainScreen) as? () -> Void
open func showMainOrWhatsNewScreen() {
addInvocation(.m_showMainOrWhatsNewScreen)
let perform = methodPerformValue(.m_showMainOrWhatsNewScreen) as? () -> Void
perform?()
}

Expand Down Expand Up @@ -1206,7 +1206,7 @@ open class BaseRouterMock: BaseRouter, Mock {
case m_backWithFade
case m_dismiss__animated_animated(Parameter<Bool>)
case m_removeLastView__controllers_controllers(Parameter<Int>)
case m_showMainScreen
case m_showMainOrWhatsNewScreen
case m_showLoginScreen
case m_showRegisterScreen
case m_showForgotPasswordScreen
Expand Down Expand Up @@ -1239,7 +1239,7 @@ open class BaseRouterMock: BaseRouter, Mock {
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers"))
return Matcher.ComparisonResult(results)

case (.m_showMainScreen, .m_showMainScreen): return .match
case (.m_showMainOrWhatsNewScreen, .m_showMainOrWhatsNewScreen): return .match

case (.m_showLoginScreen, .m_showLoginScreen): return .match

Expand Down Expand Up @@ -1291,7 +1291,7 @@ open class BaseRouterMock: BaseRouter, Mock {
case .m_backWithFade: return 0
case let .m_dismiss__animated_animated(p0): return p0.intValue
case let .m_removeLastView__controllers_controllers(p0): return p0.intValue
case .m_showMainScreen: return 0
case .m_showMainOrWhatsNewScreen: return 0
case .m_showLoginScreen: return 0
case .m_showRegisterScreen: return 0
case .m_showForgotPasswordScreen: return 0
Expand All @@ -1308,7 +1308,7 @@ open class BaseRouterMock: BaseRouter, Mock {
case .m_backWithFade: return ".backWithFade()"
case .m_dismiss__animated_animated: return ".dismiss(animated:)"
case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)"
case .m_showMainScreen: return ".showMainScreen()"
case .m_showMainOrWhatsNewScreen: return ".showMainOrWhatsNewScreen()"
case .m_showLoginScreen: return ".showLoginScreen()"
case .m_showRegisterScreen: return ".showRegisterScreen()"
case .m_showForgotPasswordScreen: return ".showForgotPasswordScreen()"
Expand Down Expand Up @@ -1339,7 +1339,7 @@ open class BaseRouterMock: BaseRouter, Mock {
public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)}
public static func dismiss(animated: Parameter<Bool>) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))}
public static func removeLastView(controllers: Parameter<Int>) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))}
public static func showMainScreen() -> Verify { return Verify(method: .m_showMainScreen)}
public static func showMainOrWhatsNewScreen() -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen)}
public static func showLoginScreen() -> Verify { return Verify(method: .m_showLoginScreen)}
public static func showRegisterScreen() -> Verify { return Verify(method: .m_showRegisterScreen)}
public static func showForgotPasswordScreen() -> Verify { return Verify(method: .m_showForgotPasswordScreen)}
Expand Down Expand Up @@ -1368,8 +1368,8 @@ open class BaseRouterMock: BaseRouter, Mock {
public static func removeLastView(controllers: Parameter<Int>, perform: @escaping (Int) -> Void) -> Perform {
return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform)
}
public static func showMainScreen(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_showMainScreen, performs: perform)
public static func showMainOrWhatsNewScreen(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_showMainOrWhatsNewScreen, performs: perform)
}
public static func showLoginScreen(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_showLoginScreen, performs: perform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class SignInViewModelTests: XCTestCase {
await viewModel.login(username: "email", password: "")

Verify(interactor, 0, .login(username: .any, password: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, AuthLocalization.Error.invalidEmailAddress)
XCTAssertEqual(viewModel.isShowProgress, false)
Expand All @@ -57,7 +57,7 @@ final class SignInViewModelTests: XCTestCase {
await viewModel.login(username: "[email protected]", password: "")

Verify(interactor, 0, .login(username: .any, password: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, AuthLocalization.Error.invalidPasswordLenght)
XCTAssertEqual(viewModel.isShowProgress, false)
Expand All @@ -82,7 +82,7 @@ final class SignInViewModelTests: XCTestCase {

Verify(interactor, 1, .login(username: .any, password: .any))
Verify(analytics, .userLogin(method: .any))
Verify(router, 1, .showMainScreen())
Verify(router, 1, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, nil)
XCTAssertEqual(viewModel.isShowProgress, true)
Expand All @@ -109,7 +109,7 @@ final class SignInViewModelTests: XCTestCase {
await viewModel.login(username: "[email protected]", password: "password123")

Verify(interactor, 1, .login(username: .any, password: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, validationErrorMessage)
XCTAssertEqual(viewModel.isShowProgress, false)
Expand All @@ -132,7 +132,7 @@ final class SignInViewModelTests: XCTestCase {
await viewModel.login(username: "[email protected]", password: "password123")

Verify(interactor, 1, .login(username: .any, password: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, CoreLocalization.Error.invalidCredentials)
XCTAssertEqual(viewModel.isShowProgress, false)
Expand All @@ -155,7 +155,7 @@ final class SignInViewModelTests: XCTestCase {
await viewModel.login(username: "[email protected]", password: "password123")

Verify(interactor, 1, .login(username: .any, password: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, CoreLocalization.Error.unknownError)
XCTAssertEqual(viewModel.isShowProgress, false)
Expand All @@ -180,7 +180,7 @@ final class SignInViewModelTests: XCTestCase {
await viewModel.login(username: "[email protected]", password: "password123")

Verify(interactor, 1, .login(username: .any, password: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.errorMessage, CoreLocalization.Error.slowOrNoInternetConnection)
XCTAssertEqual(viewModel.isShowProgress, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ final class SignUpViewModelTests: XCTestCase {

Verify(interactor, 1, .validateRegistrationFields(fields: .any))
Verify(interactor, 1, .registerUser(fields: .any))
Verify(router, 1, .showMainScreen())
Verify(router, 1, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.isShowProgress, false)
XCTAssertEqual(viewModel.showError, false)
Expand Down Expand Up @@ -164,7 +164,7 @@ final class SignUpViewModelTests: XCTestCase {

Verify(interactor, 1, .validateRegistrationFields(fields: .any))
Verify(interactor, 0, .registerUser(fields: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.isShowProgress, false)
XCTAssertEqual(viewModel.showError, false)
Expand Down Expand Up @@ -192,7 +192,7 @@ final class SignUpViewModelTests: XCTestCase {

Verify(interactor, 1, .validateRegistrationFields(fields: .any))
Verify(interactor, 1, .registerUser(fields: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.isShowProgress, false)
XCTAssertEqual(viewModel.showError, true)
Expand Down Expand Up @@ -220,7 +220,7 @@ final class SignUpViewModelTests: XCTestCase {

Verify(interactor, 1, .validateRegistrationFields(fields: .any))
Verify(interactor, 1, .registerUser(fields: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.isShowProgress, false)
XCTAssertEqual(viewModel.showError, true)
Expand Down Expand Up @@ -250,7 +250,7 @@ final class SignUpViewModelTests: XCTestCase {

Verify(interactor, 1, .validateRegistrationFields(fields: .any))
Verify(interactor, 1, .registerUser(fields: .any))
Verify(router, 0, .showMainScreen())
Verify(router, 0, .showMainOrWhatsNewScreen())

XCTAssertEqual(viewModel.isShowProgress, false)
XCTAssertEqual(viewModel.showError, true)
Expand Down
4 changes: 2 additions & 2 deletions Core/Core/Configuration/BaseRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public protocol BaseRouter {

func removeLastView(controllers: Int)

func showMainScreen()
func showMainOrWhatsNewScreen()

func showLoginScreen()

Expand Down Expand Up @@ -73,7 +73,7 @@ open class BaseRouterMock: BaseRouter {

public func dismiss(animated: Bool) {}

public func showMainScreen() {}
public func showMainOrWhatsNewScreen() {}

public func showLoginScreen() {}

Expand Down
2 changes: 2 additions & 0 deletions Core/Core/Configuration/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class Config {

public let feedbackEmail = "[email protected]"

public let whatsNewEnabled: Bool = false

public init(baseURL: String, oAuthClientId: String) {
guard let url = URL(string: baseURL) else {
fatalError("Ivalid baseURL")
Expand Down
Loading

0 comments on commit 6fbe09d

Please sign in to comment.