Frontend first draft
This commit is contained in:
61
frontend/pweb/lib/pages/2fa/page.dart
Normal file
61
frontend/pweb/lib/pages/2fa/page.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pweb/pages/2fa/error_message.dart';
|
||||
import 'package:pweb/pages/2fa/input.dart';
|
||||
import 'package:pweb/pages/2fa/prompt.dart';
|
||||
import 'package:pweb/pages/2fa/resend.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:pweb/providers/two_factor.dart';
|
||||
|
||||
|
||||
|
||||
class TwoFactorCodePage extends StatelessWidget {
|
||||
final VoidCallback onVerificationSuccess;
|
||||
|
||||
const TwoFactorCodePage({
|
||||
super.key,
|
||||
required this.onVerificationSuccess,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<TwoFactorProvider>(
|
||||
builder: (context, provider, child) {
|
||||
if (provider.verificationSuccess) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
onVerificationSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const TwoFactorPromptText(),
|
||||
const SizedBox(height: 32),
|
||||
TwoFactorCodeInput(
|
||||
onCompleted: (code) => provider.submitCode(code),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (provider.isSubmitting)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
else
|
||||
const ResendCodeButton(),
|
||||
if (provider.hasError) ...[
|
||||
const SizedBox(height: 12),
|
||||
ErrorMessage(error: AppLocalizations.of(context)!.twoFactorError),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user