forgot password screns logic fixed
This commit is contained in:
@@ -44,6 +44,7 @@ class AuthService {
|
|||||||
if (result is Ok<LoginResponseModel>) {
|
if (result is Ok<LoginResponseModel>) {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final token = result.value.data.accessToken;
|
final token = result.value.data.accessToken;
|
||||||
|
AppLogger().info('🔑 Bearer token: $token');
|
||||||
final refreshToken = result.value.data.refreshToken;
|
final refreshToken = result.value.data.refreshToken;
|
||||||
|
|
||||||
await prefs.setString('bearer', token!);
|
await prefs.setString('bearer', token!);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tm_app/data/services/model/customer/customer.dart';
|
import 'package:tm_app/data/services/model/customer/customer.dart';
|
||||||
import 'package:tm_app/data/services/model/forgot_password_response/forgot_password_response_model.dart';
|
import 'package:tm_app/data/services/model/forgot_password_response/forgot_password_response_model.dart';
|
||||||
@@ -49,13 +47,16 @@ class AuthViewModel with ChangeNotifier {
|
|||||||
bool _isResetPasswordLoading = false;
|
bool _isResetPasswordLoading = false;
|
||||||
String? _errorMessage;
|
String? _errorMessage;
|
||||||
String? _resetPasswordErrorMessage;
|
String? _resetPasswordErrorMessage;
|
||||||
|
bool _resetPasswordSuccess = false;
|
||||||
Customer? _loggedInUser;
|
Customer? _loggedInUser;
|
||||||
String? successMessage;
|
String? successMessage;
|
||||||
|
String? _successMessageOtp;
|
||||||
String? _forgotPasswordMessage;
|
String? _forgotPasswordMessage;
|
||||||
bool _isLoadingForgot = false;
|
bool _isLoadingForgot = false;
|
||||||
bool _isLoadingOtp = false;
|
bool _isLoadingOtp = false;
|
||||||
String? _errorMessageForget;
|
String? _errorMessageForget;
|
||||||
String? _errorMessageOtp;
|
String? _errorMessageOtp;
|
||||||
|
bool _verifyOtpSuccess = false;
|
||||||
|
|
||||||
bool get isLoading => _isLoading;
|
bool get isLoading => _isLoading;
|
||||||
bool get isLoadingForgot => _isLoadingForgot;
|
bool get isLoadingForgot => _isLoadingForgot;
|
||||||
@@ -65,10 +66,12 @@ class AuthViewModel with ChangeNotifier {
|
|||||||
String? get errorMessageForget => _errorMessageForget;
|
String? get errorMessageForget => _errorMessageForget;
|
||||||
String? get resetPasswordErrorMessage => _resetPasswordErrorMessage;
|
String? get resetPasswordErrorMessage => _resetPasswordErrorMessage;
|
||||||
String? get errorMessageOtp => _errorMessageOtp;
|
String? get errorMessageOtp => _errorMessageOtp;
|
||||||
|
String? get successMessageOtp => _successMessageOtp;
|
||||||
|
bool get verifyOtpSuccess => _verifyOtpSuccess;
|
||||||
Customer? get loggedInUser => _loggedInUser;
|
Customer? get loggedInUser => _loggedInUser;
|
||||||
String? get forgotPasswordMessage => _forgotPasswordMessage;
|
String? get forgotPasswordMessage => _forgotPasswordMessage;
|
||||||
String? resetToken;
|
String? resetToken;
|
||||||
|
bool get resetPasswordSuccess => _resetPasswordSuccess;
|
||||||
|
|
||||||
void togglePasswordVisibility() {
|
void togglePasswordVisibility() {
|
||||||
_obscurePassword = !_obscurePassword;
|
_obscurePassword = !_obscurePassword;
|
||||||
@@ -88,7 +91,7 @@ class AuthViewModel with ChangeNotifier {
|
|||||||
|
|
||||||
bool get isOtpValid {
|
bool get isOtpValid {
|
||||||
final otp = otpController.text.trim();
|
final otp = otpController.text.trim();
|
||||||
return otp.length == 5;
|
return otp.length == 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get canSubmitOtpPage {
|
bool get canSubmitOtpPage {
|
||||||
@@ -182,8 +185,8 @@ class AuthViewModel with ChangeNotifier {
|
|||||||
case Ok<ForgotPasswordResponseModel>():
|
case Ok<ForgotPasswordResponseModel>():
|
||||||
_isLoadingForgot = false;
|
_isLoadingForgot = false;
|
||||||
successMessage = result.value.message;
|
successMessage = result.value.message;
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
log('$successMessage');
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -208,6 +211,7 @@ class AuthViewModel with ChangeNotifier {
|
|||||||
Future<void> verifyOtp(BuildContext context) async {
|
Future<void> verifyOtp(BuildContext context) async {
|
||||||
_isLoadingOtp = true;
|
_isLoadingOtp = true;
|
||||||
_errorMessageOtp = null;
|
_errorMessageOtp = null;
|
||||||
|
_verifyOtpSuccess = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
final result = await _authRepository.verifyOtp(
|
final result = await _authRepository.verifyOtp(
|
||||||
@@ -219,39 +223,77 @@ class AuthViewModel with ChangeNotifier {
|
|||||||
case Ok<VerifyOtpResponseModel>():
|
case Ok<VerifyOtpResponseModel>():
|
||||||
_isLoadingOtp = false;
|
_isLoadingOtp = false;
|
||||||
resetToken = result.value.data.token;
|
resetToken = result.value.data.token;
|
||||||
|
_successMessageOtp = result.value.message;
|
||||||
|
_verifyOtpSuccess = true;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Error<VerifyOtpResponseModel>():
|
case Error<VerifyOtpResponseModel>():
|
||||||
_isLoadingOtp = false;
|
_isLoadingOtp = false;
|
||||||
_errorMessageOtp = result.error.toString();
|
_errorMessageOtp = result.error.toString();
|
||||||
|
_verifyOtpSuccess = false;
|
||||||
|
notifyListeners();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
_errorMessageOtp = null;
|
_errorMessageOtp = null;
|
||||||
|
_successMessageOtp = null;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearOtpFlow() {
|
||||||
|
_errorMessageOtp = null;
|
||||||
|
_successMessageOtp = null;
|
||||||
|
_isLoadingOtp = false;
|
||||||
|
_verifyOtpSuccess = false;
|
||||||
|
// Intentionally do not clear resetToken
|
||||||
|
otpController.clear();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> resetPassword() async {
|
Future<void> resetPassword() async {
|
||||||
_isResetPasswordLoading = true;
|
_isResetPasswordLoading = true;
|
||||||
_resetPasswordErrorMessage = null;
|
_resetPasswordErrorMessage = null;
|
||||||
|
_resetPasswordSuccess = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
if (resetToken != null) {
|
||||||
final result = await _authRepository.resetPassword(
|
final result = await _authRepository.resetPassword(
|
||||||
newPassword: newPasswordController.text.trim(),
|
newPassword: newPasswordController.text.trim(),
|
||||||
token: '',
|
token: resetToken!,
|
||||||
);
|
);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case Ok<ResetPasswordResponse>():
|
case Ok<ResetPasswordResponse>():
|
||||||
break;
|
_resetPasswordSuccess = true;
|
||||||
case Error<ResetPasswordResponse>():
|
break;
|
||||||
_resetPasswordErrorMessage = result.error.toString();
|
case Error<ResetPasswordResponse>():
|
||||||
break;
|
_resetPasswordErrorMessage = result.error.toString();
|
||||||
|
_resetPasswordSuccess = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_isResetPasswordLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
_resetPasswordErrorMessage = null;
|
||||||
|
notifyListeners();
|
||||||
|
} else {
|
||||||
|
_resetPasswordErrorMessage = 'Reset token is required';
|
||||||
|
_isResetPasswordLoading = false;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
_isResetPasswordLoading = false;
|
}
|
||||||
|
|
||||||
|
void clearResetPasswordSuccess() {
|
||||||
|
_resetPasswordSuccess = false;
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearResetFlow() {
|
||||||
_resetPasswordErrorMessage = null;
|
_resetPasswordErrorMessage = null;
|
||||||
|
_resetPasswordSuccess = false;
|
||||||
|
_isResetPasswordLoading = false;
|
||||||
|
// Intentionally do not clear resetToken
|
||||||
|
newPasswordController.clear();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
||||||
|
|
||||||
import '../../../core/constants/assets.dart';
|
import '../../../core/constants/assets.dart';
|
||||||
|
import '../../../core/routes/app_routes.dart';
|
||||||
import '../../../core/theme/colors.dart';
|
import '../../../core/theme/colors.dart';
|
||||||
import '../../../core/utils/app_toast.dart';
|
import '../../../core/utils/app_toast.dart';
|
||||||
import '../../../view_models/auth_view_model.dart';
|
import '../../../view_models/auth_view_model.dart';
|
||||||
@@ -40,6 +41,10 @@ class _DesktopForgotPasswordCreatePageState
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.resetPasswordErrorMessage != null) {
|
if (viewModel.resetPasswordErrorMessage != null) {
|
||||||
AppToast.error(context, viewModel.resetPasswordErrorMessage!);
|
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()),
|
SizedBox(height: 80.0.h()),
|
||||||
viewModel.isResetPasswordLoading
|
viewModel.isResetPasswordLoading
|
||||||
? const BaseButton(
|
? BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: viewModel.isNewPasswordValid,
|
||||||
text: ForgotPasswordCreateStrings.resetLink,
|
text: ForgotPasswordCreateStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
|
isLoading: true,
|
||||||
)
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.isNewPasswordValid,
|
isEnabled: viewModel.isNewPasswordValid,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:provider/provider.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/core/utils/size_config.dart';
|
||||||
import 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
import 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
||||||
|
|
||||||
@@ -40,6 +41,10 @@ class _MobileForgotPasswordCreatePageState
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.resetPasswordErrorMessage != null) {
|
if (viewModel.resetPasswordErrorMessage != null) {
|
||||||
AppToast.error(context, viewModel.resetPasswordErrorMessage!);
|
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()),
|
SizedBox(height: 80.0.h()),
|
||||||
viewModel.isResetPasswordLoading
|
viewModel.isResetPasswordLoading
|
||||||
? const BaseButton(
|
? BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: viewModel.isNewPasswordValid,
|
||||||
text: ForgotPasswordCreateStrings.resetLink,
|
text: ForgotPasswordCreateStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
|
isLoading: true,
|
||||||
)
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.isNewPasswordValid,
|
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 'package:tm_app/views/forget_password_create/strings/forgot_password_create_strings.dart';
|
||||||
|
|
||||||
import '../../../core/constants/assets.dart';
|
import '../../../core/constants/assets.dart';
|
||||||
|
import '../../../core/routes/app_routes.dart';
|
||||||
import '../../../core/theme/colors.dart';
|
import '../../../core/theme/colors.dart';
|
||||||
import '../../../core/utils/app_toast.dart';
|
import '../../../core/utils/app_toast.dart';
|
||||||
import '../../../view_models/auth_view_model.dart';
|
import '../../../view_models/auth_view_model.dart';
|
||||||
@@ -40,6 +41,10 @@ class _TabletForgotPasswordCreatePageState
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.resetPasswordErrorMessage != null) {
|
if (viewModel.resetPasswordErrorMessage != null) {
|
||||||
AppToast.error(context, viewModel.resetPasswordErrorMessage!);
|
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()),
|
SizedBox(height: 80.0.h()),
|
||||||
viewModel.isResetPasswordLoading
|
viewModel.isResetPasswordLoading
|
||||||
? const BaseButton(
|
? BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: viewModel.isNewPasswordValid,
|
||||||
text: ForgotPasswordCreateStrings.resetLink,
|
text: ForgotPasswordCreateStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
|
isLoading: true,
|
||||||
)
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.isNewPasswordValid,
|
isEnabled: viewModel.isNewPasswordValid,
|
||||||
text: ForgotPasswordCreateStrings.resetLink,
|
text: ForgotPasswordCreateStrings.resetLink,
|
||||||
|
|
||||||
onPressed:
|
onPressed:
|
||||||
viewModel.isNewPasswordValid
|
viewModel.isNewPasswordValid
|
||||||
? () async {
|
? () async {
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:tm_app/core/utils/size_config.dart';
|
import 'package:tm_app/core/utils/size_config.dart';
|
||||||
|
|
||||||
import '../../../core/constants/assets.dart';
|
import '../../../core/constants/assets.dart';
|
||||||
|
import '../../../core/routes/app_routes.dart';
|
||||||
import '../../../core/theme/colors.dart';
|
import '../../../core/theme/colors.dart';
|
||||||
import '../../../core/utils/app_toast.dart';
|
import '../../../core/utils/app_toast.dart';
|
||||||
import '../../../view_models/auth_view_model.dart';
|
import '../../../view_models/auth_view_model.dart';
|
||||||
import '../../shared/base_button.dart';
|
import '../../shared/base_button.dart';
|
||||||
import '../strings/forgot_password_otp_strings.dart';
|
import '../strings/forgot_password_otp_strings.dart';
|
||||||
import '../../forget_password_create/pages/forgot_password_create_screen.dart';
|
|
||||||
|
|
||||||
class DesktopForgotPasswordOtpPage extends StatefulWidget {
|
class DesktopForgotPasswordOtpPage extends StatefulWidget {
|
||||||
const DesktopForgotPasswordOtpPage({super.key});
|
const DesktopForgotPasswordOtpPage({super.key});
|
||||||
@@ -35,16 +35,14 @@ class _DesktopForgotPasswordOtpPageState
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.errorMessageOtp != null) {
|
if (viewModel.errorMessageOtp != null) {
|
||||||
AppToast.error(context, viewModel.errorMessageOtp!);
|
AppToast.error(context, viewModel.errorMessageOtp!);
|
||||||
}
|
} else if (!viewModel.isLoadingOtp &&
|
||||||
|
viewModel.verifyOtpSuccess &&
|
||||||
if (viewModel.resetToken != null) {
|
viewModel.resetToken != null) {
|
||||||
Router.neglect(
|
Router.neglect(
|
||||||
context,
|
context,
|
||||||
() => Navigator.push(
|
() => const ForgotPasswordCreateRouteData().pushReplacement(context),
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (_) => const ForgotPasswordCreateScreen()),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
viewModel.clearOtpFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ class _DesktopForgotPasswordOtpPageState
|
|||||||
SizedBox(height: 40.0.h()),
|
SizedBox(height: 40.0.h()),
|
||||||
Pinput(
|
Pinput(
|
||||||
controller: viewModel.otpController,
|
controller: viewModel.otpController,
|
||||||
length: 5,
|
length: 6,
|
||||||
pinAnimationType: PinAnimationType.scale,
|
pinAnimationType: PinAnimationType.scale,
|
||||||
defaultPinTheme: PinTheme(
|
defaultPinTheme: PinTheme(
|
||||||
width: 50.0.w(),
|
width: 50.0.w(),
|
||||||
@@ -117,20 +115,22 @@ class _DesktopForgotPasswordOtpPageState
|
|||||||
),
|
),
|
||||||
SizedBox(height: 24.0.h()),
|
SizedBox(height: 24.0.h()),
|
||||||
viewModel.isLoadingOtp
|
viewModel.isLoadingOtp
|
||||||
? const BaseButton(
|
? BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: viewModel.isOtpValid,
|
||||||
text: ForgotPasswordOtpStrings.resetLink,
|
text: ForgotPasswordOtpStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
)
|
isLoading: true,
|
||||||
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.canSubmitOtpPage,
|
isEnabled: viewModel.canSubmitOtpPage,
|
||||||
text: ForgotPasswordOtpStrings.resetLink,
|
text: ForgotPasswordOtpStrings.resetLink,
|
||||||
onPressed: viewModel.canSubmitOtpPage
|
onPressed:
|
||||||
? () async {
|
viewModel.canSubmitOtpPage
|
||||||
|
? () async {
|
||||||
await viewModel.verifyOtp(context);
|
await viewModel.verifyOtp(context);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12.0),
|
const SizedBox(height: 12.0),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ class _MobileForgotPasswordOtpPageState
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.errorMessageOtp != null) {
|
if (viewModel.errorMessageOtp != null) {
|
||||||
AppToast.error(context, viewModel.errorMessageOtp!);
|
AppToast.error(context, viewModel.errorMessageOtp!);
|
||||||
}
|
} else if (!viewModel.isLoadingOtp &&
|
||||||
|
viewModel.verifyOtpSuccess &&
|
||||||
if (viewModel.resetToken != null) {
|
viewModel.resetToken != null) {
|
||||||
const ForgotPasswordCreateRouteData().push(context);
|
const ForgotPasswordCreateRouteData().pushReplacement(context);
|
||||||
|
viewModel.clearOtpFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ class _MobileForgotPasswordOtpPageState
|
|||||||
SizedBox(height: 40.0.h()),
|
SizedBox(height: 40.0.h()),
|
||||||
Pinput(
|
Pinput(
|
||||||
controller: viewModel.otpController,
|
controller: viewModel.otpController,
|
||||||
length: 5,
|
length: 6,
|
||||||
pinAnimationType: PinAnimationType.scale,
|
pinAnimationType: PinAnimationType.scale,
|
||||||
defaultPinTheme: PinTheme(
|
defaultPinTheme: PinTheme(
|
||||||
width: 50.0.w(),
|
width: 50.0.w(),
|
||||||
@@ -108,10 +109,11 @@ class _MobileForgotPasswordOtpPageState
|
|||||||
),
|
),
|
||||||
SizedBox(height: 24.0.h()),
|
SizedBox(height: 24.0.h()),
|
||||||
viewModel.isLoadingOtp
|
viewModel.isLoadingOtp
|
||||||
? const BaseButton(
|
? BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: viewModel.isOtpValid,
|
||||||
text: ForgotPasswordOtpStrings.resetLink,
|
text: ForgotPasswordOtpStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
|
isLoading: true,
|
||||||
)
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.canSubmitOtpPage,
|
isEnabled: viewModel.canSubmitOtpPage,
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:tm_app/core/utils/size_config.dart';
|
import 'package:tm_app/core/utils/size_config.dart';
|
||||||
|
|
||||||
import '../../../core/constants/assets.dart';
|
import '../../../core/constants/assets.dart';
|
||||||
|
import '../../../core/routes/app_routes.dart';
|
||||||
import '../../../core/theme/colors.dart';
|
import '../../../core/theme/colors.dart';
|
||||||
import '../../../core/utils/app_toast.dart';
|
import '../../../core/utils/app_toast.dart';
|
||||||
import '../../../view_models/auth_view_model.dart';
|
import '../../../view_models/auth_view_model.dart';
|
||||||
import '../../shared/base_button.dart';
|
import '../../shared/base_button.dart';
|
||||||
import '../strings/forgot_password_otp_strings.dart';
|
import '../strings/forgot_password_otp_strings.dart';
|
||||||
import '../../forget_password_create/pages/forgot_password_create_screen.dart';
|
|
||||||
|
|
||||||
class TabletForgotPasswordOtpPage extends StatefulWidget {
|
class TabletForgotPasswordOtpPage extends StatefulWidget {
|
||||||
const TabletForgotPasswordOtpPage({super.key});
|
const TabletForgotPasswordOtpPage({super.key});
|
||||||
@@ -35,16 +35,14 @@ class _TabletForgotPasswordOtpPageState
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.errorMessageOtp != null) {
|
if (viewModel.errorMessageOtp != null) {
|
||||||
AppToast.error(context, viewModel.errorMessageOtp!);
|
AppToast.error(context, viewModel.errorMessageOtp!);
|
||||||
}
|
} else if (!viewModel.isLoadingOtp &&
|
||||||
|
viewModel.verifyOtpSuccess &&
|
||||||
if (viewModel.resetToken != null) {
|
viewModel.resetToken != null) {
|
||||||
Router.neglect(
|
Router.neglect(
|
||||||
context,
|
context,
|
||||||
() => Navigator.push(
|
() => const ForgotPasswordCreateRouteData().pushReplacement(context),
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (_) => const ForgotPasswordCreateScreen()),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
viewModel.clearOtpFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ class _TabletForgotPasswordOtpPageState
|
|||||||
SizedBox(height: 40.0.h()),
|
SizedBox(height: 40.0.h()),
|
||||||
Pinput(
|
Pinput(
|
||||||
controller: viewModel.otpController,
|
controller: viewModel.otpController,
|
||||||
length: 5,
|
length: 6,
|
||||||
pinAnimationType: PinAnimationType.scale,
|
pinAnimationType: PinAnimationType.scale,
|
||||||
defaultPinTheme: PinTheme(
|
defaultPinTheme: PinTheme(
|
||||||
width: 50.0.w(),
|
width: 50.0.w(),
|
||||||
@@ -117,20 +115,22 @@ class _TabletForgotPasswordOtpPageState
|
|||||||
),
|
),
|
||||||
SizedBox(height: 24.0.h()),
|
SizedBox(height: 24.0.h()),
|
||||||
viewModel.isLoadingOtp
|
viewModel.isLoadingOtp
|
||||||
? const BaseButton(
|
? BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: viewModel.isOtpValid,
|
||||||
text: ForgotPasswordOtpStrings.resetLink,
|
text: ForgotPasswordOtpStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
)
|
isLoading: true,
|
||||||
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.canSubmitOtpPage,
|
isEnabled: viewModel.canSubmitOtpPage,
|
||||||
text: ForgotPasswordOtpStrings.resetLink,
|
text: ForgotPasswordOtpStrings.resetLink,
|
||||||
onPressed: viewModel.canSubmitOtpPage
|
onPressed:
|
||||||
? () async {
|
viewModel.canSubmitOtpPage
|
||||||
|
? () async {
|
||||||
await viewModel.verifyOtp(context);
|
await viewModel.verifyOtp(context);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12.0),
|
const SizedBox(height: 12.0),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ class _DesktopForgotPasswordPageState extends State<DesktopForgotPasswordPage> {
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.successMessage != null) {
|
if (viewModel.successMessage != null) {
|
||||||
AppToast.success(context, viewModel.successMessage!);
|
AppToast.success(context, viewModel.successMessage!);
|
||||||
const ForgotPasswordOtpRouteData().push(context);
|
Router.neglect(
|
||||||
|
context,
|
||||||
|
() => const ForgotPasswordOtpRouteData().pushReplacement(context),
|
||||||
|
);
|
||||||
viewModel.clearMessages();
|
viewModel.clearMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,19 +106,21 @@ class _DesktopForgotPasswordPageState extends State<DesktopForgotPasswordPage> {
|
|||||||
SizedBox(height: 70.0.h()),
|
SizedBox(height: 70.0.h()),
|
||||||
viewModel.isLoadingForgot
|
viewModel.isLoadingForgot
|
||||||
? const BaseButton(
|
? const BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
text: ForgotPasswordStrings.resetLink,
|
text: ForgotPasswordStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
)
|
isLoading: true,
|
||||||
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.isEmailValid,
|
isEnabled: viewModel.isEmailValid,
|
||||||
text: ForgotPasswordStrings.resetLink,
|
text: ForgotPasswordStrings.resetLink,
|
||||||
onPressed: viewModel.isEmailValid
|
onPressed:
|
||||||
? () async {
|
viewModel.isEmailValid
|
||||||
|
? () async {
|
||||||
await viewModel.forgotPassword(context);
|
await viewModel.forgotPassword(context);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class _MobileForgotPasswordPageState extends State<MobileForgotPasswordPage> {
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.successMessage != null) {
|
if (viewModel.successMessage != null) {
|
||||||
AppToast.success(context, viewModel.successMessage!);
|
AppToast.success(context, viewModel.successMessage!);
|
||||||
const ForgotPasswordOtpRouteData().push(context);
|
const ForgotPasswordOtpRouteData().pushReplacement(context);
|
||||||
viewModel.clearMessages();
|
viewModel.clearMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,19 +98,21 @@ class _MobileForgotPasswordPageState extends State<MobileForgotPasswordPage> {
|
|||||||
SizedBox(height: 24.0.h()),
|
SizedBox(height: 24.0.h()),
|
||||||
viewModel.isLoadingForgot
|
viewModel.isLoadingForgot
|
||||||
? const BaseButton(
|
? const BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
text: ForgotPasswordStrings.resetLink,
|
text: ForgotPasswordStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
)
|
isLoading: true,
|
||||||
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.isEmailValid,
|
isEnabled: viewModel.isEmailValid,
|
||||||
text: ForgotPasswordStrings.resetLink,
|
text: ForgotPasswordStrings.resetLink,
|
||||||
onPressed: viewModel.isEmailValid
|
onPressed:
|
||||||
? () async {
|
viewModel.isEmailValid
|
||||||
|
? () async {
|
||||||
await viewModel.forgotPassword(context);
|
await viewModel.forgotPassword(context);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
|||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.successMessage != null) {
|
if (viewModel.successMessage != null) {
|
||||||
AppToast.success(context, viewModel.successMessage!);
|
AppToast.success(context, viewModel.successMessage!);
|
||||||
const ForgotPasswordOtpRouteData().push(context);
|
Router.neglect(
|
||||||
|
context,
|
||||||
|
() => const ForgotPasswordOtpRouteData().pushReplacement(context),
|
||||||
|
);
|
||||||
viewModel.clearMessages();
|
viewModel.clearMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,19 +100,21 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
|||||||
SizedBox(height: 24.0.h()),
|
SizedBox(height: 24.0.h()),
|
||||||
viewModel.isLoadingForgot
|
viewModel.isLoadingForgot
|
||||||
? const BaseButton(
|
? const BaseButton(
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
text: ForgotPasswordStrings.resetLink,
|
text: ForgotPasswordStrings.resetLink,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
)
|
isLoading: true,
|
||||||
|
)
|
||||||
: BaseButton(
|
: BaseButton(
|
||||||
isEnabled: viewModel.isEmailValid,
|
isEnabled: viewModel.isEmailValid,
|
||||||
text: ForgotPasswordStrings.resetLink,
|
text: ForgotPasswordStrings.resetLink,
|
||||||
onPressed: viewModel.isEmailValid
|
onPressed:
|
||||||
? () async {
|
viewModel.isEmailValid
|
||||||
|
? () async {
|
||||||
await viewModel.forgotPassword(context);
|
await viewModel.forgotPassword(context);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -106,20 +106,20 @@ class _LoginDesktopPageState extends State<LoginDesktopPage> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// SizedBox(height: 32.0),
|
const SizedBox(height: 32.0),
|
||||||
// TextButton(
|
TextButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// ForgotPasswordRouteData().push(context);
|
const ForgotPasswordRouteData().push(context);
|
||||||
// },
|
},
|
||||||
// child: Text(
|
child: Text(
|
||||||
// LoginStrings.forgotPassword,
|
LoginStrings.forgotPassword,
|
||||||
// style: TextStyle(
|
style: TextStyle(
|
||||||
// fontSize: 14.0.sp(),
|
fontSize: 14.0.sp(),
|
||||||
// fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
// color: AppColors.mainBlue,
|
color: AppColors.mainBlue,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -99,20 +99,20 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
// SizedBox(height: 32.0),
|
const SizedBox(height: 32.0),
|
||||||
// TextButton(
|
TextButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// ForgotPasswordRouteData().push(context);
|
const ForgotPasswordRouteData().push(context);
|
||||||
// },
|
},
|
||||||
// child: Text(
|
child: Text(
|
||||||
// LoginStrings.forgotPassword,
|
LoginStrings.forgotPassword,
|
||||||
// style: TextStyle(
|
style: TextStyle(
|
||||||
// fontSize: 14.0.sp(),
|
fontSize: 14.0.sp(),
|
||||||
// fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
// color: AppColors.mainBlue,
|
color: AppColors.mainBlue,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user