fixed some bug
This commit is contained in:
@@ -34,9 +34,14 @@ class HomeViewModel with ChangeNotifier {
|
|||||||
int _currentPage = 0;
|
int _currentPage = 0;
|
||||||
bool _isLoadingMore = false;
|
bool _isLoadingMore = false;
|
||||||
bool _hasMore = true;
|
bool _hasMore = true;
|
||||||
|
|
||||||
|
/// آیا الان در حالت Recommended هستیم یا YourTenders
|
||||||
|
bool _isRecommendedMode = false;
|
||||||
|
|
||||||
List<TenderData> get tenders => _tenders;
|
List<TenderData> get tenders => _tenders;
|
||||||
bool get isLoadingMore => _isLoadingMore;
|
bool get isLoadingMore => _isLoadingMore;
|
||||||
bool get hasMore => _hasMore;
|
bool get hasMore => _hasMore;
|
||||||
|
bool get isRecommendedMode => _isRecommendedMode;
|
||||||
|
|
||||||
void init() async {
|
void init() async {
|
||||||
await getApprovedStates();
|
await getApprovedStates();
|
||||||
@@ -66,9 +71,7 @@ class HomeViewModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getHomeRecommandTenders({bool reset = false}) async {
|
Future<void> getHomeRecommandTenders({bool reset = false}) async {
|
||||||
if (_isLoadingMore || (!_hasMore && !reset)) {
|
if (_isLoadingMore || (!_hasMore && !reset)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
_currentPage = 0;
|
_currentPage = 0;
|
||||||
@@ -78,6 +81,7 @@ class HomeViewModel with ChangeNotifier {
|
|||||||
|
|
||||||
_isLoadingMore = true;
|
_isLoadingMore = true;
|
||||||
_errorMessage = null;
|
_errorMessage = null;
|
||||||
|
_isRecommendedMode = true; // ✅ اینجا یعنی در حالت Recommended هستیم
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
final result = await _homeRepository.getHomeRecommendedTenders(
|
final result = await _homeRepository.getHomeRecommendedTenders(
|
||||||
@@ -98,6 +102,7 @@ class HomeViewModel with ChangeNotifier {
|
|||||||
_hasMore = false;
|
_hasMore = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Error<RecommendedTendersResponse>():
|
case Error<RecommendedTendersResponse>():
|
||||||
_errorMessage = result.error.toString();
|
_errorMessage = result.error.toString();
|
||||||
break;
|
break;
|
||||||
@@ -109,6 +114,7 @@ class HomeViewModel with ChangeNotifier {
|
|||||||
|
|
||||||
Future<void> getYourTenders() async {
|
Future<void> getYourTenders() async {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
_isRecommendedMode = false; // ✅ وقتی YourTenders میاد → بدون pagination
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
final result = await _homeRepository.getYourTenders();
|
final result = await _homeRepository.getYourTenders();
|
||||||
@@ -119,6 +125,7 @@ class HomeViewModel with ChangeNotifier {
|
|||||||
_errorMessage = null;
|
_errorMessage = null;
|
||||||
|
|
||||||
if (data?.data?.isEmpty ?? true) {
|
if (data?.data?.isEmpty ?? true) {
|
||||||
|
// اگه YourTenders خالی بود → برو سمت Recommended
|
||||||
await getHomeRecommandTenders(reset: true);
|
await getHomeRecommandTenders(reset: true);
|
||||||
} else {
|
} else {
|
||||||
_tenders.clear();
|
_tenders.clear();
|
||||||
|
|||||||
@@ -27,25 +27,36 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
return Center(child: Text(homeViewModel.errorMessage!));
|
return Center(child: Text(homeViewModel.errorMessage!));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 780,
|
||||||
|
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 55),
|
SizedBox(height: 55),
|
||||||
// SizedBox(width: 780, child: NotificationCard()),
|
// SizedBox(width: 780, child: NotificationCard()),
|
||||||
SizedBox(height: 40.0),
|
SizedBox(height: 40.0),
|
||||||
_progressBarsRow(homeViewModel.tenderApprovalsStateResponse!),
|
_progressBarsRow(
|
||||||
SizedBox(height: 32.0.h()),
|
|
||||||
_firstTenderCardsRow(
|
|
||||||
context,
|
|
||||||
homeViewModel.tenderApprovalsStateResponse!,
|
homeViewModel.tenderApprovalsStateResponse!,
|
||||||
),
|
),
|
||||||
SizedBox(height: 32.0.h()),
|
SizedBox(height: 32.0.h()),
|
||||||
_yourTenderText(),
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 15.0.w()),
|
||||||
|
child: _firstTenderCardsRow(
|
||||||
|
context,
|
||||||
|
homeViewModel.tenderApprovalsStateResponse!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 32.0.h()),
|
||||||
|
_yourTenderText(homeViewModel),
|
||||||
SizedBox(height: 8.0.h()),
|
SizedBox(height: 8.0.h()),
|
||||||
_bottomListView(homeViewModel),
|
_bottomListView(homeViewModel),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -81,7 +92,7 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
circularProgressIndicatorWidth: 176,
|
circularProgressIndicatorWidth: 176,
|
||||||
circularProgressIndicatorHeight: 176,
|
circularProgressIndicatorHeight: 176,
|
||||||
),
|
),
|
||||||
SizedBox(width: 106),
|
//SizedBox(width: 106),
|
||||||
// ProgressBarColumn(
|
// ProgressBarColumn(
|
||||||
// text: AppStrings.contracting,
|
// text: AppStrings.contracting,
|
||||||
// value: double.parse(homeResponse.contracting ?? '0'),
|
// value: double.parse(homeResponse.contracting ?? '0'),
|
||||||
@@ -100,11 +111,13 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
TenderCard(
|
Expanded(
|
||||||
|
child: TenderCard(
|
||||||
backgroundColor: AppColors.primary20,
|
backgroundColor: AppColors.primary20,
|
||||||
iconPath: 'assets/icons/arrows.svg',
|
iconPath: 'assets/icons/arrows.svg',
|
||||||
title: AppStrings.tenderSubmitted,
|
title: AppStrings.tenderSubmitted,
|
||||||
amount: tenderApprovalsStateResponse.data!.approvedTenders.toString(),
|
amount:
|
||||||
|
tenderApprovalsStateResponse.data!.approvedTenders.toString(),
|
||||||
// tenderApprovalsStateResponse
|
// tenderApprovalsStateResponse
|
||||||
// .data!
|
// .data!
|
||||||
// .approvalsBySubmission!
|
// .approvalsBySubmission!
|
||||||
@@ -118,8 +131,10 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
YourTendersRouteData().push(context);
|
YourTendersRouteData().push(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
TenderCard(
|
Expanded(
|
||||||
|
child: TenderCard(
|
||||||
backgroundColor: AppColors.primary10,
|
backgroundColor: AppColors.primary10,
|
||||||
iconPath: 'assets/icons/thumb.svg',
|
iconPath: 'assets/icons/thumb.svg',
|
||||||
title: AppStrings.approvedTenders,
|
title: AppStrings.approvedTenders,
|
||||||
@@ -132,7 +147,8 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
YourTendersRouteData().push(context);
|
YourTendersRouteData().push(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
),
|
||||||
|
// SizedBox(width: 10),
|
||||||
// TenderCard(
|
// TenderCard(
|
||||||
// backgroundColor: AppColors.orange10,
|
// backgroundColor: AppColors.orange10,
|
||||||
// iconPath: 'assets/icons/shield.svg',
|
// iconPath: 'assets/icons/shield.svg',
|
||||||
@@ -160,13 +176,16 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _yourTenderText() {
|
Widget _yourTenderText(HomeViewModel homeViewModel) {
|
||||||
|
final isYourTenders = homeViewModel.data?.data?.isNotEmpty ?? false;
|
||||||
return ConstrainedBox(
|
return ConstrainedBox(
|
||||||
constraints: BoxConstraints(maxWidth: 740),
|
constraints: BoxConstraints(maxWidth: 740),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
AppStrings.recommendation,
|
isYourTenders
|
||||||
|
? AppStrings.yourTenders
|
||||||
|
: AppStrings.recommendedTenders,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18.0.sp(),
|
fontSize: 18.0.sp(),
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@@ -179,15 +198,17 @@ class DesktopHomePage extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _bottomListView(HomeViewModel homeViewModel) {
|
Widget _bottomListView(HomeViewModel homeViewModel) {
|
||||||
final controller = ScrollController();
|
final controller = ScrollController();
|
||||||
|
|
||||||
controller.addListener(() {
|
controller.addListener(() {
|
||||||
|
if (homeViewModel.isRecommendedMode) {
|
||||||
if (controller.position.pixels >=
|
if (controller.position.pixels >=
|
||||||
controller.position.maxScrollExtent - 200) {
|
controller.position.maxScrollExtent - 200) {
|
||||||
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
||||||
homeViewModel.getHomeRecommandTenders();
|
homeViewModel.getHomeRecommandTenders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 740,
|
width: 740,
|
||||||
height: 387.0,
|
height: 387.0,
|
||||||
|
|||||||
@@ -195,12 +195,14 @@ class MobileHomePage extends StatelessWidget {
|
|||||||
final controller = ScrollController();
|
final controller = ScrollController();
|
||||||
|
|
||||||
controller.addListener(() {
|
controller.addListener(() {
|
||||||
|
if (homeViewModel.isRecommendedMode) {
|
||||||
if (controller.position.pixels >=
|
if (controller.position.pixels >=
|
||||||
controller.position.maxScrollExtent - 200) {
|
controller.position.maxScrollExtent - 200) {
|
||||||
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
||||||
homeViewModel.getHomeRecommandTenders();
|
homeViewModel.getHomeRecommandTenders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class TabletHomePage extends StatelessWidget {
|
|||||||
SizedBox(height: 8.0.h()),
|
SizedBox(height: 8.0.h()),
|
||||||
//_secondTenderCardsRow(homeViewModel.homeResponse!),
|
//_secondTenderCardsRow(homeViewModel.homeResponse!),
|
||||||
SizedBox(height: 32.0.h()),
|
SizedBox(height: 32.0.h()),
|
||||||
_yourTenderText(),
|
_yourTenderText(homeViewModel),
|
||||||
SizedBox(height: 8.0.h()),
|
SizedBox(height: 8.0.h()),
|
||||||
_bottomListView(homeViewModel),
|
_bottomListView(homeViewModel),
|
||||||
],
|
],
|
||||||
@@ -192,9 +192,10 @@ class TabletHomePage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _yourTenderText() {
|
Widget _yourTenderText(HomeViewModel homeViewModel) {
|
||||||
|
final isYourTenders = homeViewModel.data?.data?.isNotEmpty ?? false;
|
||||||
return Text(
|
return Text(
|
||||||
AppStrings.recommendation,
|
isYourTenders ? AppStrings.yourTenders : AppStrings.recommendedTenders,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18.0.sp(),
|
fontSize: 18.0.sp(),
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@@ -207,13 +208,16 @@ class TabletHomePage extends StatelessWidget {
|
|||||||
final controller = ScrollController();
|
final controller = ScrollController();
|
||||||
|
|
||||||
controller.addListener(() {
|
controller.addListener(() {
|
||||||
|
if (homeViewModel.isRecommendedMode) {
|
||||||
if (controller.position.pixels >=
|
if (controller.position.pixels >=
|
||||||
controller.position.maxScrollExtent - 200) {
|
controller.position.maxScrollExtent - 200) {
|
||||||
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
||||||
homeViewModel.getHomeRecommandTenders();
|
homeViewModel.getHomeRecommandTenders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 387.0.h(),
|
height: 387.0.h(),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -50,7 +51,8 @@ class _LoginDesktopPageState extends State<LoginDesktopPage> {
|
|||||||
backgroundColor: AppColors.backgroundColor,
|
backgroundColor: AppColors.backgroundColor,
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment:
|
||||||
|
kIsWeb ? MainAxisAlignment.spaceAround : MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 526,
|
width: 526,
|
||||||
@@ -111,7 +113,8 @@ class _LoginDesktopPageState extends State<LoginDesktopPage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
kIsWeb
|
||||||
|
? Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 20.0.h()),
|
padding: EdgeInsets.symmetric(vertical: 20.0.h()),
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
AssetsManager.webLoginImage,
|
AssetsManager.webLoginImage,
|
||||||
@@ -119,7 +122,8 @@ class _LoginDesktopPageState extends State<LoginDesktopPage> {
|
|||||||
height: 944.0,
|
height: 944.0,
|
||||||
fit: BoxFit.fitWidth,
|
fit: BoxFit.fitWidth,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: Container(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:tm_app/core/constants/assets.dart';
|
||||||
|
import 'package:tm_app/core/constants/strings.dart';
|
||||||
import 'package:tm_app/core/routes/app_routes.dart';
|
import 'package:tm_app/core/routes/app_routes.dart';
|
||||||
import 'package:tm_app/view_models/profile_view_model.dart';
|
import 'package:tm_app/view_models/profile_view_model.dart';
|
||||||
|
|
||||||
@@ -87,17 +90,69 @@ class _TabletProfilePageState extends State<TabletProfilePage> {
|
|||||||
TitleDescription(title: 'Founded', description: '2010'),
|
TitleDescription(title: 'Founded', description: '2010'),
|
||||||
SizedBox(height: 24.0.h()),
|
SizedBox(height: 24.0.h()),
|
||||||
// Theme Toggle
|
// Theme Toggle
|
||||||
Container(
|
Align(
|
||||||
padding: EdgeInsets.symmetric(
|
alignment: AlignmentDirectional.centerStart,
|
||||||
horizontal: 16.0.w(),
|
child: Text(
|
||||||
vertical: 12.0.h(),
|
AppStrings.settings,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20.0.sp(),
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColors.grey70,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 36.0.h()),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
AppStrings.appTheme,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.0.sp(),
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: AppColors.grey70,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
SvgPicture.asset(AssetsManager.sun),
|
||||||
|
SizedBox(width: 12.0.w()),
|
||||||
|
SizedBox(
|
||||||
|
width: 52.0.w(),
|
||||||
|
height: 32.0.h(),
|
||||||
|
child: ThemeToggle(),
|
||||||
|
),
|
||||||
|
SizedBox(width: 12.0.w()),
|
||||||
|
SvgPicture.asset(AssetsManager.moon),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 24.0.h()),
|
||||||
|
Divider(color: AppColors.dividerColor, thickness: 1),
|
||||||
|
SizedBox(height: 24.0.h()),
|
||||||
|
// Spacer(),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => viewModel.logout(),
|
||||||
|
child: Container(
|
||||||
|
width: 156,
|
||||||
|
height: 56.0.h(),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.surfaceColor,
|
color: AppColors.primary20,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(100),
|
||||||
border: Border.all(color: AppColors.borderColor),
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
'Logout',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.0.sp(),
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppColors.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: const ThemeToggle(),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user