Skip to content

Commit

Permalink
chore: add new dict social login
Browse files Browse the repository at this point in the history
  • Loading branch information
eyatsenkoperpetio committed Nov 27, 2023
1 parent 42b48a0 commit 4f1c544
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down
4 changes: 4 additions & 0 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -286,6 +287,7 @@
BAFB99832B0E282E007D09F9 /* MicrosoftConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosoftConfig.swift; sourceTree = "<group>"; };
BAFB998D2B0F70F1007D09F9 /* CustomError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomError.swift; sourceTree = "<group>"; };
BAFB998F2B14B377007D09F9 /* GoogleConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleConfig.swift; sourceTree = "<group>"; };
BAFB99912B14E23D007D09F9 /* SocialLoginConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialLoginConfig.swift; sourceTree = "<group>"; };
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 = "<group>"; };
CFC84951299F8B890055E497 /* Debounce.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debounce.swift; sourceTree = "<group>"; };
DB4EBE9D2B1075E100CB4DC4 /* ConfigTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -699,6 +701,7 @@
BAFB99812B0E2354007D09F9 /* FacebookConfig.swift */,
BAFB99832B0E282E007D09F9 /* MicrosoftConfig.swift */,
BAFB998F2B14B377007D09F9 /* GoogleConfig.swift */,
BAFB99912B14E23D007D09F9 /* SocialLoginConfig.swift */,
);
path = Config;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
7 changes: 4 additions & 3 deletions Core/Core/Configuration/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down Expand Up @@ -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)
}
}

Expand Down
6 changes: 0 additions & 6 deletions Core/Core/Configuration/Config/FeaturesConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
3 changes: 0 additions & 3 deletions Core/Core/Configuration/Config/GoogleConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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
}
}

Expand Down
32 changes: 32 additions & 0 deletions Core/Core/Configuration/Config/SocialLoginConfig.swift
Original file line number Diff line number Diff line change
@@ -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] ?? [:])
}
}

0 comments on commit 4f1c544

Please sign in to comment.