-
Notifications
You must be signed in to change notification settings - Fork 18
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
EULA link and checkbox for "send marketing messages" #273
Changes from 8 commits
fa90e18
4ff5e01
726cfeb
428a030
9d41146
a30527d
79a2ebf
22330db
3970454
d4f72ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import SwiftUI | ||
import Core | ||
import Theme | ||
|
||
struct FieldsView: View { | ||
|
||
|
@@ -17,7 +18,8 @@ struct FieldsView: View { | |
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] | ||
|
@@ -54,23 +56,67 @@ 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(config: 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 { | ||
let text = AuthLocalization.SignUp.agreement( | ||
"\(self.config.platformName)", | ||
eulaURL, | ||
"\(self.config.platformName)", | ||
tosURL, | ||
policy | ||
) | ||
let checkBox = fields.first(where: { $0.field.type == .checkbox }) | ||
checkBox.flatMap { _ in | ||
CheckBoxView( | ||
checked: $sendMarketing, | ||
text: AuthLocalization.SignUp.marketingEmailTitle("\(self.config.platformName)"), | ||
font: Theme.Fonts.labelSmall | ||
) | ||
.padding(.vertical, 10) | ||
.onAppear { | ||
checkBox?.text = "\(sendMarketing)" | ||
} | ||
.onChange(of: sendMarketing) { newValue in | ||
checkBox?.text = "\(newValue)" | ||
Comment on lines
+89
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to assign boolean text to text of the checkbox? I've commented the code and it was working fine. |
||
} | ||
} | ||
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: config.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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,15 +30,32 @@ public class SignUpViewModel: ObservableObject { | |
} | ||
|
||
@Published var fields: [FieldConfiguration] = [] | ||
|
||
var requiredFields: [FieldConfiguration] { | ||
fields | ||
.filter { | ||
$0.field.required && | ||
!$0.field.isHonorCode && | ||
$0.field.type != .checkbox | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please format it like
because at other places the same pattern is being used in this file. |
||
} | ||
var agreementsFields: [FieldConfiguration] { | ||
fields.filter { | ||
$0.field.isHonorCode || | ||
$0.field.type == .checkbox | ||
} | ||
} | ||
var nonRequiredFields: [FieldConfiguration] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about renaming it to optionalFields? |
||
fields.filter { !$0.field.required } | ||
} | ||
|
||
let router: AuthorizationRouter | ||
let config: ConfigProtocol | ||
let cssInjector: CSSInjector | ||
|
||
private let interactor: AuthInteractorProtocol | ||
private let analytics: AuthorizationAnalytics | ||
private let validator: Validator | ||
|
||
public init( | ||
interactor: AuthInteractorProtocol, | ||
router: AuthorizationRouter, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
"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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type |
||
accordance with the [Privacy Policy.](%@)"; | ||
|
||
|
||
"ERROR.INVALID_EMAIL_ADDRESS" = "Invalid email address"; | ||
"ERROR.INVALID_PASSWORD_LENGHT" = "Invalid password lenght"; | ||
|
@@ -26,6 +29,8 @@ | |
"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.](%@)"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"SIGN_UP.MARKETING_EMAIL_TITLE" = "I agree that %@ may send me marketing messages."; | ||
|
||
"FORGOT.TITLE"= "Forgot password"; | ||
"FORGOT.DESCRIPTION" = "Please enter your log-in or recovery email address below and we will send you an email with instructions."; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
config
parameter name is conflicting withself.config
. How about renaming it tofieldConfig
?