verification before payment and email fixes
This commit is contained in:
@@ -23,6 +23,7 @@ class TwoFactorCodePage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<TwoFactorProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final email = provider.pendingLogin?.target ?? '';
|
||||
if (provider.verificationSuccess) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
onVerificationSuccess();
|
||||
@@ -36,7 +37,7 @@ class TwoFactorCodePage extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const TwoFactorPromptText(),
|
||||
TwoFactorPromptText(email: email),
|
||||
const SizedBox(height: 32),
|
||||
TwoFactorCodeInput(
|
||||
onCompleted: (code) => provider.submitCode(code),
|
||||
@@ -45,7 +46,12 @@ class TwoFactorCodePage extends StatelessWidget {
|
||||
if (provider.isSubmitting)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
else
|
||||
const ResendCodeButton(),
|
||||
ResendCodeButton(
|
||||
onPressed: provider.resendCode,
|
||||
isCooldownActive: provider.isCooldownActive,
|
||||
isResending: provider.isResending,
|
||||
cooldownRemainingSeconds: provider.cooldownRemainingSeconds,
|
||||
),
|
||||
if (provider.hasError) ...[
|
||||
const SizedBox(height: 12),
|
||||
ErrorMessage(error: AppLocalizations.of(context)!.twoFactorError),
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pweb/providers/two_factor.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class TwoFactorPromptText extends StatelessWidget {
|
||||
const TwoFactorPromptText({super.key});
|
||||
final String email;
|
||||
|
||||
const TwoFactorPromptText({
|
||||
super.key,
|
||||
required this.email,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Text(
|
||||
AppLocalizations.of(context)!.twoFactorPrompt(
|
||||
context.watch<TwoFactorProvider>().pendingLogin?.target ?? '',
|
||||
),
|
||||
AppLocalizations.of(context)!.twoFactorPrompt(email),
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pweb/providers/two_factor.dart';
|
||||
import 'package:pweb/utils/cooldown_format.dart';
|
||||
import 'package:pweb/widgets/resend_link.dart';
|
||||
|
||||
@@ -10,23 +7,33 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class ResendCodeButton extends StatelessWidget {
|
||||
const ResendCodeButton({super.key});
|
||||
final VoidCallback onPressed;
|
||||
final bool isCooldownActive;
|
||||
final bool isResending;
|
||||
final int cooldownRemainingSeconds;
|
||||
|
||||
const ResendCodeButton({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.isCooldownActive,
|
||||
required this.isResending,
|
||||
required this.cooldownRemainingSeconds,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localizations = AppLocalizations.of(context)!;
|
||||
final provider = context.watch<TwoFactorProvider>();
|
||||
final isDisabled = provider.isCooldownActive || provider.isResending;
|
||||
final isDisabled = isCooldownActive || isResending;
|
||||
|
||||
final label = provider.isCooldownActive
|
||||
? '${localizations.twoFactorResend} (${formatCooldownSeconds(provider.cooldownRemainingSeconds)})'
|
||||
final label = isCooldownActive
|
||||
? '${localizations.twoFactorResend} (${formatCooldownSeconds(cooldownRemainingSeconds)})'
|
||||
: localizations.twoFactorResend;
|
||||
|
||||
return ResendLink(
|
||||
label: label,
|
||||
onPressed: provider.resendCode,
|
||||
onPressed: onPressed,
|
||||
isDisabled: isDisabled,
|
||||
isLoading: provider.isResending,
|
||||
isLoading: isResending,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user