Skip to content

Commit

Permalink
Merge pull request #281 from openedx/develop
Browse files Browse the repository at this point in the history
Develop to main v1.4
  • Loading branch information
volodymyr-chekyrta authored Feb 12, 2024
2 parents 71bb314 + 9d214f1 commit 05d3073
Show file tree
Hide file tree
Showing 499 changed files with 30,417 additions and 4,761 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ jobs:
run:
source ci_scripts/ci_prepare_env.sh && setup_github_actions_environment

- run: |
xcversion installed
- name: SwiftLint
run:
bundle exec fastlane linting
Expand Down
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/
32 changes: 32 additions & 0 deletions Authorization/Authorization.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
0770DE6B28D0C035006D8A5D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0770DE6D28D0C035006D8A5D /* Localizable.strings */; };
0770DE7128D0C0E7006D8A5D /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0770DE7028D0C0E7006D8A5D /* Strings.swift */; };
5FB79D2802949372CDAF08D6 /* Pods_App_Authorization_AuthorizationTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FAE9B7FD61FF88C9C4FE1E8 /* Pods_App_Authorization_AuthorizationTests.framework */; };
BA8B3A322AD5487300D25EF5 /* SocialAuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8B3A312AD5487300D25EF5 /* SocialAuthView.swift */; };
BADB3F552AD6DFC3004D5CFA /* SocialAuthViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BADB3F542AD6DFC3004D5CFA /* SocialAuthViewModel.swift */; };
DE843D6BB1B9DDA398494890 /* Pods_App_Authorization.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47BCFB7C19382EECF15131B6 /* Pods_App_Authorization.framework */; };
E03261642AE64676002CA7EB /* StartupViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E03261632AE64676002CA7EB /* StartupViewModel.swift */; };
E03261662AE64AF4002CA7EB /* StartupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E03261652AE64AF4002CA7EB /* StartupView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -75,6 +79,10 @@
96C85172770225EB81A6D2DA /* Pods-App-Authorization.releasedev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Authorization.releasedev.xcconfig"; path = "Target Support Files/Pods-App-Authorization/Pods-App-Authorization.releasedev.xcconfig"; sourceTree = "<group>"; };
9BF6A1004A955E24527FCF0F /* Pods-App-Authorization-AuthorizationTests.releaseprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Authorization-AuthorizationTests.releaseprod.xcconfig"; path = "Target Support Files/Pods-App-Authorization-AuthorizationTests/Pods-App-Authorization-AuthorizationTests.releaseprod.xcconfig"; sourceTree = "<group>"; };
A99D45203C981893C104053A /* Pods-App-Authorization-AuthorizationTests.releasestage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Authorization-AuthorizationTests.releasestage.xcconfig"; path = "Target Support Files/Pods-App-Authorization-AuthorizationTests/Pods-App-Authorization-AuthorizationTests.releasestage.xcconfig"; sourceTree = "<group>"; };
BA8B3A312AD5487300D25EF5 /* SocialAuthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialAuthView.swift; sourceTree = "<group>"; };
BADB3F542AD6DFC3004D5CFA /* SocialAuthViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialAuthViewModel.swift; sourceTree = "<group>"; };
E03261632AE64676002CA7EB /* StartupViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartupViewModel.swift; sourceTree = "<group>"; };
E03261652AE64AF4002CA7EB /* StartupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartupView.swift; sourceTree = "<group>"; };
E78971D8E6ED2116BBF9FD66 /* Pods-App-Authorization.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Authorization.release.xcconfig"; path = "Target Support Files/Pods-App-Authorization/Pods-App-Authorization.release.xcconfig"; sourceTree = "<group>"; };
F52826C68AEA1CF4769389EA /* Pods-App-Authorization.releasestage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Authorization.releasestage.xcconfig"; path = "Target Support Files/Pods-App-Authorization/Pods-App-Authorization.releasestage.xcconfig"; sourceTree = "<group>"; };
F5802BBA113276950ABCD9B3 /* Pods-App-Authorization.releaseprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Authorization.releaseprod.xcconfig"; path = "Target Support Files/Pods-App-Authorization/Pods-App-Authorization.releaseprod.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -139,6 +147,8 @@
071009CC28D1E24000344290 /* Presentation */ = {
isa = PBXGroup;
children = (
BA8B3A302AD5485100D25EF5 /* SocialAuth */,
E03261622AE6464A002CA7EB /* Startup */,
020C31BD290AADA700D6DEA2 /* Base */,
071009C528D1D9FA00344290 /* Login */,
07169462296D93E000E3DED6 /* Registration */,
Expand Down Expand Up @@ -258,6 +268,24 @@
path = ../Pods;
sourceTree = "<group>";
};
BA8B3A302AD5485100D25EF5 /* SocialAuth */ = {
isa = PBXGroup;
children = (
BA8B3A312AD5487300D25EF5 /* SocialAuthView.swift */,
BADB3F542AD6DFC3004D5CFA /* SocialAuthViewModel.swift */,
);
path = SocialAuth;
sourceTree = "<group>";
};
E03261622AE6464A002CA7EB /* Startup */ = {
isa = PBXGroup;
children = (
E03261632AE64676002CA7EB /* StartupViewModel.swift */,
E03261652AE64AF4002CA7EB /* StartupView.swift */,
);
path = Startup;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -467,16 +495,20 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BADB3F552AD6DFC3004D5CFA /* SocialAuthViewModel.swift in Sources */,
02066B442906D72400F4307E /* SignUpView.swift in Sources */,
0770DE7128D0C0E7006D8A5D /* Strings.swift in Sources */,
025F40E229D360E20064C183 /* ResetPasswordViewModel.swift in Sources */,
02066B462906D72F00F4307E /* SignUpViewModel.swift in Sources */,
E03261642AE64676002CA7EB /* StartupViewModel.swift in Sources */,
02A2ACDB2A4B016100FBBBBB /* AuthorizationAnalytics.swift in Sources */,
025F40E029D1E2FC0064C183 /* ResetPasswordView.swift in Sources */,
020C31CB290BF49900D6DEA2 /* FieldsView.swift in Sources */,
0770DE4E28D0A677006D8A5D /* SignInView.swift in Sources */,
02F3BFE5292533720051930C /* AuthorizationRouter.swift in Sources */,
E03261662AE64AF4002CA7EB /* StartupView.swift in Sources */,
071009C728D1DA4F00344290 /* SignInViewModel.swift in Sources */,
BA8B3A322AD5487300D25EF5 /* SocialAuthView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@

import Foundation

public enum LoginMethod: String {
case password = "Password"
public enum AuthMethod: Equatable {
case password
case socailAuth(SocialAuthMethod)

public var analyticsValue: String {
switch self {
case .password:
"Password"
case .socailAuth(let socialAuthMethod):
socialAuthMethod.rawValue
}
}
}

public enum SocialAuthMethod: String {
case facebook = "Facebook"
case google = "Google"
case microsoft = "Microsoft"
case apple = "Apple"
}

//sourcery: AutoMockable
public protocol AuthorizationAnalytics {
func setUserID(_ id: String)
func userLogin(method: LoginMethod)
func userLogin(method: AuthMethod)
func signUpClicked()
func createAccountClicked()
func registrationSuccess()
Expand All @@ -28,7 +42,7 @@ public protocol AuthorizationAnalytics {
#if DEBUG
class AuthorizationAnalyticsMock: AuthorizationAnalytics {
public func setUserID(_ id: String) {}
public func userLogin(method: LoginMethod) {}
public func userLogin(method: AuthMethod) {}
public func signUpClicked() {}
public func createAccountClicked() {}
public func registrationSuccess() {}
Expand Down
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
75 changes: 61 additions & 14 deletions Authorization/Authorization/Presentation/Base/FieldsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@

import SwiftUI
import Core
import Theme

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
@State private var text: String = ""

@State private var sendMarketing: Bool = true

var body: some View {
ForEach(0..<fields.count, id: \.self) { index in
let config = fields[index]
Expand Down Expand Up @@ -54,23 +56,68 @@ struct FieldsView: View {
case .checkbox:
EmptyView()
.id(index)
Text("Checkbox is not support")
case .plaintext:
HTMLFormattedText(
cssInjector.injectCSS(
colorScheme: colorScheme,
html: config.field.label,
type: .discovery,
fontSize: 90, screenWidth: proxy.size.width)
)
.id(UUID())
.padding(.horizontal, -6)

plaintext(fieldConfig: config)
case .unknown:
Text("This field not support")
}
}
}

@ViewBuilder
private func plaintext(fieldConfig: FieldConfiguration) -> some View {
if fieldConfig.field.isHonorCode,
let eulaURL = config.agreement.eulaURL,
let tosURL = config.agreement.tosURL,
let policy = config.agreement.privacyPolicyURL {
let text = AuthLocalization.SignUp.agreement(
"\(config.platformName)",
eulaURL,
"\(config.platformName)",
tosURL,
"\(config.platformName)",
policy
)
let checkBox = fields.first(where: { $0.field.type == .checkbox })
checkBox.flatMap { _ in
CheckBoxView(
checked: $sendMarketing,
text: AuthLocalization.SignUp.marketingEmailTitle("\(config.platformName)"),
font: Theme.Fonts.labelSmall
)
.padding(.vertical, 10)
.onAppear {
checkBox?.text = "\(sendMarketing)"
}
.onChange(of: sendMarketing) { newValue in
checkBox?.text = "\(newValue)"
}
}
Text(.init(text))
.tint(Theme.Colors.accentColor)
.foregroundStyle(Theme.Colors.textSecondary)
.font(Theme.Fonts.labelSmall)
.padding(.vertical, 3)
.id(UUID())
.environment(\.openURL, OpenURLAction(handler: handleURL))
Divider()
} else {
HTMLFormattedText(
cssInjector.injectCSS(
colorScheme: colorScheme,
html: fieldConfig.field.label,
type: .discovery,
fontSize: 90, screenWidth: proxy.size.width)
)
.id(UUID())
.padding(.horizontal, -6)
}
}

private func handleURL(_ url: URL) -> OpenURLAction.Result {
router.showWebBrowser(title: url.host ?? "", url: url)
return .handled
}
}

#if DEBUG
Expand Down Expand Up @@ -107,7 +154,7 @@ struct FieldsView_Previews: PreviewProvider {
FieldsView(
fields: fields,
router: AuthorizationRouterMock(),
configuration: ConfigMock(),
config: ConfigMock(),
cssInjector: CSSInjectorMock(),
proxy: proxy
)
Expand Down
Loading

0 comments on commit 05d3073

Please sign in to comment.