fixed TM-171 jira task
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tm_app/views/completion_of_documents/pages/m_completion_of_documents_page.dart';
|
||||
import 'package:tm_app/views/detail/pages/detail_screen.dart';
|
||||
import 'package:tm_app/views/forget_password_create/pages/forgot_password_create_screen.dart';
|
||||
import 'package:tm_app/views/forget_password_otp.dart/pages/forgot_password_otp_screen.dart';
|
||||
import 'package:tm_app/views/forget_password_otp/pages/forgot_password_otp_screen.dart';
|
||||
import 'package:tm_app/views/home/pages/home_screen.dart';
|
||||
import 'package:tm_app/views/liked_tenders/pages/liked_tenders_screen.dart';
|
||||
import 'package:tm_app/views/login/pages/login_screen.dart';
|
||||
@@ -34,6 +36,22 @@ final GoRouter appRouter = GoRouter(
|
||||
routes: $appRoutes,
|
||||
initialLocation: '/splash',
|
||||
navigatorKey: rootNavigatorKey,
|
||||
redirect: (context, state) {
|
||||
final prefs = context.read<SharedPreferences>();
|
||||
final hasToken = prefs.getString('bearer') != null;
|
||||
final path = state.uri.path;
|
||||
final location = state.matchedLocation;
|
||||
final isSplash = path == '/splash' || location == '/splash';
|
||||
final isLogin = path == '/login' || location == '/login';
|
||||
final isForgotFlow =
|
||||
path.startsWith('/forgot-password') ||
|
||||
location.startsWith('/forgot-password');
|
||||
final isPublic = isSplash || isLogin || isForgotFlow;
|
||||
if (!hasToken && !isPublic) {
|
||||
return '/splash';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
||||
// Login route - outside the shell
|
||||
|
||||
@@ -101,7 +101,7 @@ class _TabletForgotPasswordCreatePageState
|
||||
onToggleVisibility:
|
||||
viewModel.toggleForgotPasswordVisibility,
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
SizedBox(height: 24.0.h()),
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: 16.0.w()),
|
||||
@@ -149,7 +149,7 @@ class _TabletForgotPasswordCreatePageState
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 80.0.h()),
|
||||
SizedBox(height: 70.0.h()),
|
||||
viewModel.isResetPasswordLoading
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isNewPasswordValid,
|
||||
@@ -169,6 +169,7 @@ class _TabletForgotPasswordCreatePageState
|
||||
: null,
|
||||
),
|
||||
|
||||
SizedBox(height: 32.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
|
||||
+5
-3
@@ -1,7 +1,8 @@
|
||||
import 'package:flutter/material.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 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/views/forget_password_otp/pages/d_forget_password_otp_page.dart';
|
||||
import 'package:tm_app/views/forget_password_otp/pages/m_forget_password_otp_page.dart';
|
||||
import 'package:tm_app/views/forget_password_otp/pages/t_forget_password_otp_page.dart';
|
||||
|
||||
import '../../shared/responsive_builder.dart';
|
||||
|
||||
@@ -10,6 +11,7 @@ class ForgotPasswordOtpScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SizeConfig.init(context);
|
||||
return const ResponsiveBuilder(
|
||||
mobile: MobileForgotPasswordOtpPage(),
|
||||
tablet: TabletForgotPasswordOtpPage(),
|
||||
+2
-2
@@ -113,7 +113,7 @@ class _TabletForgotPasswordOtpPageState
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
SizedBox(height: 70.0.h()),
|
||||
viewModel.isLoadingOtp
|
||||
? BaseButton(
|
||||
isEnabled: viewModel.isOtpValid,
|
||||
@@ -131,7 +131,7 @@ class _TabletForgotPasswordOtpPageState
|
||||
}
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
SizedBox(height: 32.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
|
||||
import '../../shared/responsive_builder.dart';
|
||||
import 'd_forgot_apssword_page.dart';
|
||||
@@ -10,6 +11,7 @@ class ForgotPasswordScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SizeConfig.init(context);
|
||||
return const ResponsiveBuilder(
|
||||
mobile: MobileForgotPasswordPage(),
|
||||
tablet: TabletForgotPasswordPage(),
|
||||
|
||||
@@ -59,7 +59,7 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
||||
builder: (context, viewModel, _) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: 364,
|
||||
width: 364.0.w(),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -97,7 +97,7 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
||||
label: ForgotPasswordStrings.emailHint,
|
||||
isPassword: false,
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
SizedBox(height: 70.0.h()),
|
||||
viewModel.isLoadingForgot
|
||||
? const BaseButton(
|
||||
isEnabled: false,
|
||||
@@ -115,7 +115,7 @@ class _TabletForgotPasswordPageState extends State<TabletForgotPasswordPage> {
|
||||
}
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(height: 32.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -51,7 +51,7 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: SizedBox(
|
||||
width: 526,
|
||||
width: 364.0.w(),
|
||||
child: Consumer<AuthViewModel>(
|
||||
builder: (context, viewModel, _) {
|
||||
return Column(
|
||||
@@ -65,9 +65,9 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
height: 50.0.h(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
SizedBox(height: 72.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
SizedBox(height: 40.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
@@ -77,7 +77,7 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
SizedBox(height: 24.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
@@ -90,7 +90,7 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
onToggleVisibility: viewModel.togglePasswordVisibility,
|
||||
borderRedus: 12,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
SizedBox(height: 70.0.h()),
|
||||
if (viewModel.isLoading)
|
||||
const BaseButton(
|
||||
isEnabled: false,
|
||||
@@ -107,7 +107,7 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
}
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 32.0),
|
||||
SizedBox(height: 30.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
|
||||
Reference in New Issue
Block a user