verification before payment and email fixes
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pweb/controllers/payout_verification.dart';
|
||||
import 'package:pweb/pages/payout_verification/page.dart';
|
||||
import 'package:pweb/utils/error/snackbar.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
Future<bool> runPayoutVerification({
|
||||
required BuildContext context,
|
||||
required PayoutVerificationController controller,
|
||||
}) async {
|
||||
final localizations = AppLocalizations.of(context)!;
|
||||
|
||||
if (controller.isCooldownActive) return false;
|
||||
|
||||
try {
|
||||
await controller.requestCode();
|
||||
} catch (e) {
|
||||
await notifyUserOfError(
|
||||
context: context,
|
||||
errorSituation: localizations.verificationFailed,
|
||||
exception: e,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.mounted) return false;
|
||||
|
||||
final verified = await Navigator.of(context).push<bool>(
|
||||
MaterialPageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => ChangeNotifierProvider.value(
|
||||
value: controller,
|
||||
child: const PayoutVerificationPage(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (verified == true) {
|
||||
controller.reset();
|
||||
} else {
|
||||
controller.resetStatus();
|
||||
}
|
||||
|
||||
return verified == true;
|
||||
}
|
||||
Reference in New Issue
Block a user