Skip to content

Commit

Permalink
chore: changes from PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
eyatsenkoperpetio committed Dec 6, 2023
1 parent c7a01c6 commit 10bf647
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public class SignInViewModel: ObservableObject {
}

var socialLoginEnabled: Bool {
config.socialLoginEnabled
config.appleSignIn.enabled ||
config.facebook.enabled ||
config.microsoft.enabled ||
config.google.enabled
}

@MainActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public class SignUpViewModel: ObservableObject {
}

var socialLoginEnabled: Bool {
config.socialLoginEnabled && !isThirdPartyAuthSuccess && !isShowProgress
let socialLoginEnabled = config.appleSignIn.enabled ||
config.facebook.enabled ||
config.microsoft.enabled ||
config.google.enabled
return socialLoginEnabled && !isThirdPartyAuthSuccess && !isShowProgress
}

private func showErrors(errors: [String: String]) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ final public class SocialAuthViewModel: ObservableObject {
/// must also offer Sign in with Apple as an equivalent option
return true
}
return config.appleSignIn.enable
return config.appleSignIn.enabled
}

// MARK: - Public Intens
Expand Down
1 change: 0 additions & 1 deletion Authorization/Authorization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@
"STARTUP.SEARCH_TITLE" = "What do you want to learn?";
"STARTUP.SEARCH_PLACEHOLDER" = "Search our 3000+ courses";
"STARTUP.EXPLORE_ALL_COURSES" = "Explore all courses";

10 changes: 5 additions & 5 deletions Core/Core/Configuration/Config/AppleSignInConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
import Foundation

private enum AppleSignInKeys: String {
case enable = "ENABLED"
case enabled = "ENABLED"
}

public class AppleSignInConfig: NSObject {
public var enable: Bool
public var enabled: Bool

init(dictionary: [String: Any]) {
enable = dictionary[AppleSignInKeys.enable.rawValue] as? Bool ?? false
enabled = dictionary[AppleSignInKeys.enabled.rawValue] as? Bool ?? false
super.init()
}
}

private let appleSignInKey = "APPLE_SIGNIN"
private let key = "APPLE_SIGNIN"
extension Config {
public var appleSignIn: AppleSignInConfig {
AppleSignInConfig(dictionary: self[appleSignInKey] as? [String: AnyObject] ?? [:])
AppleSignInConfig(dictionary: self[key] as? [String: AnyObject] ?? [:])
}
}
8 changes: 0 additions & 8 deletions Core/Core/Configuration/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public protocol ConfigProtocol {
var feedbackEmail: String { get }
var appStoreLink: String { get }
var platformName: String { get }
var socialLoginEnabled: Bool { get }
var agreement: AgreementConfig { get }
var firebase: FirebaseConfig { get }
var facebook: FacebookConfig { get }
Expand Down Expand Up @@ -137,13 +136,6 @@ extension Config: ConfigProtocol {
public var appStoreLink: String {
"itms-apps://itunes.apple.com/app/id\(appStoreId)?mt=8"
}

public var socialLoginEnabled: Bool {
appleSignIn.enable ||
facebook.enabled ||
microsoft.enabled ||
google.enabled
}
}

// Mark - For testing and SwiftUI preview
Expand Down
4 changes: 2 additions & 2 deletions Core/Core/Configuration/Config/FacebookConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public final class FacebookConfig: NSObject {
}
}

private let facebookKey = "FACEBOOK"
private let key = "FACEBOOK"
extension Config {
public var facebook: FacebookConfig {
FacebookConfig(dictionary: self[facebookKey] as? [String: AnyObject] ?? [:])
FacebookConfig(dictionary: self[key] as? [String: AnyObject] ?? [:])
}
}
4 changes: 2 additions & 2 deletions Core/Core/Configuration/Config/GoogleConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public final class GoogleConfig: NSObject {
}
}

private let googleKey = "GOOGLE"
private let key = "GOOGLE"
extension Config {
public var google: GoogleConfig {
GoogleConfig(dictionary: self[googleKey] as? [String: AnyObject] ?? [:])
GoogleConfig(dictionary: self[key] as? [String: AnyObject] ?? [:])
}
}
4 changes: 2 additions & 2 deletions Core/Core/Configuration/Config/MicrosoftConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public final class MicrosoftConfig: NSObject {
}
}

private let microsoftKey = "MICROSOFT"
private let key = "MICROSOFT"
extension Config {
public var microsoft: MicrosoftConfig {
MicrosoftConfig(dictionary: self[microsoftKey] as? [String: AnyObject] ?? [:])
MicrosoftConfig(dictionary: self[key] as? [String: AnyObject] ?? [:])
}
}
28 changes: 28 additions & 0 deletions Core/CoreTests/Configuration/ConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,32 @@ class ConfigTests: XCTestCase {
XCTAssertEqual(config.firebase.isAnalyticsSourceFirebase, true)
XCTAssertEqual(config.firebase.cloudMessagingEnabled, true)
}

func testGoogleConfigInitialization() {
let config = Config(properties: properties)

XCTAssertTrue(config.google.enabled)
XCTAssertEqual(config.google.clientID, "clientId")
}

func testFacebookConfigInitialization() {
let config = Config(properties: properties)

XCTAssertTrue(config.facebook.enabled)
XCTAssertEqual(config.facebook.appID, "facebookAppId")
XCTAssertEqual(config.facebook.clientToken, "client_token")
}

func testMicrosoftConfigInitialization() {
let config = Config(properties: properties)

XCTAssertTrue(config.microsoft.enabled)
XCTAssertEqual(config.microsoft.appID, "appId")
}

func testAppleConfigInitialization() {
let config = Config(properties: properties)

XCTAssertTrue(config.appleSignIn.enabled)
}
}
2 changes: 1 addition & 1 deletion OpenEdX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
_ app: UIApplication,
open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
if let config = Container.shared.resolve(ConfigProtocol.self), config.socialLoginEnabled {
if let config = Container.shared.resolve(ConfigProtocol.self) {
if config.facebook.enabled {
ApplicationDelegate.shared.application(
app,
Expand Down

0 comments on commit 10bf647

Please sign in to comment.