Skip to content

Commit f4618d1

Browse files
committed
fix: refactors [#246]
1 parent 5df890d commit f4618d1

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
@@ -212,6 +212,7 @@ class _ClerkSignUpPanelState extends State<ClerkSignUpPanel>
212212
_CodeInputBox(
213213
attribute: attr,
214214
value: _values[attr] ?? '',
215+
localizations: l10ns,
215216
closed: _state.isInput ||
216217
signUp?.unverified(clerk.Field.forUserAttribute(attr)) != true,
217218
onSubmit: (code) async {
@@ -409,7 +410,9 @@ class _LegalAcceptanceConfirmation extends StatelessWidget {
409410
..onTap = () => launchUrlString(url),
410411
),
411412
);
412-
spans.add(TextSpan(text: segmentText));
413+
if (segmentText.isNotEmpty) {
414+
spans.add(TextSpan(text: segmentText));
415+
}
413416
}
414417

415418
return spans;
@@ -418,6 +421,13 @@ class _LegalAcceptanceConfirmation extends StatelessWidget {
418421
return [TextSpan(text: text)];
419422
}
420423

424+
// We're assuming here that, whatever language has had its localizations
425+
// generated, the `termsOfService` and `privacyPolicy` will be literal
426+
// unique substrings of `acceptTerms`, so can be turned into links in
427+
// this manner - and it's the responsibility of the engineer dealing with
428+
// translations to ensure that's the case, so that this will work. (I'm not
429+
// aware of any language where that won't work, but would love to be told
430+
// if there is one.)
421431
List<InlineSpan> _spans(BuildContext context) {
422432
final authState = ClerkAuth.of(context, listen: false);
423433
final display = authState.env.display;
@@ -449,6 +459,7 @@ class _CodeInputBox extends StatefulWidget {
449459
required this.attribute,
450460
required this.onResend,
451461
required this.onSubmit,
462+
required this.localizations,
452463
required this.closed,
453464
required this.value,
454465
});
@@ -459,6 +470,8 @@ class _CodeInputBox extends StatefulWidget {
459470

460471
final VoidCallback onResend;
461472

473+
final ClerkSdkLocalizations localizations;
474+
462475
final bool closed;
463476

464477
final String value;
@@ -478,8 +491,6 @@ class _CodeInputBoxState extends State<_CodeInputBox> {
478491

479492
@override
480493
Widget build(BuildContext context) {
481-
final localizations = ClerkAuth.localizationsOf(context);
482-
483494
return Closeable(
484495
closed: widget.closed,
485496
onEnd: (closed) {
@@ -497,12 +508,12 @@ class _CodeInputBoxState extends State<_CodeInputBox> {
497508
focusNode: _focus,
498509
title: switch (widget.attribute) {
499510
clerk.UserAttribute.emailAddress =>
500-
localizations.verifyYourEmailAddress,
511+
widget.localizations.verifyYourEmailAddress,
501512
clerk.UserAttribute.phoneNumber =>
502-
localizations.verifyYourPhoneNumber,
513+
widget.localizations.verifyYourPhoneNumber,
503514
_ => widget.attribute.toString(),
504515
},
505-
subtitle: localizations.enterTheCodeSentTo(widget.value),
516+
subtitle: widget.localizations.enterTheCodeSentTo(widget.value),
506517
onSubmit: widget.onSubmit,
507518
),
508519
Padding(
@@ -513,7 +524,7 @@ class _CodeInputBoxState extends State<_CodeInputBox> {
513524
child: ClerkMaterialButton(
514525
style: ClerkMaterialButtonStyle.light,
515526
onPressed: widget.onResend,
516-
label: Text(localizations.resend),
527+
label: Text(widget.localizations.resend),
517528
),
518529
),
519530
),

0 commit comments

Comments
 (0)