Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into feat/add_support…
Browse files Browse the repository at this point in the history
…_for_username
  • Loading branch information
mumer92 committed Nov 27, 2023
2 parents 4c5120c + 7fc5a64 commit c7eda4d
Show file tree
Hide file tree
Showing 192 changed files with 7,400 additions and 636 deletions.
19 changes: 17 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,9 @@ iOSInjectionProject/
xcode-frameworks

vendor/
.bundle/
.bundle/

venv/
Podfile.lock
config_settings.yaml
default_config/
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 @@ -12,7 +12,7 @@ struct FieldsView: View {

let fields: [FieldConfiguration]
let router: BaseRouter
let configuration: Config
let config: ConfigProtocol
let cssInjector: CSSInjector
let proxy: GeometryProxy
@Environment(\.colorScheme) var colorScheme
Expand Down Expand Up @@ -107,7 +107,7 @@ struct FieldsView_Previews: PreviewProvider {
FieldsView(
fields: fields,
router: AuthorizationRouterMock(),
configuration: ConfigMock(),
config: ConfigMock(),
cssInjector: CSSInjectorMock(),
proxy: proxy
)
Expand Down
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: ConfigProtocol
private let interactor: AuthInteractorProtocol
private let analytics: AuthorizationAnalytics
private let validator: Validator

public init(
interactor: AuthInteractorProtocol,
router: AuthorizationRouter,
config: ConfigProtocol,
analytics: AuthorizationAnalytics,
validator: Validator
) {
self.interactor = interactor
self.router = router
self.config = config
self.analytics = analytics
self.validator = validator
}
Expand All @@ -67,8 +69,10 @@ public class SignInViewModel: ObservableObject {
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 @@ -72,15 +72,15 @@ public struct SignUpView: View {

FieldsView(fields: requiredFields,
router: viewModel.router,
configuration: viewModel.config,
config: viewModel.config,
cssInjector: viewModel.cssInjector,
proxy: proxy)

if !viewModel.isShowProgress {
DisclosureGroup(isExpanded: $disclosureGroupOpen, content: {
FieldsView(fields: nonRequiredFields,
router: viewModel.router,
configuration: viewModel.config,
config: viewModel.config,
cssInjector: viewModel.cssInjector,
proxy: proxy).padding(.horizontal, 1)
}, label: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SignUpViewModel: ObservableObject {
@Published var fields: [FieldConfiguration] = []

let router: AuthorizationRouter
let config: Config
let config: ConfigProtocol
let cssInjector: CSSInjector

private let interactor: AuthInteractorProtocol
Expand All @@ -36,7 +36,7 @@ public class SignUpViewModel: ObservableObject {
interactor: AuthInteractorProtocol,
router: AuthorizationRouter,
analytics: AuthorizationAnalytics,
config: Config,
config: ConfigProtocol,
cssInjector: CSSInjector,
validator: Validator
) {
Expand Down 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 Down
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 @@ -811,6 +817,7 @@ 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
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 Down Expand Up @@ -896,6 +908,7 @@ 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
Expand All @@ -913,6 +926,7 @@ 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()"
Expand Down Expand Up @@ -944,6 +958,7 @@ 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)}
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ final class SignInViewModelTests: XCTestCase {
let analytics = AuthorizationAnalyticsMock()
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -51,6 +52,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -71,6 +73,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -96,6 +99,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand Down Expand Up @@ -123,6 +127,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -146,6 +151,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -169,6 +175,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -194,6 +201,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand All @@ -211,6 +219,7 @@ final class SignInViewModelTests: XCTestCase {
let viewModel = SignInViewModel(
interactor: interactor,
router: router,
config: ConfigMock(),
analytics: analytics,
validator: validator
)
Expand Down
4 changes: 2 additions & 2 deletions Authorization/Mockfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sourceryCommand: null
sourceryTemplate: null
sourceryCommand: mint run krzysztofzablocki/[email protected] sourcery
sourceryTemplate: ../MockTemplate.swifttemplate
unit.tests.mock:
sources:
include:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "youtubeplayerkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SvenTiigi/YouTubePlayerKit",
"state" : {
"revision" : "1fe4c8b07a61d50c2fd276e1d9c8087583c7638a",
"version" : "1.5.3"
}
}
],
"version" : 2
}
Loading

0 comments on commit c7eda4d

Please sign in to comment.