Skip to content

Commit

Permalink
chore: resolve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eyatsenkoperpetio committed Feb 6, 2024
1 parent 22330db commit 3970454
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 34 deletions.
21 changes: 11 additions & 10 deletions Authorization/Authorization/Presentation/Base/FieldsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,32 @@ struct FieldsView: View {
EmptyView()
.id(index)
case .plaintext:
plaintext(config: config)
plaintext(fieldConfig: config)
case .unknown:
Text("This field not support")
}
}
}

@ViewBuilder
private func plaintext(config: FieldConfiguration) -> some View {
if config.field.isHonorCode,
let eulaURL = self.config.agreement.eulaURL,
let tosURL = self.config.agreement.tosURL,
let policy = self.config.agreement.privacyPolicyURL {
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(
"\(self.config.platformName)",
"\(config.platformName)",
eulaURL,
"\(self.config.platformName)",
"\(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("\(self.config.platformName)"),
text: AuthLocalization.SignUp.marketingEmailTitle("\(config.platformName)"),
font: Theme.Fonts.labelSmall
)
.padding(.vertical, 10)
Expand All @@ -104,7 +105,7 @@ struct FieldsView: View {
HTMLFormattedText(
cssInjector.injectCSS(
colorScheme: colorScheme,
html: config.field.label,
html: fieldConfig.field.label,
type: .discovery,
fontSize: 90, screenWidth: proxy.size.width)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public struct SignInView: View {
eulaURL,
"\(viewModel.config.platformName)",
tosURL,
"\(viewModel.config.platformName)",
policy
)
Text(.init(text))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct SignUpView: View {
}

let requiredFields = viewModel.requiredFields
let nonRequiredFields = viewModel.nonRequiredFields
let optionalFields = viewModel.optionalFields

FieldsView(
fields: requiredFields,
Expand All @@ -100,7 +100,7 @@ public struct SignUpView: View {
if !viewModel.isShowProgress {
DisclosureGroup(isExpanded: $disclosureGroupOpen) {
FieldsView(
fields: nonRequiredFields,
fields: optionalFields,
router: viewModel.router,
config: viewModel.config,
cssInjector: viewModel.cssInjector,
Expand Down Expand Up @@ -162,10 +162,11 @@ public struct SignUpView: View {
.padding(.horizontal, 24)
.padding(.top, 24)

}.roundedBackground(Theme.Colors.background)
.onRightSwipeGesture {
viewModel.router.back()
}
}
.roundedBackground(Theme.Colors.background)
.onRightSwipeGesture {
viewModel.router.back()
}
.scrollAvoidKeyboard(dismissKeyboardByTap: true)
.onChange(of: viewModel.scrollTo, perform: { index in
withAnimation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public class SignUpViewModel: ObservableObject {

@Published var fields: [FieldConfiguration] = []
var requiredFields: [FieldConfiguration] {
fields
.filter {
fields.filter {
$0.field.required &&
!$0.field.isHonorCode &&
$0.field.type != .checkbox
Expand All @@ -44,7 +43,7 @@ public class SignUpViewModel: ObservableObject {
$0.field.type == .checkbox
}
}
var nonRequiredFields: [FieldConfiguration] {
var optionalFields: [FieldConfiguration] {
fields.filter { !$0.field.required }
}

Expand Down
12 changes: 6 additions & 6 deletions Authorization/Authorization/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public enum AuthLocalization {
public static let title = AuthLocalization.tr("Localizable", "FORGOT.TITLE", fallback: "Forgot password")
}
public enum SignIn {
/// By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data in
/// By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data in
/// accordance with the [Privacy Policy.](%@)
public static func agreement(_ p1: Any, _ p2: Any, _ p3: Any, _ p4: Any, _ p5: Any) -> String {
return AuthLocalization.tr("Localizable", "SIGN_IN.AGREEMENT", String(describing: p1), String(describing: p2), String(describing: p3), String(describing: p4), String(describing: p5), fallback: "By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data in\naccordance with the [Privacy Policy.](%@)")
public static func agreement(_ p1: Any, _ p2: Any, _ p3: Any, _ p4: Any, _ p5: Any, _ p6: Any) -> String {
return AuthLocalization.tr("Localizable", "SIGN_IN.AGREEMENT", String(describing: p1), String(describing: p2), String(describing: p3), String(describing: p4), String(describing: p5), String(describing: p6), fallback: "By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data in\naccordance with the [Privacy Policy.](%@)")
}
/// Email
public static let email = AuthLocalization.tr("Localizable", "SIGN_IN.EMAIL", fallback: "Email")
Expand All @@ -73,9 +73,9 @@ public enum AuthLocalization {
public static let welcomeBack = AuthLocalization.tr("Localizable", "SIGN_IN.WELCOME_BACK", fallback: "Welcome back! Please authorize to continue.")
}
public enum SignUp {
/// By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data inaccordance with the [Privacy Policy.](%@)
public static func agreement(_ p1: Any, _ p2: Any, _ p3: Any, _ p4: Any, _ p5: Any) -> String {
return AuthLocalization.tr("Localizable", "SIGN_UP.AGREEMENT", String(describing: p1), String(describing: p2), String(describing: p3), String(describing: p4), String(describing: p5), fallback: "By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data inaccordance with the [Privacy Policy.](%@)")
/// By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data inaccordance with the [Privacy Policy.](%@)
public static func agreement(_ p1: Any, _ p2: Any, _ p3: Any, _ p4: Any, _ p5: Any, _ p6: Any) -> String {
return AuthLocalization.tr("Localizable", "SIGN_UP.AGREEMENT", String(describing: p1), String(describing: p2), String(describing: p3), String(describing: p4), String(describing: p5), String(describing: p6), fallback: "By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data inaccordance with the [Privacy Policy.](%@)")
}
/// Create account
public static let createAccountBtn = AuthLocalization.tr("Localizable", "SIGN_UP.CREATE_ACCOUNT_BTN", fallback: "Create account")
Expand Down
4 changes: 2 additions & 2 deletions Authorization/Authorization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"SIGN_IN.EMAIL_OR_USERNAME" = "Email or username";
"SIGN_IN.PASSWORD" = "Password";
"SIGN_IN.FORGOT_PASS_BTN" = "Forgot password?";
"SIGN_IN.AGREEMENT" = "By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data in
"SIGN_IN.AGREEMENT" = "By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data in
accordance with the [Privacy Policy.](%@)";


Expand All @@ -29,7 +29,7 @@ accordance with the [Privacy Policy.](%@)";
"SIGN_UP.SHOW_FIELDS" = "Show optional Fields";
"SIGN_UP.SUCCESS_SIGNIN_LABEL" = "You've successfully signed in.";
"SIGN_UP.SUCCESS_SIGNIN_SUBLABEL" = "We just need a little more information before you start learning.";
"SIGN_UP.AGREEMENT" = "By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data inaccordance with the [Privacy Policy.](%@)";
"SIGN_UP.AGREEMENT" = "By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data inaccordance with the [Privacy Policy.](%@)";
"SIGN_UP.MARKETING_EMAIL_TITLE" = "I agree that %@ may send me marketing messages.";

"FORGOT.TITLE"= "Forgot password";
Expand Down
4 changes: 2 additions & 2 deletions Authorization/Authorization/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"SIGN_IN.EMAIL" = "Пошта";
"SIGN_IN.PASSWORD" = "Пароль";
"SIGN_IN.FORGOT_PASS_BTN" = "Забули пароль?";
"SIGN_IN.AGREEMENT" = "By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data in
"SIGN_IN.AGREEMENT" = "By signing in to this app, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data in
accordance with the [Privacy Policy.](%@)";

"ERROR.INVALID_EMAIL_ADDRESS" = "невірна адреса електронної пошти";
Expand All @@ -26,7 +26,7 @@ accordance with the [Privacy Policy.](%@)";
"SIGN_UP.SHOW_FIELDS" = "Показати необовʼязкові поля";
"SIGN_UP.SUCCESS_SIGNIN_LABEL" = "You've successfully signed in.";
"SIGN_UP.SUCCESS_SIGNIN_SUBLABEL" = "We just need a little more information before you start learning.";
"SIGN_UP.AGREEMENT" = "By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and vou acknowledge that edX and each Member process your personal data inaccordance with the [Privacy Policy.](%@)";
"SIGN_UP.AGREEMENT" = "By creating an account, you agree to the [%@ End User License Agreement](%@) and [%@ Terms of Service and Honor Code](%@) and you acknowledge that %@ and each Member process your personal data inaccordance with the [Privacy Policy.](%@)";
"SIGN_UP.MARKETING_EMAIL_TITLE" = "I agree that %@ may send me marketing messages.";

"FORGOT.TITLE"= "Відновлення паролю";
Expand Down
10 changes: 5 additions & 5 deletions Core/Core/Configuration/Config/AgreementConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

private enum AgreementKeys: String {
private enum AgreementKeys: String, RawStringExtractable {
case privacyPolicyURL = "PRIVACY_POLICY_URL"
case tosURL = "TOS_URL"
case cookiePolicyURL = "COOKIE_POLICY_URL"
Expand All @@ -25,10 +25,10 @@ public class AgreementConfig: NSObject {
public var supportedLanguages: [String]?

init(dictionary: [String: AnyObject]) {
supportedLanguages = dictionary[AgreementKeys.supportedLanguages.rawValue] as? [String]
cookiePolicyURL = (dictionary[AgreementKeys.cookiePolicyURL.rawValue] as? String).flatMap(URL.init)
dataSellContentURL = (dictionary[AgreementKeys.dataSellContentURL.rawValue] as? String).flatMap(URL.init)
eulaURL = (dictionary[AgreementKeys.eulaURL.rawValue] as? String).flatMap(URL.init)
supportedLanguages = dictionary[AgreementKeys.supportedLanguages] as? [String]
cookiePolicyURL = (dictionary[AgreementKeys.cookiePolicyURL] as? String).flatMap(URL.init)
dataSellContentURL = (dictionary[AgreementKeys.dataSellContentURL] as? String).flatMap(URL.init)
eulaURL = (dictionary[AgreementKeys.eulaURL] as? String).flatMap(URL.init)

super.init()

Expand Down

0 comments on commit 3970454

Please sign in to comment.