From 4f1c54449cf720f42a7cb183b366ff84ffb35dd1 Mon Sep 17 00:00:00 2001 From: Eugene Yatsenko Date: Mon, 27 Nov 2023 15:58:24 +0100 Subject: [PATCH] chore: add new dict social login --- .../SocialSign/SocialSignView.swift | 4 +-- Core/Core.xcodeproj/project.pbxproj | 4 +++ Core/Core/Configuration/Config/Config.swift | 7 ++-- .../Configuration/Config/FeaturesConfig.swift | 6 ---- .../Configuration/Config/GoogleConfig.swift | 3 -- .../Config/SocialLoginConfig.swift | 32 +++++++++++++++++++ 6 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 Core/Core/Configuration/Config/SocialLoginConfig.swift diff --git a/Authorization/Authorization/Presentation/SocialSign/SocialSignView.swift b/Authorization/Authorization/Presentation/SocialSign/SocialSignView.swift index f18df8ddd..99eaca2b4 100644 --- a/Authorization/Authorization/Presentation/SocialSign/SocialSignView.swift +++ b/Authorization/Authorization/Presentation/SocialSign/SocialSignView.swift @@ -59,7 +59,7 @@ struct SocialSignView: View { private var buttonsView: some View { Group { - if viewModel.config.google.googleSignInEnabled { + if viewModel.config.google.enabled { LabelButton( image: CoreAssets.iconGoogleWhite.swiftUIImage, title: "\(title) \(AuthLocalization.google)", @@ -90,7 +90,7 @@ struct SocialSignView: View { .accessibilityElement(children: .ignore) .accessibilityLabel("\(title) \(AuthLocalization.microsoft)") } - if viewModel.config.features.isAppleSigninEnabled { + if viewModel.config.socialLogin.appleSigninEnabled { LabelButton( image: CoreAssets.iconApple.swiftUIImage, title: "\(title) \(AuthLocalization.apple)", diff --git a/Core/Core.xcodeproj/project.pbxproj b/Core/Core.xcodeproj/project.pbxproj index 305bb2865..8ba9ba24e 100644 --- a/Core/Core.xcodeproj/project.pbxproj +++ b/Core/Core.xcodeproj/project.pbxproj @@ -134,6 +134,7 @@ BAFB99842B0E282E007D09F9 /* MicrosoftConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAFB99832B0E282E007D09F9 /* MicrosoftConfig.swift */; }; BAFB998E2B0F70F1007D09F9 /* CustomError.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAFB998D2B0F70F1007D09F9 /* CustomError.swift */; }; BAFB99902B14B377007D09F9 /* GoogleConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAFB998F2B14B377007D09F9 /* GoogleConfig.swift */; }; + BAFB99922B14E23D007D09F9 /* SocialLoginConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAFB99912B14E23D007D09F9 /* SocialLoginConfig.swift */; }; C8C446EF233F81B9FABB77D2 /* Pods_App_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 349B90CD6579F7B8D257E515 /* Pods_App_Core.framework */; }; CFC84952299F8B890055E497 /* Debounce.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFC84951299F8B890055E497 /* Debounce.swift */; }; DB4EBE9E2B1075E100CB4DC4 /* ConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4EBE9D2B1075E100CB4DC4 /* ConfigTests.swift */; }; @@ -286,6 +287,7 @@ BAFB99832B0E282E007D09F9 /* MicrosoftConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosoftConfig.swift; sourceTree = ""; }; BAFB998D2B0F70F1007D09F9 /* CustomError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomError.swift; sourceTree = ""; }; BAFB998F2B14B377007D09F9 /* GoogleConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleConfig.swift; sourceTree = ""; }; + BAFB99912B14E23D007D09F9 /* SocialLoginConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialLoginConfig.swift; sourceTree = ""; }; C7E5BCE79CE297B20777B27A /* Pods-App-Core.debugprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.debugprod.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.debugprod.xcconfig"; sourceTree = ""; }; CFC84951299F8B890055E497 /* Debounce.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debounce.swift; sourceTree = ""; }; DB4EBE9D2B1075E100CB4DC4 /* ConfigTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigTests.swift; sourceTree = ""; }; @@ -699,6 +701,7 @@ BAFB99812B0E2354007D09F9 /* FacebookConfig.swift */, BAFB99832B0E282E007D09F9 /* MicrosoftConfig.swift */, BAFB998F2B14B377007D09F9 /* GoogleConfig.swift */, + BAFB99912B14E23D007D09F9 /* SocialLoginConfig.swift */, ); path = Config; sourceTree = ""; @@ -933,6 +936,7 @@ 0260E58028FD792800BBBE18 /* WebUnitViewModel.swift in Sources */, 02A4833A29B8A9AB00D33F33 /* DownloadManager.swift in Sources */, 027BD3AE2909475000392132 /* KeyboardScrollerOptions.swift in Sources */, + BAFB99922B14E23D007D09F9 /* SocialLoginConfig.swift in Sources */, 027BD3BE2909478B00392132 /* UIResponder+CurrentResponder.swift in Sources */, 070019AE28F701B200D5FC78 /* Certificate.swift in Sources */, 076F297F2A1F80C800967E7D /* Pagination.swift in Sources */, diff --git a/Core/Core/Configuration/Config/Config.swift b/Core/Core/Configuration/Config/Config.swift index 041466ce5..9ad12c481 100644 --- a/Core/Core/Configuration/Config/Config.swift +++ b/Core/Core/Configuration/Config/Config.swift @@ -19,6 +19,7 @@ public protocol ConfigProtocol { var facebook: FacebookConfig { get } var microsoft: MicrosoftConfig { get } var google: GoogleConfig { get } + var socialLogin: SocialLoginConfig { get } var features: FeaturesConfig { get } } @@ -133,11 +134,11 @@ extension Config: ConfigProtocol { } public var socialLoginEnabled: Bool { - features.socialLoginEnabled && - (features.isAppleSigninEnabled || + socialLogin.enable && + (socialLogin.appleSigninEnabled || facebook.enabled || microsoft.enabled || - google.googleSignInEnabled) + google.enabled) } } diff --git a/Core/Core/Configuration/Config/FeaturesConfig.swift b/Core/Core/Configuration/Config/FeaturesConfig.swift index 626bbd502..fa17af6f4 100644 --- a/Core/Core/Configuration/Config/FeaturesConfig.swift +++ b/Core/Core/Configuration/Config/FeaturesConfig.swift @@ -9,19 +9,13 @@ import Foundation private enum FeaturesKeys: String { case whatNewEnabled = "WHATS_NEW_ENABLED" - case socialLoginEnabled = "SOCIAL_LOGIN_ENABLED" - case isAppleSigninEnabled = "APPLE_SIGNIN_ENABLED" } public class FeaturesConfig: NSObject { public var whatNewEnabled: Bool - public var socialLoginEnabled: Bool - public var isAppleSigninEnabled: Bool init(dictionary: [String: Any]) { whatNewEnabled = dictionary[FeaturesKeys.whatNewEnabled.rawValue] as? Bool ?? false - socialLoginEnabled = dictionary[FeaturesKeys.socialLoginEnabled.rawValue] as? Bool ?? false - isAppleSigninEnabled = dictionary[FeaturesKeys.isAppleSigninEnabled.rawValue] as? Bool ?? false super.init() } } diff --git a/Core/Core/Configuration/Config/GoogleConfig.swift b/Core/Core/Configuration/Config/GoogleConfig.swift index 01c2b0bf4..5baa04d87 100644 --- a/Core/Core/Configuration/Config/GoogleConfig.swift +++ b/Core/Core/Configuration/Config/GoogleConfig.swift @@ -9,14 +9,12 @@ import Foundation private enum GoogleKeys: String { case enabled = "ENABLED" - case googleSignInEnabled = "GOOGLE_SIGNIN_ENABLED" case googlePlusKey = "GOOGLE_PLUS_KEY" case clientID = "CLIENT_ID" } public final class GoogleConfig: NSObject { public var enabled: Bool = false - public var googleSignInEnabled: Bool = false public var googlePlusKey: String? public var clientID: String? @@ -29,7 +27,6 @@ public final class GoogleConfig: NSObject { clientID = dictionary[GoogleKeys.clientID.rawValue] as? String super.init() enabled = requiredKeysAvailable && dictionary[GoogleKeys.enabled.rawValue] as? Bool == true - googleSignInEnabled = enabled && dictionary[GoogleKeys.googleSignInEnabled.rawValue] as? Bool == true } } diff --git a/Core/Core/Configuration/Config/SocialLoginConfig.swift b/Core/Core/Configuration/Config/SocialLoginConfig.swift new file mode 100644 index 000000000..9439efc37 --- /dev/null +++ b/Core/Core/Configuration/Config/SocialLoginConfig.swift @@ -0,0 +1,32 @@ +// +// SocialLoginConfig.swift +// Core +// +// Created by Eugene Yatsenko on 27.11.2023. +// + +import Foundation + +private enum SocialLoginKeys: String { + case enable = "ENABLED" + case appleSigninEnabled = "APPLE_SIGNIN_ENABLED" + +} + +public class SocialLoginConfig: NSObject { + public var enable: Bool + public var appleSigninEnabled: Bool + + init(dictionary: [String: Any]) { + enable = dictionary[SocialLoginKeys.enable.rawValue] as? Bool ?? false + appleSigninEnabled = dictionary[SocialLoginKeys.appleSigninEnabled.rawValue] as? Bool ?? false + super.init() + } +} + +private let socialLoginKey = "SOCIAL_LOGINS" +extension Config { + public var socialLogin: SocialLoginConfig { + SocialLoginConfig(dictionary: self[socialLoginKey] as? [String: AnyObject] ?? [:]) + } +}