345 lines
9.5 KiB
Dart
345 lines
9.5 KiB
Dart
import 'package:country_flags/country_flags.dart';
|
|
import 'package:flutter/material.dart' hide DateUtils;
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:tm_app/core/constants/strings.dart';
|
|
import 'package:tm_app/core/routes/app_routes.dart';
|
|
import 'package:tm_app/data/services/model/tender_data/tender_data.dart';
|
|
|
|
import '../../../core/constants/assets.dart';
|
|
import '../../../core/theme/colors.dart';
|
|
import '../../../core/utils/date_utils.dart';
|
|
import '../../../core/utils/size_config.dart';
|
|
import 'tender_action_buttons_row.dart';
|
|
|
|
class TenderCard extends StatelessWidget {
|
|
final TenderData tender;
|
|
final bool isDesktop;
|
|
const TenderCard({required this.tender, super.key, this.isDesktop = false});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
width: double.infinity,
|
|
margin: EdgeInsets.symmetric(horizontal: 16.0.w()),
|
|
height: 587.0.h(),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.grey0,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: AppColors.grey30),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
// Main content
|
|
Padding(
|
|
padding: EdgeInsets.all(16.0.w()),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Date
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
_dateText(),
|
|
if (isDesktop)
|
|
TenderActionButtonsRow(
|
|
tender: tender,
|
|
isDesktop: isDesktop,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 12.0.h()),
|
|
|
|
// Deadline badge
|
|
_deadlineBadge(),
|
|
SizedBox(height: 12.0.h()),
|
|
|
|
// Approval status badge
|
|
// _approvalStatusBadge(),
|
|
SizedBox(height: 12.0.h()),
|
|
|
|
// Title
|
|
_tenderTitle(),
|
|
SizedBox(height: 8.0.h()),
|
|
|
|
// Description
|
|
_tenderDescription(),
|
|
SizedBox(height: 12.0.h()),
|
|
|
|
// Tender ID
|
|
_idText(),
|
|
],
|
|
),
|
|
),
|
|
Spacer(),
|
|
// Bottom section with progress and actions
|
|
Padding(
|
|
padding: EdgeInsets.all(16.0.w()),
|
|
child: Column(
|
|
children: [
|
|
// Match percentage
|
|
_matchPercentage(),
|
|
SizedBox(height: 8.0.h()),
|
|
|
|
// Progress bar
|
|
_progressBar(),
|
|
SizedBox(height: 16.0.h()),
|
|
|
|
// Location and apply button
|
|
Row(
|
|
children: [
|
|
// Location info
|
|
_locationInfo(),
|
|
|
|
// See More button
|
|
_seeMoreButton(context),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 72.0.h()),
|
|
if (!isDesktop) TenderActionButtonsRow(tender: tender),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _dateText() {
|
|
return Text(
|
|
DateUtils.unixToDate(tender.publicationDate ?? 0),
|
|
style: TextStyle(
|
|
color: AppColors.grey60,
|
|
fontSize: 12.0.sp(),
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _deadlineBadge() {
|
|
return Container(
|
|
width: double.infinity,
|
|
height: 24.0.h(),
|
|
padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primary20,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
AppStrings.tenderDeadlineLabel,
|
|
style: TextStyle(
|
|
color: AppColors.textBlue,
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
Text(
|
|
DateUtils.unixToDate(tender.tenderDeadline ?? 0),
|
|
style: TextStyle(
|
|
color: AppColors.grey80,
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// Widget _approvalStatusBadge() {
|
|
// return Consumer<TendersViewModel>(
|
|
// builder: (context, viewModel, child) {
|
|
// final approvalStatus = viewModel.getApprovalStatusForTender(tender.id!);
|
|
// final statusText = approvalStatus ?? 'Pending';
|
|
|
|
// Color statusColor;
|
|
// switch (approvalStatus) {
|
|
// case 'approved':
|
|
// statusColor = AppColors.successColor;
|
|
// break;
|
|
// case 'rejected':
|
|
// statusColor = AppColors.errorColor;
|
|
// break;
|
|
// default:
|
|
// statusColor = AppColors.grey60;
|
|
// }
|
|
|
|
// return Container(
|
|
// width: double.infinity,
|
|
// height: 24.0.h(),
|
|
// padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
|
|
// decoration: BoxDecoration(
|
|
// color: AppColors.grey20,
|
|
// borderRadius: BorderRadius.circular(4),
|
|
// border: Border.all(color: statusColor),
|
|
// ),
|
|
// child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
// children: [
|
|
// Text(
|
|
// 'Approval Status',
|
|
// style: TextStyle(
|
|
// color: AppColors.grey80,
|
|
// fontSize: 14.0.sp(),
|
|
// fontWeight: FontWeight.w500,
|
|
// ),
|
|
// ),
|
|
// Text(
|
|
// statusText.toUpperCase(),
|
|
// style: TextStyle(
|
|
// color: statusColor,
|
|
// fontSize: 14.0.sp(),
|
|
// fontWeight: FontWeight.w500,
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// );
|
|
// },
|
|
// );
|
|
// }
|
|
|
|
Widget _tenderTitle() {
|
|
return Text(
|
|
tender.title ?? '',
|
|
style: TextStyle(
|
|
color: AppColors.grey80,
|
|
fontSize: 16.0.sp(),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _tenderDescription() {
|
|
return Text(
|
|
tender.description ?? '',
|
|
maxLines: 7,
|
|
style: TextStyle(
|
|
color: AppColors.grey70,
|
|
fontSize: 16.0.sp(),
|
|
fontWeight: FontWeight.w400,
|
|
height: 1.5,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _idText() {
|
|
return Text(
|
|
tender.id ?? '',
|
|
style: TextStyle(
|
|
color: AppColors.grey,
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _matchPercentage() {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
AppStrings.tenderMatchProfile,
|
|
style: TextStyle(
|
|
color: AppColors.grey80,
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
Text(
|
|
'${45}%',
|
|
style: TextStyle(
|
|
color: AppColors.secondaryTextColor,
|
|
fontSize: 16.0.sp(),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _progressBar() {
|
|
return Container(
|
|
width: double.infinity,
|
|
height: 4.0.h(),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.grey20,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
child: FractionallySizedBox(
|
|
alignment: Alignment.centerLeft,
|
|
widthFactor: (45) / 100,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: AppColors.secondary50,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _locationInfo() {
|
|
return Expanded(
|
|
child: Row(
|
|
children: [
|
|
SvgPicture.asset(AssetsManager.location),
|
|
SizedBox(width: 4.0.w()),
|
|
Text(
|
|
tender.countryCode ?? '',
|
|
style: TextStyle(
|
|
color: AppColors.grey80,
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
SizedBox(width: 8.0.w()),
|
|
// Country flag placeholder
|
|
if (tender.countryCode != null)
|
|
SizedBox(
|
|
width: 32.0.w(),
|
|
height: 21.0.h(),
|
|
child: CountryFlag.fromCountryCode(
|
|
tender.countryCode!,
|
|
shape: RoundedRectangle(4),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _seeMoreButton(BuildContext context) {
|
|
return InkWell(
|
|
onTap: () {
|
|
if (tender.id != null) {
|
|
TenderDetailRouteData(tenderId: tender.id!).push(context);
|
|
}
|
|
},
|
|
child: Container(
|
|
width: 108.0.w(),
|
|
height: 40.0.h(),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primary20,
|
|
borderRadius: BorderRadius.circular(100),
|
|
),
|
|
child: Text(
|
|
AppStrings.tenderSeeMore,
|
|
style: TextStyle(
|
|
color: AppColors.mainBlue,
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|