fixed auth pages sizes and push notification navigate bug
This commit is contained in:
@@ -38,10 +38,12 @@ class AppShellScreen extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ResponsiveBuilder(
|
return ResponsiveBuilder(
|
||||||
mobile: MobileShellPage(
|
mobile: SafeArea(
|
||||||
|
child: MobileShellPage(
|
||||||
navigationShell: navigationShell,
|
navigationShell: navigationShell,
|
||||||
onTap: (value) => _gotoBranch(value, context),
|
onTap: (value) => _gotoBranch(value, context),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
tablet: TabletShellPage(
|
tablet: TabletShellPage(
|
||||||
navigationShell: navigationShell,
|
navigationShell: navigationShell,
|
||||||
onTap: (value) => _gotoBranch(value, context),
|
onTap: (value) => _gotoBranch(value, context),
|
||||||
|
|||||||
+14
-9
@@ -54,21 +54,26 @@ class MyApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
@override
|
Future<void> setupInteractedMessage() async {
|
||||||
void initState() {
|
final initialMessage = await FirebaseMessaging.instance.getInitialMessage();
|
||||||
super.initState();
|
|
||||||
_handleInitialMessage();
|
if (initialMessage != null) {
|
||||||
|
_handleMessage(initialMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _handleInitialMessage() async {
|
FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
|
||||||
final message = await FirebaseMessaging.instance.getInitialMessage();
|
}
|
||||||
if (message != null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
void _handleMessage(RemoteMessage message) {
|
||||||
appRouter.go(
|
appRouter.go(
|
||||||
const SplashScreenRoute(navigateToNotification: true).location,
|
const SplashScreenRoute(navigateToNotification: true).location,
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
setupInteractedMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ class _MobileForgotPasswordCreatePageState
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.backgroundColor,
|
backgroundColor: AppColors.backgroundColor,
|
||||||
body: Center(
|
resizeToAvoidBottomInset: false,
|
||||||
|
body: SafeArea(
|
||||||
|
child: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||||
child: Consumer<AuthViewModel>(
|
child: Consumer<AuthViewModel>(
|
||||||
@@ -184,6 +186,7 @@ class _MobileForgotPasswordCreatePageState
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/d_forget_password_otp_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/m_forget_password_otp_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/t_forget_password_otp_page.dart';
|
||||||
|
|
||||||
import '../../shared/responsive_builder.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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,7 +46,8 @@ class _LoginMobilePageState extends State<LoginMobilePage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.backgroundColor,
|
backgroundColor: AppColors.backgroundColor,
|
||||||
body: Center(
|
body: SafeArea(
|
||||||
|
child: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||||
child: Consumer<AuthViewModel>(
|
child: Consumer<AuthViewModel>(
|
||||||
@@ -122,6 +123,7 @@ class _LoginMobilePageState extends State<LoginMobilePage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class _MobileSplashPageState extends State<MobileSplashPage> {
|
|||||||
|
|
||||||
void _viewModelListener() {
|
void _viewModelListener() {
|
||||||
if (viewModel.isLoggedIn) {
|
if (viewModel.isLoggedIn) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
if (widget.navigateToNotification) {
|
if (widget.navigateToNotification) {
|
||||||
Router.neglect(
|
Router.neglect(
|
||||||
context,
|
context,
|
||||||
@@ -36,7 +35,6 @@ class _MobileSplashPageState extends State<MobileSplashPage> {
|
|||||||
} else {
|
} else {
|
||||||
Router.neglect(context, () => const HomeRouteData().go(context));
|
Router.neglect(context, () => const HomeRouteData().go(context));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
Router.neglect(context, () => const LoginScreenRoute().go(context));
|
Router.neglect(context, () => const LoginScreenRoute().go(context));
|
||||||
|
|||||||
Reference in New Issue
Block a user