forgot password screns logic fixed
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
||||
|
||||
import '../../../core/constants/assets.dart';
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../../core/theme/colors.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../../view_models/auth_view_model.dart';
|
||||
@@ -40,6 +41,10 @@ class _DesktopForgotPasswordCreatePageState
|
||||
void _viewModelListener() {
|
||||
if (viewModel.resetPasswordErrorMessage != null) {
|
||||
AppToast.error(context, viewModel.resetPasswordErrorMessage!);
|
||||
} else if (viewModel.isResetPasswordLoading == false &&
|
||||
viewModel.resetPasswordSuccess) {
|
||||
Router.neglect(context, () => const LoginScreenRoute().go(context));
|
||||
viewModel.clearResetFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,10 +151,11 @@ class _DesktopForgotPasswordCreatePageState
|
||||
),
|
||||
SizedBox(height: 80.0.h()),
|
||||
viewModel.isResetPasswordLoading
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
text: ForgotPasswordCreateStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/routes/app_routes.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
||||
|
||||
@@ -40,6 +41,10 @@ class _MobileForgotPasswordCreatePageState
|
||||
void _viewModelListener() {
|
||||
if (viewModel.resetPasswordErrorMessage != null) {
|
||||
AppToast.error(context, viewModel.resetPasswordErrorMessage!);
|
||||
} else if (viewModel.isResetPasswordLoading == false &&
|
||||
viewModel.resetPasswordSuccess) {
|
||||
Router.neglect(context, () => const LoginScreenRoute().go(context));
|
||||
viewModel.clearResetFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,10 +148,11 @@ class _MobileForgotPasswordCreatePageState
|
||||
),
|
||||
SizedBox(height: 80.0.h()),
|
||||
viewModel.isResetPasswordLoading
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
text: ForgotPasswordCreateStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
||||
|
||||
import '../../../core/constants/assets.dart';
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../../core/theme/colors.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../../view_models/auth_view_model.dart';
|
||||
@@ -40,6 +41,10 @@ class _TabletForgotPasswordCreatePageState
|
||||
void _viewModelListener() {
|
||||
if (viewModel.resetPasswordErrorMessage != null) {
|
||||
AppToast.error(context, viewModel.resetPasswordErrorMessage!);
|
||||
} else if (viewModel.isResetPasswordLoading == false &&
|
||||
viewModel.resetPasswordSuccess) {
|
||||
Router.neglect(context, () => const LoginScreenRoute().go(context));
|
||||
viewModel.clearResetFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,14 +151,16 @@ class _TabletForgotPasswordCreatePageState
|
||||
),
|
||||
SizedBox(height: 80.0.h()),
|
||||
viewModel.isResetPasswordLoading
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
text: ForgotPasswordCreateStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
text: ForgotPasswordCreateStrings.resetLink,
|
||||
|
||||
onPressed:
|
||||
viewModel.isNewPasswordValid
|
||||
? () async {
|
||||
|
||||
@@ -6,12 +6,12 @@ import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
|
||||
import '../../../core/constants/assets.dart';
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../../core/theme/colors.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../../view_models/auth_view_model.dart';
|
||||
import '../../shared/base_button.dart';
|
||||
import '../strings/forgot_password_otp_strings.dart';
|
||||
import '../../forget_password_create/pages/forgot_password_create_screen.dart';
|
||||
|
||||
class DesktopForgotPasswordOtpPage extends StatefulWidget {
|
||||
const DesktopForgotPasswordOtpPage({super.key});
|
||||
@@ -35,16 +35,14 @@ class _DesktopForgotPasswordOtpPageState
|
||||
void _viewModelListener() {
|
||||
if (viewModel.errorMessageOtp != null) {
|
||||
AppToast.error(context, viewModel.errorMessageOtp!);
|
||||
}
|
||||
|
||||
if (viewModel.resetToken != null) {
|
||||
} else if (!viewModel.isLoadingOtp &&
|
||||
viewModel.verifyOtpSuccess &&
|
||||
viewModel.resetToken != null) {
|
||||
Router.neglect(
|
||||
context,
|
||||
() => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ForgotPasswordCreateScreen()),
|
||||
),
|
||||
() => const ForgotPasswordCreateRouteData().pushReplacement(context),
|
||||
);
|
||||
viewModel.clearOtpFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +97,7 @@ class _DesktopForgotPasswordOtpPageState
|
||||
SizedBox(height: 40.0.h()),
|
||||
Pinput(
|
||||
controller: viewModel.otpController,
|
||||
length: 5,
|
||||
length: 6,
|
||||
pinAnimationType: PinAnimationType.scale,
|
||||
defaultPinTheme: PinTheme(
|
||||
width: 50.0.w(),
|
||||
@@ -117,20 +115,22 @@ class _DesktopForgotPasswordOtpPageState
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
viewModel.isLoadingOtp
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: null,
|
||||
)
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isOtpValid,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.canSubmitOtpPage,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: viewModel.canSubmitOtpPage
|
||||
? () async {
|
||||
isEnabled: viewModel.canSubmitOtpPage,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed:
|
||||
viewModel.canSubmitOtpPage
|
||||
? () async {
|
||||
await viewModel.verifyOtp(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -35,10 +35,11 @@ class _MobileForgotPasswordOtpPageState
|
||||
void _viewModelListener() {
|
||||
if (viewModel.errorMessageOtp != null) {
|
||||
AppToast.error(context, viewModel.errorMessageOtp!);
|
||||
}
|
||||
|
||||
if (viewModel.resetToken != null) {
|
||||
const ForgotPasswordCreateRouteData().push(context);
|
||||
} else if (!viewModel.isLoadingOtp &&
|
||||
viewModel.verifyOtpSuccess &&
|
||||
viewModel.resetToken != null) {
|
||||
const ForgotPasswordCreateRouteData().pushReplacement(context);
|
||||
viewModel.clearOtpFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ class _MobileForgotPasswordOtpPageState
|
||||
SizedBox(height: 40.0.h()),
|
||||
Pinput(
|
||||
controller: viewModel.otpController,
|
||||
length: 5,
|
||||
length: 6,
|
||||
pinAnimationType: PinAnimationType.scale,
|
||||
defaultPinTheme: PinTheme(
|
||||
width: 50.0.w(),
|
||||
@@ -108,10 +109,11 @@ class _MobileForgotPasswordOtpPageState
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
viewModel.isLoadingOtp
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isOtpValid,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.canSubmitOtpPage,
|
||||
|
||||
@@ -6,12 +6,12 @@ import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
|
||||
import '../../../core/constants/assets.dart';
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../../core/theme/colors.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../../view_models/auth_view_model.dart';
|
||||
import '../../shared/base_button.dart';
|
||||
import '../strings/forgot_password_otp_strings.dart';
|
||||
import '../../forget_password_create/pages/forgot_password_create_screen.dart';
|
||||
|
||||
class TabletForgotPasswordOtpPage extends StatefulWidget {
|
||||
const TabletForgotPasswordOtpPage({super.key});
|
||||
@@ -35,16 +35,14 @@ class _TabletForgotPasswordOtpPageState
|
||||
void _viewModelListener() {
|
||||
if (viewModel.errorMessageOtp != null) {
|
||||
AppToast.error(context, viewModel.errorMessageOtp!);
|
||||
}
|
||||
|
||||
if (viewModel.resetToken != null) {
|
||||
} else if (!viewModel.isLoadingOtp &&
|
||||
viewModel.verifyOtpSuccess &&
|
||||
viewModel.resetToken != null) {
|
||||
Router.neglect(
|
||||
context,
|
||||
() => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ForgotPasswordCreateScreen()),
|
||||
),
|
||||
() => const ForgotPasswordCreateRouteData().pushReplacement(context),
|
||||
);
|
||||
viewModel.clearOtpFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +97,7 @@ class _TabletForgotPasswordOtpPageState
|
||||
SizedBox(height: 40.0.h()),
|
||||
Pinput(
|
||||
controller: viewModel.otpController,
|
||||
length: 5,
|
||||
length: 6,
|
||||
pinAnimationType: PinAnimationType.scale,
|
||||
defaultPinTheme: PinTheme(
|
||||
width: 50.0.w(),
|
||||
@@ -117,20 +115,22 @@ class _TabletForgotPasswordOtpPageState
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
viewModel.isLoadingOtp
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: null,
|
||||
)
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isOtpValid,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.canSubmitOtpPage,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed: viewModel.canSubmitOtpPage
|
||||
? () async {
|
||||
isEnabled: viewModel.canSubmitOtpPage,
|
||||
text: ForgotPasswordOtpStrings.resetLink,
|
||||
onPressed:
|
||||
viewModel.canSubmitOtpPage
|
||||
? () async {
|
||||
await viewModel.verifyOtp(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -33,7 +33,10 @@ class _DesktopForgotPasswordPageState extends State<DesktopForgotPasswordPage> {
|
||||
void _viewModelListener() {
|
||||
if (viewModel.successMessage != null) {
|
||||
AppToast.success(context, viewModel.successMessage!);
|
||||
const ForgotPasswordOtpRouteData().push(context);
|
||||
Router.neglect(
|
||||
context,
|
||||
() => const ForgotPasswordOtpRouteData().pushReplacement(context),
|
||||
);
|
||||
viewModel.clearMessages();
|
||||
}
|
||||
|
||||
@@ -103,19 +106,21 @@ class _DesktopForgotPasswordPageState extends State<DesktopForgotPasswordPage> {
|
||||
SizedBox(height: 70.0.h()),
|
||||
viewModel.isLoadingForgot
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: null,
|
||||
)
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.isEmailValid,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: viewModel.isEmailValid
|
||||
? () async {
|
||||
isEnabled: viewModel.isEmailValid,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed:
|
||||
viewModel.isEmailValid
|
||||
? () async {
|
||||
await viewModel.forgotPassword(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -33,7 +33,7 @@ class _MobileForgotPasswordPageState extends State<MobileForgotPasswordPage> {
|
||||
void _viewModelListener() {
|
||||
if (viewModel.successMessage != null) {
|
||||
AppToast.success(context, viewModel.successMessage!);
|
||||
const ForgotPasswordOtpRouteData().push(context);
|
||||
const ForgotPasswordOtpRouteData().pushReplacement(context);
|
||||
viewModel.clearMessages();
|
||||
}
|
||||
|
||||
@@ -98,19 +98,21 @@ class _MobileForgotPasswordPageState extends State<MobileForgotPasswordPage> {
|
||||
SizedBox(height: 24.0.h()),
|
||||
viewModel.isLoadingForgot
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: null,
|
||||
)
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.isEmailValid,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: viewModel.isEmailValid
|
||||
? () async {
|
||||
isEnabled: viewModel.isEmailValid,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed:
|
||||
viewModel.isEmailValid
|
||||
? () async {
|
||||
await viewModel.forgotPassword(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
: null,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -33,7 +33,10 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
||||
void _viewModelListener() {
|
||||
if (viewModel.successMessage != null) {
|
||||
AppToast.success(context, viewModel.successMessage!);
|
||||
const ForgotPasswordOtpRouteData().push(context);
|
||||
Router.neglect(
|
||||
context,
|
||||
() => const ForgotPasswordOtpRouteData().pushReplacement(context),
|
||||
);
|
||||
viewModel.clearMessages();
|
||||
}
|
||||
|
||||
@@ -97,19 +100,21 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
||||
SizedBox(height: 24.0.h()),
|
||||
viewModel.isLoadingForgot
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: null,
|
||||
)
|
||||
isEnabled: false,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: viewModel.isEmailValid,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed: viewModel.isEmailValid
|
||||
? () async {
|
||||
isEnabled: viewModel.isEmailValid,
|
||||
text: ForgotPasswordStrings.resetLink,
|
||||
onPressed:
|
||||
viewModel.isEmailValid
|
||||
? () async {
|
||||
await viewModel.forgotPassword(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -106,20 +106,20 @@ class _LoginDesktopPageState extends State<LoginDesktopPage> {
|
||||
}
|
||||
},
|
||||
),
|
||||
// SizedBox(height: 32.0),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// ForgotPasswordRouteData().push(context);
|
||||
// },
|
||||
// child: Text(
|
||||
// LoginStrings.forgotPassword,
|
||||
// style: TextStyle(
|
||||
// fontSize: 14.0.sp(),
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: AppColors.mainBlue,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 32.0),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
},
|
||||
child: Text(
|
||||
LoginStrings.forgotPassword,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@@ -99,20 +99,20 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
}
|
||||
: null,
|
||||
),
|
||||
// SizedBox(height: 32.0),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// ForgotPasswordRouteData().push(context);
|
||||
// },
|
||||
// child: Text(
|
||||
// LoginStrings.forgotPassword,
|
||||
// style: TextStyle(
|
||||
// fontSize: 14.0.sp(),
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: AppColors.mainBlue,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 32.0),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
},
|
||||
child: Text(
|
||||
LoginStrings.forgotPassword,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user