Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop to main v2.1 #566

Merged
merged 17 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 16 additions & 6 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: SwiftLint

on:
workflow_dispatch:

pull_request:

jobs:
Expand All @@ -11,8 +10,6 @@ jobs:
runs-on: macos-latest

concurrency:
# When running on develop, use the sha to allow all runs of this workflow to run concurrently.
# Otherwise only allow a single run of this workflow on each branch, automatically cancelling older runs.
group: ${{ github.ref == 'refs/heads/develop' && format('swiftlint-develop-{0}', github.sha) || format('swiftlint-{0}', github.ref) }}
cancel-in-progress: true

Expand All @@ -29,9 +26,22 @@ jobs:
${{ runner.os }}-gems-

- name: Setup environment
run:
run: |
source ci_scripts/ci_prepare_env.sh && setup_github_actions_environment
xcodes select 16.1

- name: SwiftLint
run:
bundle exec fastlane linting
run: |
export PODS_ROOT=$(pwd)/Pods
"${PODS_ROOT}/SwiftLint/swiftlint" --reporter sarif > swiftlint.report.sarif

- name: Prepare swiftlint.report.sarif
if: success() || failure()
run: |
swift PrepareSarifToUpload.swift

- name: Upload report
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: swiftlint.report.sarif
16 changes: 6 additions & 10 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
warning_threshold: 1
disabled_rules: # rule identifiers to exclude from running
- identifier_name
- comment_spacing
Expand Down Expand Up @@ -31,6 +32,7 @@ excluded: # paths to ignore during linting. Takes precedence over `included`.
- Core/Core/SwiftGen
- Authorization/Authorization/SwiftGen
- Course/Course/SwiftGen
- Discussion/Discussion/SwiftGen
- Discovery/Discovery/SwiftGen
- Dashboard/Dashboard/SwiftGen
- Profile/Profile/SwiftGen
Expand All @@ -48,14 +50,15 @@ excluded: # paths to ignore during linting. Takes precedence over `included`.
force_try: error

line_length: 120
type_body_length: 300
type_body_length: 600
function_body_length: 100

trailing_whitespace:
ignores_empty_lines: true

file_length:
warning: 500
error: 1200
warning: 850
error: 1500

function_parameter_count:
warning: 10
Expand All @@ -70,11 +73,4 @@ type_name:
- iPhone
- API

