fixed auth pages sizes and push notification navigate bug

This commit is contained in:
amirrezaghabeli
2025-09-24 13:11:48 +03:30
parent a8e65f3cb5
commit 8458da4f15
10 changed files with 372 additions and 360 deletions
@@ -52,135 +52,138 @@ class _MobileForgotPasswordCreatePageState
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.backgroundColor,
body: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Consumer<AuthViewModel>(
builder: (context, viewModel, _) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
child: SvgPicture.asset(
AssetsManager.logoBig,
width: double.infinity,
height: 50.0.h(),
resizeToAvoidBottomInset: false,
body: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Consumer<AuthViewModel>(
builder: (context, viewModel, _) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
child: SvgPicture.asset(
AssetsManager.logoBig,
width: double.infinity,
height: 50.0.h(),
),
),
),
SizedBox(height: 72.0.h()),
Text(
ForgotPasswordCreateStrings.forgotPasswordTitle,
style: TextStyle(
fontSize: 28.0.sp(),
fontWeight: FontWeight.bold,
color: AppColors.grey80,
SizedBox(height: 72.0.h()),
Text(
ForgotPasswordCreateStrings.forgotPasswordTitle,
style: TextStyle(
fontSize: 28.0.sp(),
fontWeight: FontWeight.bold,
color: AppColors.grey80,
),
),
),
SizedBox(height: 16.0.h()),
Text(
ForgotPasswordCreateStrings.forgotPasswordSubtitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey60,
),
),
SizedBox(height: 40.0.h()),
LoginTextField(
controller: viewModel.newPasswordController,
focusNode: viewModel.newPasswordFocus,
label: ForgotPasswordCreateStrings.createNewPassword,
iconPath: AssetsManager.passwordIcon,
isPassword: true,
obscureText: viewModel.obscureForgotPassword,
onToggleVisibility:
viewModel.toggleForgotPasswordVisibility,
),
SizedBox(height: 16.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLast5Character,
SizedBox(height: 16.0.h()),
Text(
ForgotPasswordCreateStrings.forgotPasswordSubtitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey60,
),
),
),
SizedBox(height: 6.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLeast1uppercase,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
SizedBox(height: 40.0.h()),
LoginTextField(
controller: viewModel.newPasswordController,
focusNode: viewModel.newPasswordFocus,
label: ForgotPasswordCreateStrings.createNewPassword,
iconPath: AssetsManager.passwordIcon,
isPassword: true,
obscureText: viewModel.obscureForgotPassword,
onToggleVisibility:
viewModel.toggleForgotPasswordVisibility,
),
SizedBox(height: 16.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLast5Character,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
),
),
),
),
SizedBox(height: 6.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLeast1lowercase,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
SizedBox(height: 6.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLeast1uppercase,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
),
),
),
),
SizedBox(height: 6.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLeastSpecial,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
SizedBox(height: 6.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLeast1lowercase,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
),
),
),
),
SizedBox(height: 80.0.h()),
viewModel.isResetPasswordLoading
? BaseButton(
isEnabled: viewModel.isNewPasswordValid,
text: ForgotPasswordCreateStrings.resetLink,
onPressed: null,
isLoading: true,
)
: BaseButton(
isEnabled: viewModel.isNewPasswordValid,
text: ForgotPasswordCreateStrings.resetLink,
onPressed:
viewModel.isNewPasswordValid
? () async {
viewModel.resetPassword();
}
: null,
SizedBox(height: 6.0.h()),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16.0.w()),
child: Text(
ForgotPasswordCreateStrings.atLeastSpecial,
style: TextStyle(
fontSize: 14.0.sp(),
color: AppColors.grey60,
),
),
),
SizedBox(height: 80.0.h()),
viewModel.isResetPasswordLoading
? BaseButton(
isEnabled: viewModel.isNewPasswordValid,
text: ForgotPasswordCreateStrings.resetLink,
onPressed: null,
isLoading: true,
)
: BaseButton(
isEnabled: viewModel.isNewPasswordValid,
text: ForgotPasswordCreateStrings.resetLink,
onPressed:
viewModel.isNewPasswordValid
? () async {
viewModel.resetPassword();
}
: null,
),
TextButton(
onPressed: () {
context.pop();
},
child: Text(
ForgotPasswordCreateStrings.backToSignInButton,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
TextButton(
onPressed: () {
context.pop();
},
child: Text(
ForgotPasswordCreateStrings.backToSignInButton,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
),
),
),
),
],
);
},
],
);
},
),
),
),
),
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:tm_app/views/forget_password_otp.dart/pages/d_forget_password_otp.dart_page.dart';
import 'package:tm_app/views/forget_password_otp.dart/pages/m_forget_password_otp.dart_page.dart';
import 'package:tm_app/views/forget_password_otp.dart/pages/t_forget_password_otp.dart_page.dart';
import 'package:tm_app/views/forget_password_otp.dart/pages/d_forget_password_otp_page.dart';
import 'package:tm_app/views/forget_password_otp.dart/pages/m_forget_password_otp_page.dart';
import 'package:tm_app/views/forget_password_otp.dart/pages/t_forget_password_otp_page.dart';
import '../../shared/responsive_builder.dart';
@@ -1,149 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:pinput/pinput.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 '../../../core/constants/assets.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';
class MobileForgotPasswordOtpPage extends StatefulWidget {
const MobileForgotPasswordOtpPage({super.key});
@override
State<MobileForgotPasswordOtpPage> createState() =>
_MobileForgotPasswordOtpPageState();
}
class _MobileForgotPasswordOtpPageState
extends State<MobileForgotPasswordOtpPage> {
late final AuthViewModel viewModel;
@override
void initState() {
super.initState();
viewModel = context.read<AuthViewModel>();
viewModel.addListener(_viewModelListener);
}
void _viewModelListener() {
if (viewModel.errorMessageOtp != null) {
AppToast.error(context, viewModel.errorMessageOtp!);
} else if (!viewModel.isLoadingOtp &&
viewModel.verifyOtpSuccess &&
viewModel.resetToken != null) {
const ForgotPasswordCreateRouteData().pushReplacement(context);
viewModel.clearOtpFlow();
}
}
@override
void dispose() {
viewModel.removeListener(_viewModelListener);
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.backgroundColor,
body: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Consumer<AuthViewModel>(
builder: (context, viewModel, _) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
child: SvgPicture.asset(
AssetsManager.logoBig,
width: double.infinity,
height: 50.0.h(),
),
),
SizedBox(height: 72.0.h()),
Text(
ForgotPasswordOtpStrings.forgotPasswordTitle,
style: TextStyle(
fontSize: 28.0.sp(),
fontWeight: FontWeight.bold,
color: AppColors.grey80,
),
),
SizedBox(height: 16.0.h()),
Text(
ForgotPasswordOtpStrings.forgotPasswordSubtitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey60,
),
),
SizedBox(height: 40.0.h()),
Pinput(
controller: viewModel.otpController,
length: 6,
pinAnimationType: PinAnimationType.scale,
defaultPinTheme: PinTheme(
width: 50.0.w(),
height: 50.0.h(),
textStyle: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.bold,
),
decoration: BoxDecoration(
color: AppColors.grey0,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: AppColors.grey40),
),
),
),
SizedBox(height: 24.0.h()),
viewModel.isLoadingOtp
? BaseButton(
isEnabled: viewModel.isOtpValid,
text: ForgotPasswordOtpStrings.resetLink,
onPressed: null,
isLoading: true,
)
: BaseButton(
isEnabled: viewModel.canSubmitOtpPage,
text: ForgotPasswordOtpStrings.resetLink,
onPressed:
viewModel.canSubmitOtpPage
? () async {
await viewModel.verifyOtp(context);
}
: null,
),
TextButton(
onPressed: () {
context.pop();
},
child: Text(
ForgotPasswordOtpStrings.backToSignInButton,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
),
),
),
],
);
},
),
),
),
);
}
}
@@ -0,0 +1,151 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:pinput/pinput.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 '../../../core/constants/assets.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';
class MobileForgotPasswordOtpPage extends StatefulWidget {
const MobileForgotPasswordOtpPage({super.key});
@override
State<MobileForgotPasswordOtpPage> createState() =>
_MobileForgotPasswordOtpPageState();
}
class _MobileForgotPasswordOtpPageState
extends State<MobileForgotPasswordOtpPage> {
late final AuthViewModel viewModel;
@override
void initState() {
super.initState();
viewModel = context.read<AuthViewModel>();
viewModel.addListener(_viewModelListener);
}
void _viewModelListener() {
if (viewModel.errorMessageOtp != null) {
AppToast.error(context, viewModel.errorMessageOtp!);
} else if (!viewModel.isLoadingOtp &&
viewModel.verifyOtpSuccess &&
viewModel.resetToken != null) {
const ForgotPasswordCreateRouteData().pushReplacement(context);
viewModel.clearOtpFlow();
}
}
@override
void dispose() {
viewModel.removeListener(_viewModelListener);
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.backgroundColor,
body: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Consumer<AuthViewModel>(
builder: (context, viewModel, _) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
child: SvgPicture.asset(
AssetsManager.logoBig,
width: double.infinity,
height: 50.0.h(),
),
),
SizedBox(height: 72.0.h()),
Text(
ForgotPasswordOtpStrings.forgotPasswordTitle,
style: TextStyle(
fontSize: 28.0.sp(),
fontWeight: FontWeight.bold,
color: AppColors.grey80,
),
),
SizedBox(height: 16.0.h()),
Text(
ForgotPasswordOtpStrings.forgotPasswordSubtitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey60,
),
),
SizedBox(height: 40.0.h()),
Pinput(
controller: viewModel.otpController,
length: 6,
pinAnimationType: PinAnimationType.scale,
defaultPinTheme: PinTheme(
width: 50.0.w(),
height: 50.0.h(),
textStyle: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.bold,
),
decoration: BoxDecoration(
color: AppColors.grey0,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: AppColors.grey40),
),
),
),
SizedBox(height: 24.0.h()),
viewModel.isLoadingOtp
? BaseButton(
isEnabled: viewModel.isOtpValid,
text: ForgotPasswordOtpStrings.resetLink,
onPressed: null,
isLoading: true,
)
: BaseButton(
isEnabled: viewModel.canSubmitOtpPage,
text: ForgotPasswordOtpStrings.resetLink,
onPressed:
viewModel.canSubmitOtpPage
? () async {
await viewModel.verifyOtp(context);
}
: null,
),
TextButton(
onPressed: () {
context.pop();
},
child: Text(
ForgotPasswordOtpStrings.backToSignInButton,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
),
),
),
],
);
},
),
),
),
),
);
}
}
+73 -71
View File
@@ -46,79 +46,81 @@ class _LoginMobilePageState extends State<LoginMobilePage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.backgroundColor,
body: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Consumer<AuthViewModel>(
builder: (context, viewModel, _) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
// LoginLogo(width: 190.0.w(), height: 88.0.h()),
Padding(
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
child: SvgPicture.asset(
AssetsManager.logoBig,
width: double.infinity,
height: 50.0.h(),
),
),
SizedBox(height: 32.0.h()),
const LoginTitle(),
SizedBox(height: 32.0.h()),
LoginTextField(
controller: viewModel.usernameController,
focusNode: viewModel.usernameFocus,
label: LoginStrings.usernameLabel,
iconPath: AssetsManager.userIcon,
),
SizedBox(height: 16.0.h()),
LoginTextField(
controller: viewModel.passwordController,
focusNode: viewModel.passwordFocus,
label: LoginStrings.passwordLabel,
iconPath: AssetsManager.passwordIcon,
isPassword: true,
obscureText: viewModel.obscurePassword,
onToggleVisibility: viewModel.togglePasswordVisibility,
),
SizedBox(height: 32.0.h()),
if (viewModel.isLoading)
BaseButton(
isEnabled: false,
onPressed: null,
isLoading: true,
textColor: AppColors.white,
)
else
BaseButton(
isEnabled: viewModel.isLoginEnabled,
onPressed: () async {
if (viewModel.isLoginEnabled) {
await viewModel.login();
}
},
),
SizedBox(height: 32.0.h()),
TextButton(
onPressed: () {
const ForgotPasswordRouteData().push(context);
},
child: Text(
LoginStrings.forgotPassword,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
body: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Consumer<AuthViewModel>(
builder: (context, viewModel, _) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
// LoginLogo(width: 190.0.w(), height: 88.0.h()),
Padding(
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
child: SvgPicture.asset(
AssetsManager.logoBig,
width: double.infinity,
height: 50.0.h(),
),
),
),
],
);
},
SizedBox(height: 32.0.h()),
const LoginTitle(),
SizedBox(height: 32.0.h()),
LoginTextField(
controller: viewModel.usernameController,
focusNode: viewModel.usernameFocus,
label: LoginStrings.usernameLabel,
iconPath: AssetsManager.userIcon,
),
SizedBox(height: 16.0.h()),
LoginTextField(
controller: viewModel.passwordController,
focusNode: viewModel.passwordFocus,
label: LoginStrings.passwordLabel,
iconPath: AssetsManager.passwordIcon,
isPassword: true,
obscureText: viewModel.obscurePassword,
onToggleVisibility: viewModel.togglePasswordVisibility,
),
SizedBox(height: 32.0.h()),
if (viewModel.isLoading)
BaseButton(
isEnabled: false,
onPressed: null,
isLoading: true,
textColor: AppColors.white,
)
else
BaseButton(
isEnabled: viewModel.isLoginEnabled,
onPressed: () async {
if (viewModel.isLoginEnabled) {
await viewModel.login();
}
},
),
SizedBox(height: 32.0.h()),
TextButton(
onPressed: () {
const ForgotPasswordRouteData().push(context);
},
child: Text(
LoginStrings.forgotPassword,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
),
),
),
],
);
},
),
),
),
),
+8 -10
View File
@@ -27,16 +27,14 @@ class _MobileSplashPageState extends State<MobileSplashPage> {
void _viewModelListener() {
if (viewModel.isLoggedIn) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.navigateToNotification) {
Router.neglect(
context,
() => const NotificationRouteData().go(context),
);
} else {
Router.neglect(context, () => const HomeRouteData().go(context));
}
});
if (widget.navigateToNotification) {
Router.neglect(
context,
() => const NotificationRouteData().go(context),
);
} else {
Router.neglect(context, () => const HomeRouteData().go(context));
}
} else {
WidgetsBinding.instance.addPostFrameCallback((_) {
Router.neglect(context, () => const LoginScreenRoute().go(context));