Added data from api for recommended

This commit is contained in:
llsajjad
2025-08-18 08:23:05 +03:30
parent 3c5284f508
commit 34afaa9d4d
15 changed files with 978 additions and 86 deletions
+14 -9
View File
@@ -5,6 +5,7 @@ import 'package:tm_app/core/routes/app_routes.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/home/home_response/home_response_model.dart';
import 'package:tm_app/data/services/model/recommended_tenders_response/recommended_tenders_response.dart';
import 'package:tm_app/view_models/home_view_model.dart';
import 'package:tm_app/views/home/widgets/notification_card.dart';
@@ -41,7 +42,7 @@ class DesktopHomePage extends StatelessWidget {
SizedBox(height: 32.0.h()),
_yourTenderText(),
SizedBox(height: 8.0.h()),
_bottomListView(homeViewModel.homeResponse!),
_bottomListView(homeViewModel.recommendedTendersResponse!),
],
),
);
@@ -150,27 +151,31 @@ class DesktopHomePage extends StatelessWidget {
child: Align(
alignment: Alignment.centerLeft,
child: Text(
AppStrings.yourTenders,
AppStrings.recommendation,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey60,
fontSize: 18.0.sp(),
fontWeight: FontWeight.w700,
color: AppColors.grey80,
),
),
),
);
}
Widget _bottomListView(HomeResponseModel homeResponse) {
Widget _bottomListView(
RecommendedTendersResponse recommendedTendersResponse,
) {
return SizedBox(
width: 740,
height: 290.0,
height: 387.0,
child: ListView.builder(
padding: EdgeInsets.only(bottom: 20),
itemCount: homeResponse.yourTenders?.length ?? 0,
itemCount: recommendedTendersResponse.data!.tenders.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return TendersListItem(tender: homeResponse.yourTenders![index]);
return TendersListItem(
tender: recommendedTendersResponse.data!.tenders[index]!,
);
},
),
);
+17 -13
View File
@@ -6,6 +6,7 @@ import 'package:tm_app/core/routes/app_routes.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/home/home_response/home_response_model.dart';
import 'package:tm_app/data/services/model/recommended_tenders_response/recommended_tenders_response.dart';
import 'package:tm_app/view_models/home_view_model.dart';
import 'package:tm_app/views/home/widgets/notification_card.dart';
import 'package:tm_app/views/shared/tender_app_bar.dart';
@@ -43,10 +44,9 @@ class MobileHomePage extends StatelessWidget {
_firstTenderCardsRow(context, homeViewModel.homeResponse!),
SizedBox(height: 8.0.h()),
_secondTenderCardsRow(homeViewModel.homeResponse!),
SizedBox(height: 32.0.h()),
SizedBox(height: 40.0.h()),
_yourTenderText(),
SizedBox(height: 8.0.h()),
_bottomListView(homeViewModel.homeResponse!),
_bottomListView(homeViewModel.recommendedTendersResponse!),
],
),
);
@@ -150,26 +150,30 @@ class MobileHomePage extends StatelessWidget {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Text(
AppStrings.yourTenders,
AppStrings.recommendation,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey60,
fontSize: 18.0.sp(),
fontWeight: FontWeight.w700,
color: AppColors.grey80,
),
),
);
}
Widget _bottomListView(HomeResponseModel homeResponse) {
return SizedBox(
Widget _bottomListView(
RecommendedTendersResponse recommendedTendersResponse,
) {
return Container(
constraints: BoxConstraints(maxHeight: 387.0.h()),
width: double.infinity,
height: 286.0.h(),
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 24.0.w(), vertical: 16.0.h()),
itemCount: homeResponse.yourTenders?.length ?? 0,
padding: EdgeInsets.symmetric(horizontal: 24.0.w(), vertical: 15.0.h()),
itemCount: recommendedTendersResponse.data!.tenders.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return TendersListItem(tender: homeResponse.yourTenders![index]);
return TendersListItem(
tender: recommendedTendersResponse.data!.tenders[index]!,
);
},
),
);
+10 -9
View File
@@ -5,6 +5,7 @@ import 'package:tm_app/core/routes/app_routes.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/home/home_response/home_response_model.dart';
import 'package:tm_app/data/services/model/recommended_tenders_response/recommended_tenders_response.dart';
import 'package:tm_app/view_models/home_view_model.dart';
import 'package:tm_app/views/home/widgets/notification_card.dart';
@@ -49,7 +50,7 @@ class TabletHomePage extends StatelessWidget {
SizedBox(height: 32.0.h()),
_yourTenderText(),
SizedBox(height: 8.0.h()),
_bottomListView(homeViewModel.homeResponse!),
_bottomListView(homeViewModel.recommendedTendersResponse!),
],
),
),
@@ -170,24 +171,24 @@ class TabletHomePage extends StatelessWidget {
Widget _yourTenderText() {
return Text(
AppStrings.yourTenders,
AppStrings.recommendation,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey60,
fontSize: 18.0.sp(),
fontWeight: FontWeight.w700,
color: AppColors.grey80,
),
);
}
Widget _bottomListView(HomeResponseModel homeResponse) {
Widget _bottomListView(RecommendedTendersResponse recommendedTendersResponse) {
return SizedBox(
width: double.infinity,
height: 310.0.h(),
height: 387.0.h(),
child: ListView.builder(
itemCount: homeResponse.yourTenders?.length ?? 0,
itemCount: recommendedTendersResponse.data!.tenders.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return TendersListItem(tender: homeResponse.yourTenders![index]);
return TendersListItem(tender: recommendedTendersResponse.data!.tenders[index]!);
},
),
);
+88 -55
View File
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:tm_app/data/services/model/tender/tender_model.dart';
import 'package:tm_app/core/constants/strings.dart';
import 'package:tm_app/data/services/model/tender_data/tender_data.dart';
import 'package:tm_app/views/home/widgets/tender_card_progress_bar.dart';
import '../../core/constants/assets.dart';
import '../../core/theme/colors.dart';
@@ -8,7 +10,7 @@ import '../../core/utils/size_config.dart';
class TendersListItem extends StatelessWidget {
const TendersListItem({required this.tender, super.key});
final TenderModel tender;
final TenderData tender;
@override
Widget build(BuildContext context) {
@@ -16,71 +18,93 @@ class TendersListItem extends StatelessWidget {
decoration: BoxDecoration(
color: AppColors.cardBackground,
borderRadius: BorderRadius.circular(4),
border: Border.all(color: AppColors.grey30),
),
margin: EdgeInsetsDirectional.only(end: 16.0.w()),
width: 320.0.w(),
height: 280.0.h(),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0.w(), vertical: 16.0.h()),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
tender.createdTime ?? '',
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey60,
),
SizedBox(
width: double.infinity,
child: Text(
timeConvertor(tender.publicationDate!),
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey60,
),
Container(
width: 91.0.w(),
height: 24.0.h(),
decoration: BoxDecoration(
color: AppColors.green20,
borderRadius: BorderRadius.circular(8),
),
alignment: Alignment.center,
child: Text(
tender.status ?? '',
),
),
SizedBox(height: 10.0.h()),
Container(
padding: EdgeInsets.symmetric(
horizontal: 10.0.w(),
vertical: 5.0.h(),
),
decoration: BoxDecoration(
color: AppColors.primary2,
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${AppStrings.tenderDeadline} :',
style: TextStyle(
fontSize: 12.0.sp(),
fontSize: 15.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.green30,
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 ?? '',
tender.title!,
style: TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: 16.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey80,
),
),
SizedBox(height: 8.0.h()),
Text(
tender.description ?? '',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey70,
SizedBox(
width: double.infinity,
child: Text(
tender.description!,
textAlign: TextAlign.left,
maxLines: 6,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey70,
),
),
),
SizedBox(height: 24.0.h()),
SizedBox(height: 18.0.h()),
TenderCardProgressBar(),
SizedBox(height: 15.0.h()),
Row(
children: [
SvgPicture.asset(AssetsManager.location),
SizedBox(width: 1.0.w()),
Text(
tender.location ?? '',
tender.countryCode!,
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
@@ -94,23 +118,23 @@ class TendersListItem extends StatelessWidget {
child: Image.asset(AssetsManager.seFlag, fit: BoxFit.cover),
),
Spacer(),
Container(
width: 96.0.w(),
height: 24.0.h(),
decoration: BoxDecoration(
color: AppColors.grey30,
borderRadius: BorderRadius.circular(88),
),
alignment: Alignment.center,
child: Text(
tender.type ?? '',
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey60,
),
),
),
// Container(
// width: 96.0.w(),
// height: 24.0.h(),
// decoration: BoxDecoration(
// color: AppColors.grey30,
// borderRadius: BorderRadius.circular(88),
// ),
// alignment: Alignment.center,
// child: Text(
// 'tender.type',
// style: TextStyle(
// fontSize: 12.0.sp(),
// fontWeight: FontWeight.w500,
// color: AppColors.grey60,
// ),
// ),
// ),
],
),
],
@@ -119,3 +143,12 @@ class TendersListItem extends StatelessWidget {
);
}
}
String timeConvertor(int time) {
DateTime date = DateTime.fromMillisecondsSinceEpoch(time);
String formattedDate =
"${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}";
return formattedDate;
}
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:tm_app/core/constants/strings.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
class TenderCardProgressBar extends StatelessWidget {
const TenderCardProgressBar({super.key});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppStrings.tenderMatchProfile,
style: TextStyle(
fontSize: 12.0.sp(),
color: AppColors.grey80,
fontWeight: FontWeight.w400,
),
),
Text(
AppStrings.tenderMatchPercentageExample,
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.secondaryTextColor,
),
),
],
),
SizedBox(height: 6.0.h()),
ClipRRect(
borderRadius: BorderRadius.circular(4),
child: LinearProgressIndicator(
value: 0.75,
backgroundColor: AppColors.grey20,
valueColor: AlwaysStoppedAnimation<Color>(AppColors.secondary50),
minHeight: 6.0.h(),
),
),
],
);
}
}