Skip to content

Commit 1176986

Browse files
committed
fix: refactors [#246]
1 parent f54a24b commit 1176986

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

packages/clerk_flutter/lib/src/widgets/authentication/clerk_sign_up_panel.dart

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class _ClerkSignUpPanelState extends State<ClerkSignUpPanel>
223223
_CodeInputBox(
224224
attribute: attr,
225225
value: _values[attr] ?? '',
226+
localizations: l10ns,
226227
closed: _state.isInput ||
227228
signUp?.unverified(clerk.Field.forUserAttribute(attr)) != true,
228229
onSubmit: (code) async {
@@ -421,7 +422,9 @@ class _LegalAcceptanceConfirmation extends StatelessWidget {
421422
..onTap = () => launchUrlString(url),
422423
),
423424
);
424-
spans.add(TextSpan(text: segmentText));
425+
if (segmentText.isNotEmpty) {
426+
spans.add(TextSpan(text: segmentText));
427+
}
425428
}
426429

427430
return spans;
@@ -430,6 +433,13 @@ class _LegalAcceptanceConfirmation extends StatelessWidget {
430433
return [TextSpan(text: text)];
431434
}
432435

436+
// We're assuming here that, whatever language has had its localizations
437+
// generated, the `termsOfService` and `privacyPolicy` will be literal
438+
// unique substrings of `acceptTerms`, so can be turned into links in
439+
// this manner - and it's the responsibility of the engineer dealing with
440+
// translations to ensure that's the case, so that this will work. (I'm not
441+
// aware of any language where that won't work, but would love to be told
442+
// if there is one.)
433443
List<InlineSpan> _spans(BuildContext context) {
434444
final authState = ClerkAuth.of(context, listen: false);
435445
final display = authState.env.display;
@@ -461,6 +471,7 @@ class _CodeInputBox extends StatefulWidget {
461471
required this.attribute,
462472
required this.onResend,
463473
required this.onSubmit,
474+
required this.localizations,
464475
required this.closed,
465476
required this.value,
466477
});
@@ -471,6 +482,8 @@ class _CodeInputBox extends StatefulWidget {
471482

472483
final VoidCallback onResend;
473484

485+
final ClerkSdkLocalizations localizations;
486+
474487
final bool closed;
475488

476489
final String value;
@@ -490,8 +503,6 @@ class _CodeInputBoxState extends State<_CodeInputBox> {
490503

491504
@override
492505
Widget build(BuildContext context) {
493-
final localizations = ClerkAuth.localizationsOf(context);
494-
495506
return Closeable(
496507
closed: widget.closed,
497508
onEnd: (closed) {
@@ -509,12 +520,12 @@ class _CodeInputBoxState extends State<_CodeInputBox> {
509520
focusNode: _focus,
510521
title: switch (widget.attribute) {
511522
clerk.UserAttribute.emailAddress =>
512-
localizations.verifyYourEmailAddress,
523+
widget.localizations.verifyYourEmailAddress,
513524
clerk.UserAttribute.phoneNumber =>
514-
localizations.verifyYourPhoneNumber,
525+
widget.localizations.verifyYourPhoneNumber,
515526
_ => widget.attribute.toString(),
516527
},
517-
subtitle: localizations.enterTheCodeSentTo(widget.value),
528+
subtitle: widget.localizations.enterTheCodeSentTo(widget.value),
518529
onSubmit: widget.onSubmit,
519530
),
520531
Padding(
@@ -525,7 +536,7 @@ class _CodeInputBoxState extends State<_CodeInputBox> {
525536
child: ClerkMaterialButton(
526537
style: ClerkMaterialButtonStyle.light,
527538
onPressed: widget.onResend,
528-
label: Text(localizations.resend),
539+
label: Text(widget.localizations.resend),
529540
),
530541
),
531542
),

0 commit comments

Comments
 (0)