identifier_name:
min_length: # only min_length
error: 1 # only error
# excluded: # excluded via string array
# - id
# - URL
# - GlobalAPIKey
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown)
18 changes: 9 additions & 9 deletions Authorization/Authorization.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = DebugStage;
Expand Down Expand Up @@ -829,7 +829,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = ReleaseStage;
Expand Down Expand Up @@ -1054,7 +1054,7 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = DebugDev;
Expand Down Expand Up @@ -1146,7 +1146,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = ReleaseDev;
Expand Down Expand Up @@ -1245,7 +1245,7 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = DebugProd;
Expand Down Expand Up @@ -1337,7 +1337,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = ReleaseProd;
Expand Down Expand Up @@ -1494,7 +1494,7 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -1528,7 +1528,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -1605,7 +1605,7 @@
repositoryURL = "https://github.com/openedx/openedx-app-foundation-ios/";
requirement = {
kind = exactVersion;
version = 1.0.0;
version = 1.0.2;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import OEXFoundation
public enum AuthMethod: Equatable {
case password
case SSO
case socailAuth(SocialAuthMethod)
case socialAuth(SocialAuthMethod)

public var analyticsValue: String {
switch self {
case .password:
"password"
case .SSO:
"SSO"
case .socailAuth(let socialAuthMethod):
case .socialAuth(let socialAuthMethod):
socialAuthMethod.rawValue
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation
import Core

//sourcery: AutoMockable
@MainActor
public protocol AuthorizationRouter: BaseRouter {
func showUpdateRequiredView(showAccountLink: Bool)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct FieldsView: View {
}

private func handleURL(_ url: URL) -> OpenURLAction.Result {
router.showWebBrowser(title: url.host ?? "", url: url)
router.showWebBrowser(title: "", url: url)
return .handled
}
}
Expand Down
74 changes: 42 additions & 32 deletions Authorization/Authorization/Presentation/Login/SignInView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public struct SignInView: View {
.foregroundColor(Theme.Colors.textPrimary)
.padding(.bottom, 20)
.accessibilityIdentifier("welcome_back_text")
if viewModel.socialAuthEnabled {
SocialAuthView(
viewModel: .init(
config: viewModel.config,
lastUsedOption: viewModel.storage.lastUsedSocialAuth
) { result in
Task { await viewModel.login(with: result) }
}
)
.padding(.top, 22)
.padding(.bottom, 16)
}
Text(AuthLocalization.SignIn.emailOrUsername)
.font(Theme.Fonts.labelLarge)
.foregroundColor(Theme.Colors.textPrimary)
Expand Down Expand Up @@ -104,9 +116,8 @@ public struct SignInView: View {
.foregroundColor(Theme.Colors.textPrimary)
.padding(.top, 18)
.accessibilityIdentifier("password_text")
SecureField("", text: $password)
SecureInputView($password)
.font(Theme.Fonts.bodyLarge)
.foregroundColor(Theme.Colors.textInputTextColor)
.padding(.all, 14)
.background(
Theme.InputFieldBackground(
Expand All @@ -124,7 +135,9 @@ public struct SignInView: View {
HStack {
if !viewModel.config.features.startupScreenEnabled {
Button(CoreLocalization.SignIn.registerBtn) {
viewModel.router.showRegisterScreen(sourceScreen: viewModel.sourceScreen)
viewModel.router.showRegisterScreen(
sourceScreen: viewModel.sourceScreen
)
}
.foregroundColor(Theme.Colors.accentColor)
.accessibilityIdentifier("register_button")
Expand Down Expand Up @@ -160,7 +173,7 @@ public struct SignInView: View {
}
}
if viewModel.config.uiComponents.samlSSOLoginEnabled {
if !viewModel.config.uiComponents.loginRegistrationEnabled{
if !viewModel.config.uiComponents.loginRegistrationEnabled {
VStack(alignment: .center) {
Text(AuthLocalization.SignIn.ssoHeading)
.font(Theme.Fonts.headlineSmall)
Expand All @@ -170,7 +183,7 @@ public struct SignInView: View {
.padding(.horizontal, 20)
.accessibilityIdentifier("signin_sso_heading")
}

Divider()

VStack(alignment: .center) {
Expand All @@ -191,9 +204,8 @@ public struct SignInView: View {
.accessibilityIdentifier("signin_sso_login_subtitle")
}
}

VStack(alignment: .center) {

if viewModel.isShowProgress {
HStack(alignment: .center) {
ProgressBar(size: 40, lineWidth: 8)
Expand All @@ -203,37 +215,34 @@ public struct SignInView: View {
} else {
let languageCode = Locale.current.language.languageCode?.identifier ?? "en"
if viewModel.config.uiComponents.samlSSODefaultLoginButton {
StyledButton(viewModel.config.ssoButtonTitle[languageCode] as! String, action: {
viewModel.router.showSSOWebBrowser(title: CoreLocalization.SignIn.logInBtn)
})
StyledButton(
viewModel.config.ssoButtonTitle[languageCode] as! String,
action: {
viewModel.router
.showSSOWebBrowser(title: CoreLocalization.SignIn.logInBtn)
}
)
.frame(maxWidth: .infinity)
.padding(.top, 20)
.accessibilityIdentifier("signin_SSO_button")
} else {
StyledButton(viewModel.config.ssoButtonTitle[languageCode] as! String, action: {
viewModel.router.showSSOWebBrowser(title: CoreLocalization.SignIn.logInBtn)
},
color: .white,
textColor: Theme.Colors.accentColor,
borderColor: Theme.Colors.accentColor)
StyledButton(
viewModel.config.ssoButtonTitle[languageCode] as! String,
action: {
viewModel.router
.showSSOWebBrowser(title: CoreLocalization.SignIn.logInBtn)
},
color: .white,
textColor: Theme.Colors.accentColor,
borderColor: Theme.Colors.accentColor)
.frame(maxWidth: .infinity)
.padding(.top, 20)
.accessibilityIdentifier("signin_SSO_button")
}

}
}
}
}
if viewModel.socialAuthEnabled {
SocialAuthView(
viewModel: .init(
config: viewModel.config
) { result in
Task { await viewModel.login(with: result) }
}
)
}
agreements
Spacer()
}
Expand Down Expand Up @@ -280,16 +289,16 @@ public struct SignInView: View {
.navigationBarHidden(true)
.ignoresSafeArea(.all, edges: .horizontal)
.background(Theme.Colors.background.ignoresSafeArea(.all))
.onFirstAppear{
.onFirstAppear {
viewModel.trackScreenEvent()
}
}

@ViewBuilder
private var agreements: some View {
if let eulaURL = viewModel.config.agreement.eulaURL,
let tosURL = viewModel.config.agreement.tosURL,
let policy = viewModel.config.agreement.privacyPolicyURL {
let tosURL = viewModel.config.agreement.tosURL,
let policy = viewModel.config.agreement.privacyPolicyURL {
let text = AuthLocalization.SignIn.agreement(
"\(viewModel.config.platformName)",
eulaURL,
Expand All @@ -307,9 +316,9 @@ public struct SignInView: View {
.environment(\.openURL, OpenURLAction(handler: handleURL))
}
}

private func handleURL(_ url: URL) -> OpenURLAction.Result {
viewModel.router.showWebBrowser(title: url.host ?? "", url: url)
viewModel.router.showWebBrowser(title: "", url: url)
return .handled
}
}
Expand All @@ -323,6 +332,7 @@ struct SignInView_Previews: PreviewProvider {
config: ConfigMock(),
analytics: AuthorizationAnalyticsMock(),
validator: Validator(),
storage: CoreStorageMock(),
sourceScreen: .default
)

Expand Down
Loading
Loading