fixed logout at refresh failed
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:tm_app/view_models/liked_tenders_view_model.dart';
|
||||
import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_list_item.dart';
|
||||
import 'package:tm_app/views/shared/page_selection_dialog.dart';
|
||||
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../shared/desktop_navigation_widget.dart';
|
||||
import '../../shared/tablet_desktop_appbar.dart';
|
||||
@@ -175,7 +176,13 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(AssetsManager.arrowDownSmall,colorFilter: ColorFilter.mode(AppColors.grey60, BlendMode.srcIn),),
|
||||
SvgPicture.asset(
|
||||
AssetsManager.arrowDownSmall,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColors.grey60,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
),
|
||||
@@ -230,7 +237,13 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
viewModel.removeTenderById(item.tenderId!);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(tender: item.tender!, isDesktop: true),
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
isDesktop: true,
|
||||
onTap: () {
|
||||
TenderDetailRouteData(tenderId: item.tenderId!).push(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -10,6 +10,8 @@ import 'package:tm_app/views/liked_tenders/strings/liked_tenders_strings.dart';
|
||||
import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_list_item.dart';
|
||||
import 'package:tm_app/views/login/widgets/widgets.dart';
|
||||
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
|
||||
class LikedTendersMobilePage extends StatefulWidget {
|
||||
const LikedTendersMobilePage({super.key});
|
||||
|
||||
@@ -209,7 +211,14 @@ class _LikedTendersMobilePageState extends State<LikedTendersMobilePage> {
|
||||
viewModel.removeTenderById(item.tenderId!);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(tender: item.tender!),
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
onTap: () {
|
||||
TenderDetailRouteData(
|
||||
tenderId: item.tenderId!,
|
||||
).push(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_list_item.dart'
|
||||
import 'package:tm_app/views/shared/page_selection_dialog.dart';
|
||||
import 'package:tm_app/views/shared/tender_app_bar.dart';
|
||||
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../shared/tablet_desktop_appbar.dart';
|
||||
import '../../shared/tablet_navigation_widget.dart';
|
||||
@@ -256,7 +257,12 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
|
||||
viewModel.removeTenderById(item.tenderId!);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(tender: item.tender!),
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
onTap: () {
|
||||
TenderDetailRouteData(tenderId: item.tenderId!).push(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -14,161 +14,169 @@ import '../../shared/flag.dart';
|
||||
class LikedListItem extends StatelessWidget {
|
||||
const LikedListItem({
|
||||
required this.tender,
|
||||
required this.onTap,
|
||||
this.isDesktop = false,
|
||||
super.key,
|
||||
});
|
||||
final TenderData tender;
|
||||
|
||||
final bool isDesktop;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.read<LikedTendersViewModel>();
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: AppColors.grey30),
|
||||
),
|
||||
width: double.infinity,
|
||||
height: 250.0.h(),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0.w(), vertical: 16.0.h()),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 10.0.h()),
|
||||
isDesktop
|
||||
? Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10.0.w(),
|
||||
vertical: 5.0.h(),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary20,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${HomeStrings.tenderDeadline} :',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.textBlue,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
timeConvertor(tender.tenderDeadline!),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8.0.w()),
|
||||
InkWell(
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.trash,
|
||||
width: 32.0.w(),
|
||||
height: 32.0.h(),
|
||||
),
|
||||
onTap: () {
|
||||
if (tender.id != null) {
|
||||
viewModel.removeTenderById(tender.id!);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10.0.w(),
|
||||
vertical: 5.0.h(),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary20,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: AppColors.grey30),
|
||||
),
|
||||
width: double.infinity,
|
||||
height: 250.0.h(),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.0.w(),
|
||||
vertical: 16.0.h(),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 10.0.h()),
|
||||
isDesktop
|
||||
? Row(
|
||||
children: [
|
||||
Text(
|
||||
'${HomeStrings.tenderDeadline} :',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.textBlue,
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10.0.w(),
|
||||
vertical: 5.0.h(),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary20,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${HomeStrings.tenderDeadline} :',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.textBlue,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
timeConvertor(tender.tenderDeadline!),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
timeConvertor(tender.tenderDeadline!),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey80,
|
||||
SizedBox(width: 8.0.w()),
|
||||
InkWell(
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.trash,
|
||||
width: 32.0.w(),
|
||||
height: 32.0.h(),
|
||||
),
|
||||
onTap: () {
|
||||
if (tender.id != null) {
|
||||
viewModel.removeTenderById(tender.id!);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10.0.w(),
|
||||
vertical: 5.0.h(),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary20,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${HomeStrings.tenderDeadline} :',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.textBlue,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
timeConvertor(tender.tenderDeadline!),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12.0.h()),
|
||||
Text(
|
||||
tender.title!,
|
||||
style: TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
fontSize: 16.0.sp(),
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
tender.description!,
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
SizedBox(height: 12.0.h()),
|
||||
Text(
|
||||
tender.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey70,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
fontSize: 16.0.sp(),
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(AssetsManager.location),
|
||||
SizedBox(width: 1.0.w()),
|
||||
Text(
|
||||
tender.countryCode!,
|
||||
SizedBox(height: 8.0.h()),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
tender.description!,
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12.0.sp(),
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey80,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8.0.w()),
|
||||
tender.countryCode != null
|
||||
? Flag(countryCode: tender.countryCode!)
|
||||
: const Flag(countryCode: ''),
|
||||
const Spacer(),
|
||||
),
|
||||
const Spacer(),
|
||||
|
||||
SizedBox(width: 30.0.w()),
|
||||
],
|
||||
),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(AssetsManager.location),
|
||||
SizedBox(width: 1.0.w()),
|
||||
Text(
|
||||
tender.countryCode!,
|
||||
style: TextStyle(
|
||||
fontSize: 12.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8.0.w()),
|
||||
tender.countryCode != null
|
||||
? Flag(countryCode: tender.countryCode!)
|
||||
: const Flag(countryCode: ''),
|
||||
const Spacer(),
|
||||
|
||||
SizedBox(width: 30.0.w()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -56,76 +56,89 @@ class _LoginDesktopPageState extends State<LoginDesktopPage> {
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 364,
|
||||
child: Consumer<AuthViewModel>(
|
||||
builder: (context, viewModel, _) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
AssetsManager.logoBig,
|
||||
width: 320,
|
||||
height: 50,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
SizedBox(height: 72.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 7.0.w(),
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
LoginTextField(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
AssetsManager.logoBig,
|
||||
width: 320,
|
||||
height: 50,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
SizedBox(height: 72.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 7.0.w(),
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.obscurePassword,
|
||||
builder: (_, obscurePassword, __) {
|
||||
return LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
label: LoginStrings.passwordLabel,
|
||||
iconPath: AssetsManager.passwordIcon,
|
||||
prefixIconPadding: 7.0.w(),
|
||||
isPassword: true,
|
||||
obscureText: viewModel.obscurePassword,
|
||||
fieldHeight: 60.0.h(),
|
||||
obscureText: obscurePassword,
|
||||
onToggleVisibility:
|
||||
viewModel.togglePasswordVisibility,
|
||||
borderRedus: 12,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
if (viewModel.isLoading)
|
||||
const BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
onPressed: () async {
|
||||
if (viewModel.isLoginEnabled) {
|
||||
await viewModel.login();
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 32.0),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
|
||||
/// ✅ Only this part rebuilds now
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoading,
|
||||
builder: (_, isLoading, __) {
|
||||
return Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoginEnabled,
|
||||
builder: (_, isEnabled, __) {
|
||||
if (isLoading) {
|
||||
return BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
textColor: AppColors.white,
|
||||
);
|
||||
}
|
||||
|
||||
return BaseButton(
|
||||
isEnabled: isEnabled,
|
||||
onPressed:
|
||||
isEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
}
|
||||
: null,
|
||||
);
|
||||
},
|
||||
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,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -50,76 +50,90 @@ class _LoginMobilePageState extends State<LoginMobilePage> {
|
||||
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()),
|
||||
child: 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.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
|
||||
LoginTextField(
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.obscurePassword,
|
||||
builder: (_, obscurePassword, __) {
|
||||
return LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
label: LoginStrings.passwordLabel,
|
||||
iconPath: AssetsManager.passwordIcon,
|
||||
isPassword: true,
|
||||
obscureText: viewModel.obscurePassword,
|
||||
obscureText: obscurePassword,
|
||||
onToggleVisibility: viewModel.togglePasswordVisibility,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
);
|
||||
},
|
||||
),
|
||||
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);
|
||||
/// ✅ Only this part rebuilds now
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoading,
|
||||
builder: (_, isLoading, __) {
|
||||
return Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoginEnabled,
|
||||
builder: (_, isEnabled, __) {
|
||||
if (isLoading) {
|
||||
return BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
textColor: AppColors.white,
|
||||
);
|
||||
}
|
||||
|
||||
return BaseButton(
|
||||
isEnabled: isEnabled,
|
||||
onPressed:
|
||||
isEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
}
|
||||
: null,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
LoginStrings.forgotPassword,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
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,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -52,78 +52,90 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: SizedBox(
|
||||
width: 364.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()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 40.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
LoginTextField(
|
||||
child: 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()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 40.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.obscurePassword,
|
||||
builder: (_, obscurePassword, __) {
|
||||
return LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
label: LoginStrings.passwordLabel,
|
||||
iconPath: AssetsManager.passwordIcon,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
isPassword: true,
|
||||
obscureText: viewModel.obscurePassword,
|
||||
fieldHeight: 60.0.h(),
|
||||
obscureText: obscurePassword,
|
||||
onToggleVisibility: viewModel.togglePasswordVisibility,
|
||||
borderRedus: 12,
|
||||
),
|
||||
SizedBox(height: 70.0.h()),
|
||||
if (viewModel.isLoading)
|
||||
const BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
onPressed:
|
||||
viewModel.isLoginEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
SizedBox(height: 30.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 70.0.h()),
|
||||
|
||||
/// ✅ Only this part rebuilds now
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoading,
|
||||
builder: (_, isLoading, __) {
|
||||
return Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoginEnabled,
|
||||
builder: (_, isEnabled, __) {
|
||||
if (isLoading) {
|
||||
return BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
textColor: AppColors.white,
|
||||
);
|
||||
}
|
||||
|
||||
return BaseButton(
|
||||
isEnabled: isEnabled,
|
||||
onPressed:
|
||||
isEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
}
|
||||
: null,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
LoginStrings.forgotPassword,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 30.0.h()),
|
||||
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