Skip to content

Commit

Permalink
feat: add config to process config
Browse files Browse the repository at this point in the history
  • Loading branch information
mumer92 committed Nov 13, 2023
1 parent cdcfdb6 commit af58789
Show file tree
Hide file tree
Showing 48 changed files with 780 additions and 242 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ xcode-frameworks

vendor/
.bundle/

config.yaml
venv/
Podfile.lock
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 @@ -31,15 +31,15 @@ public class SignInViewModel: ObservableObject {
}

let router: AuthorizationRouter
private let config: Config
private let config: ConfigProtocol
private let interactor: AuthInteractorProtocol
private let analytics: AuthorizationAnalytics
private let validator: Validator

public init(
interactor: AuthInteractorProtocol,
router: AuthorizationRouter,
config: Config,
config: ConfigProtocol,
analytics: AuthorizationAnalytics,
validator: Validator
) {
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
37 changes: 35 additions & 2 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
07DDFCBD29A780BB00572595 /* UINavigationController+Animation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07DDFCBC29A780BB00572595 /* UINavigationController+Animation.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 */; };
DBF6F2412B014ADA0098414B /* FirebaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6F2402B014ADA0098414B /* FirebaseConfig.swift */; };
DBF6F2462B01DAFE0098414B /* AgreementConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6F2452B01DAFE0098414B /* AgreementConfig.swift */; };
DBF6F2482B01E20A0098414B /* ConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6F2472B01E20A0098414B /* ConfigTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -243,6 +246,9 @@
9D5B06CAA99EA5CD49CBE2BB /* Pods-App-Core.debugdev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.debugdev.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.debugdev.xcconfig"; 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>"; };
DBF6F2402B014ADA0098414B /* FirebaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirebaseConfig.swift; sourceTree = "<group>"; };
DBF6F2452B01DAFE0098414B /* AgreementConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgreementConfig.swift; sourceTree = "<group>"; };
DBF6F2472B01E20A0098414B /* ConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -367,8 +373,8 @@
isa = PBXGroup;
children = (
CFC84955299FAC4D0055E497 /* Combine */,
CFC84951299F8B890055E497 /* Debounce.swift */,
0770DE1828D0847D006D8A5D /* BaseRouter.swift */,
0727876F28D23411002E9142 /* Config.swift */,
0231CDBD2922422D00032416 /* CSSInjector.swift */,
02280F5A294B4E6F0032823A /* Connectivity.swift */,
);
Expand Down Expand Up @@ -559,11 +565,22 @@
CFC84955299FAC4D0055E497 /* Combine */ = {
isa = PBXGroup;
children = (
CFC84951299F8B890055E497 /* Debounce.swift */,
DBF6F2422B014AF30098414B /* Config */,
);
path = Combine;
sourceTree = "<group>";
};
DBF6F2422B014AF30098414B /* Config */ = {
isa = PBXGroup;
children = (
0727876F28D23411002E9142 /* Config.swift */,
DBF6F2402B014ADA0098414B /* FirebaseConfig.swift */,
DBF6F2452B01DAFE0098414B /* AgreementConfig.swift */,
DBF6F2472B01E20A0098414B /* ConfigTests.swift */,
);
path = Config;
sourceTree = "<group>";
};
F1620A3A2C8B0699EAA61B57 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -638,6 +655,7 @@
TargetAttributes = {
07169468296D996800E3DED6 = {
CreatedOnToolsVersion = 14.2;
LastSwiftMigration = 1500;
};
0770DE0728D07831006D8A5D = {
CreatedOnToolsVersion = 14.0;
Expand Down Expand Up @@ -738,6 +756,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DBF6F2482B01E20A0098414B /* ConfigTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -747,6 +766,7 @@
files = (
0727878528D31657002E9142 /* Data_User.swift in Sources */,
02F6EF4A28D9F0A700835477 /* DateExtension.swift in Sources */,
DBF6F2462B01DAFE0098414B /* AgreementConfig.swift in Sources */,
027BD3AF2909475000392132 /* DismissKeyboardTapHandler.swift in Sources */,
02E225B0291D29EB0067769A /* UrlExtension.swift in Sources */,
0770DE7928D0C4A9006D8A5D /* RoundedCorners.swift in Sources */,
Expand Down Expand Up @@ -810,6 +830,7 @@
0770DE1928D0847D006D8A5D /* BaseRouter.swift in Sources */,
0284DBFE28D48C5300830893 /* CourseItem.swift in Sources */,
0248C92329C075EF00DC8402 /* CourseBlockModel.swift in Sources */,
DBF6F2412B014ADA0098414B /* FirebaseConfig.swift in Sources */,
072787B628D37A0E002E9142 /* Validator.swift in Sources */,
0236961D28F9A2D200EEF206 /* Data_AuthResponse.swift in Sources */,
02B2B594295C5C7A00914876 /* Thread.swift in Sources */,
Expand Down Expand Up @@ -974,6 +995,7 @@
02DD1C9B29E80CE400F35DCE /* DebugStage */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -986,6 +1008,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -1086,6 +1109,7 @@
02DD1C9E29E80CED00F35DCE /* ReleaseStage */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -1106,6 +1130,7 @@
07169470296D996900E3DED6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -1118,6 +1143,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1126,6 +1152,7 @@
07169471296D996900E3DED6 /* DebugProd */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -1138,6 +1165,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1146,6 +1174,7 @@
07169472296D996900E3DED6 /* DebugDev */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -1158,6 +1187,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1166,6 +1196,7 @@
07169473296D996900E3DED6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -1186,6 +1217,7 @@
07169474296D996900E3DED6 /* ReleaseProd */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand All @@ -1206,6 +1238,7 @@
07169475296D996900E3DED6 /* ReleaseDev */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = L8PG7LC3Y3;
Expand Down
9 changes: 3 additions & 6 deletions Core/Core/Configuration/CSSInjector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ public class CSSInjector {

public let baseURL: URL

public init(baseURL: String) {
guard let url = URL(string: baseURL) else {
fatalError("Ivalid baseURL")
}
self.baseURL = url
public init(config: ConfigProtocol) {
self.baseURL = config.baseURL
}

public enum CssType {
Expand Down Expand Up @@ -151,7 +148,7 @@ public class CSSInjector {
#if DEBUG
public class CSSInjectorMock: CSSInjector {
public convenience init() {
self.init(baseURL: "https://google.com/")
self.init(config: ConfigMock())
}
}
#endif
36 changes: 36 additions & 0 deletions Core/Core/Configuration/Combine/Config/AgreementConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AgreementConfig.swift
// Core
//
// Created by Muhammad Umer on 11/13/23.
//

import Foundation

public protocol AgreementConfigProtocol {
var privacyPolicyURL: URL? { get }
var tosURL: URL? { get }
}

private enum AgreementKeys: String {
case privacyPolicyURL = "PRIVACY_POLICY_URL"
case tosURL = "TOS_URL"
}

public class AgreementConfig: NSObject, AgreementConfigProtocol {
public var privacyPolicyURL: URL?
public var tosURL: URL?

init(dictionary: [String: AnyObject]) {
privacyPolicyURL = (dictionary[AgreementKeys.privacyPolicyURL.rawValue] as? String).flatMap(URL.init)
tosURL = (dictionary[AgreementKeys.tosURL.rawValue] as? String).flatMap(URL.init)
super.init()
}
}

private let key = "AGREEMENT_URLS"
extension Config {
public var agreementConfig: AgreementConfigProtocol {
return AgreementConfig(dictionary: self[key] as? [String: AnyObject] ?? [:])
}
}
Loading

0 comments on commit af58789

Please sign in to comment.