Skip to content

Commit

Permalink
Merge branch 'develop' into feature/add-accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepanokdev committed Nov 10, 2023
2 parents 78c2a24 + 7256a71 commit c6c1cd8
Show file tree
Hide file tree
Showing 145 changed files with 7,627 additions and 466 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/*
xcuserdata/
*.xcuserdata/*
/OpenEdX.xcodeproj/xcuserdata/
/OpenEdX.xcworkspace/xcuserdata/
/OpenEdX.xcworkspace/xcshareddata/swiftpm/Package.resolved
Expand All @@ -25,6 +26,15 @@ DerivedData/
*.perspectivev3
!default.perspectivev3

*.xcodeproj/*
**/xcuserdata/
**/*.xcuserdata/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings

## Obj-C/Swift specific
*.hmap

Expand Down Expand Up @@ -100,4 +110,4 @@ iOSInjectionProject/
xcode-frameworks

vendor/
.bundle/
.bundle/
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import Foundation
import Core

//sourcery: AutoMockable
public protocol AuthorizationRouter: BaseRouter {}
public protocol AuthorizationRouter: BaseRouter {
func showUpdateRequiredView(showAccountLink: Bool)
}

// Mark - For testing and SwiftUI preview
#if DEBUG
public class AuthorizationRouterMock: BaseRouterMock, AuthorizationRouter {

public override init() {}

public func showUpdateRequiredView(showAccountLink: Bool) {}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ struct SignInView_Previews: PreviewProvider {
static var previews: some View {
let vm = SignInViewModel(
interactor: AuthInteractor.mock,
router: AuthorizationRouterMock(),
router: AuthorizationRouterMock(),
config: ConfigMock(),
analytics: AuthorizationAnalyticsMock(),
validator: Validator()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,21 @@ public class SignInViewModel: ObservableObject {
}

let router: AuthorizationRouter

private let config: Config
private let interactor: AuthInteractorProtocol
private let analytics: AuthorizationAnalytics
private let validator: Validator

public init(
interactor: AuthInteractorProtocol,
router: AuthorizationRouter,
config: Config,
analytics: AuthorizationAnalytics,
validator: Validator
) {
self.interactor = interactor
self.router = router
self.config = config
self.analytics = analytics
self.validator = validator
}
Expand All @@ -64,11 +66,13 @@ 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,
let value = validationError.data?["error_description"] as? String {
if error.isUpdateRequeiredError {
router.showUpdateRequiredView(showAccountLink: false)
} else if let validationError = error.validationError,
let value = validationError.data?["error_description"] as? String {
errorMessage = value
} else if case APIError.invalidGrant = error {
errorMessage = CoreLocalization.Error.invalidCredentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class SignUpViewModel: ObservableObject {
isShowProgress = false
if error.isInternetError {
errorMessage = CoreLocalization.Error.slowOrNoInternetConnection
} else if error.isUpdateRequeiredError {
router.showUpdateRequiredView(showAccountLink: false)
} else {
errorMessage = CoreLocalization.Error.unknownError
}
Expand All @@ -93,7 +95,7 @@ public class SignUpViewModel: ObservableObject {
analytics.setUserID("\(user.id)")
analytics.registrationSuccess()
isShowProgress = false
router.showMainScreen()
router.showMainOrWhatsNewScreen()

} catch let error {
isShowProgress = false
Expand Down
60 changes: 39 additions & 21 deletions Authorization/AuthorizationTests/AuthorizationMock.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 1.8.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT


Expand Down Expand Up @@ -731,6 +731,12 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {



open func showUpdateRequiredView(showAccountLink: Bool) {
addInvocation(.m_showUpdateRequiredView__showAccountLink_showAccountLink(Parameter<Bool>.value(`showAccountLink`)))
let perform = methodPerformValue(.m_showUpdateRequiredView__showAccountLink_showAccountLink(Parameter<Bool>.value(`showAccountLink`))) as? (Bool) -> Void
perform?(`showAccountLink`)
}

open func backToRoot(animated: Bool) {
addInvocation(.m_backToRoot__animated_animated(Parameter<Bool>.value(`animated`)))
let perform = methodPerformValue(.m_backToRoot__animated_animated(Parameter<Bool>.value(`animated`))) as? (Bool) -> Void
Expand Down Expand Up @@ -761,9 +767,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 @@ -811,12 +817,13 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {


fileprivate enum MethodType {
case m_showUpdateRequiredView__showAccountLink_showAccountLink(Parameter<Bool>)
case m_backToRoot__animated_animated(Parameter<Bool>)
case m_back__animated_animated(Parameter<Bool>)
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 All @@ -827,6 +834,11 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {

static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult {
switch (lhs, rhs) {
case (.m_showUpdateRequiredView__showAccountLink_showAccountLink(let lhsShowaccountlink), .m_showUpdateRequiredView__showAccountLink_showAccountLink(let rhsShowaccountlink)):
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsShowaccountlink, rhs: rhsShowaccountlink, with: matcher), lhsShowaccountlink, rhsShowaccountlink, "showAccountLink"))
return Matcher.ComparisonResult(results)

case (.m_backToRoot__animated_animated(let lhsAnimated), .m_backToRoot__animated_animated(let rhsAnimated)):
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAnimated, rhs: rhsAnimated, with: matcher), lhsAnimated, rhsAnimated, "animated"))
Expand All @@ -849,7 +861,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 @@ -896,12 +908,13 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {

func intValue() -> Int {
switch self {
case let .m_showUpdateRequiredView__showAccountLink_showAccountLink(p0): return p0.intValue
case let .m_backToRoot__animated_animated(p0): return p0.intValue
case let .m_back__animated_animated(p0): return p0.intValue
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 @@ -913,12 +926,13 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
}
func assertionName() -> String {
switch self {
case .m_showUpdateRequiredView__showAccountLink_showAccountLink: return ".showUpdateRequiredView(showAccountLink:)"
case .m_backToRoot__animated_animated: return ".backToRoot(animated:)"
case .m_back__animated_animated: return ".back(animated:)"
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 All @@ -944,12 +958,13 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
public struct Verify {
fileprivate var method: MethodType

public static func showUpdateRequiredView(showAccountLink: Parameter<Bool>) -> Verify { return Verify(method: .m_showUpdateRequiredView__showAccountLink_showAccountLink(`showAccountLink`))}
public static func backToRoot(animated: Parameter<Bool>) -> Verify { return Verify(method: .m_backToRoot__animated_animated(`animated`))}
public static func back(animated: Parameter<Bool>) -> Verify { return Verify(method: .m_back__animated_animated(`animated`))}
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 All @@ -963,6 +978,9 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock {
fileprivate var method: MethodType
var performs: Any

public static func showUpdateRequiredView(showAccountLink: Parameter<Bool>, perform: @escaping (Bool) -> Void) -> Perform {
return Perform(method: .m_showUpdateRequiredView__showAccountLink_showAccountLink(`showAccountLink`), performs: perform)
}
public static func backToRoot(animated: Parameter<Bool>, perform: @escaping (Bool) -> Void) -> Perform {
return Perform(method: .m_backToRoot__animated_animated(`animated`), performs: perform)
}
Expand All @@ -978,8 +996,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 +1169,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 +1224,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 +1257,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 +1309,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 +1326,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 +1357,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 +1386,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
Loading

0 comments on commit c6c1cd8

Please sign in to comment.