41 lines
1.0 KiB
Dart
41 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pweb/utils/cooldown_format.dart';
|
|
import 'package:pweb/widgets/resend_link.dart';
|
|
|
|
import 'package:pweb/generated/i18n/app_localizations.dart';
|
|
|
|
|
|
class ResendCodeButton extends StatelessWidget {
|
|
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 isDisabled = isCooldownActive || isResending;
|
|
|
|
final label = isCooldownActive
|
|
? '${localizations.twoFactorResend} (${formatCooldownSeconds(cooldownRemainingSeconds)})'
|
|
: localizations.twoFactorResend;
|
|
|
|
return ResendLink(
|
|
label: label,
|
|
onPressed: onPressed,
|
|
isDisabled: isDisabled,
|
|
isLoading: isResending,
|
|
);
|
|
}
|
|
|
|
}
|