adding i18n base project
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:http/http.dart' as http;
|
||||
import '../../Utils/color_constants.dart';
|
||||
import '../../Utils/image_constant.dart';
|
||||
import '../../Utils/size_utils.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../../providers/token_manager.dart';
|
||||
import '../../resources/api_constants.dart';
|
||||
import '../../theme/app_style.dart';
|
||||
@@ -21,6 +22,7 @@ class ForgotPasswordPage extends StatefulWidget {
|
||||
class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
|
||||
final TextEditingController emailController = TextEditingController();
|
||||
String message = '';
|
||||
bool linkSent = false;
|
||||
bool isLoading = false; // Added to track loading state
|
||||
|
||||
Future<void> sendForgotPasswordRequest() async {
|
||||
@@ -42,7 +44,9 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
setState(() {
|
||||
message = 'An email with a reset link has been sent to $email.';
|
||||
message = AppLocalizations.of(context)!
|
||||
.forgotPasswordSentMessage(emailController.text);
|
||||
linkSent = true;
|
||||
});
|
||||
|
||||
// Delay for 3 seconds and then navigate to the login page
|
||||
@@ -52,7 +56,9 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
message = 'Failed to send the reset link. Please try again.';
|
||||
message =
|
||||
AppLocalizations.of(context)!.forgotPasswordFailedMessage;
|
||||
linkSent = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,7 +82,8 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
centerTitle: true,
|
||||
title: AppbarTitle(text: "Forgot Password")),
|
||||
title: AppbarTitle(
|
||||
text: AppLocalizations.of(context)!.forgotPassword)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
@@ -88,19 +95,20 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email",
|
||||
Text(AppLocalizations.of(context)!.email,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
hintText: "Enter Email",
|
||||
hintText:
|
||||
AppLocalizations.of(context)!.enterEmail,
|
||||
controller: emailController,
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
CustomButton(
|
||||
height: getVerticalSize(50),
|
||||
text: "Send me an access link",
|
||||
text: AppLocalizations.of(context)!.sendAccessLink,
|
||||
margin: getMargin(top: 24, bottom: 5),
|
||||
onTap: () async {
|
||||
sendForgotPasswordRequest();
|
||||
@@ -111,9 +119,10 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
|
||||
color: ColorConstant.blue700,
|
||||
) // Show loading indicator when isLoading is true
|
||||
: Text(message, style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
if (message.contains('An email with a reset link'))
|
||||
if (linkSent)
|
||||
InkWell(
|
||||
child: Text('Click here to return to login',
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.backToLogin,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
|
||||
Reference in New Issue
Block a user