Files
tm_app/lib/views/your_tenders/widgets/tender_card.dart
T

206 lines
6.8 KiB
Dart

import 'package:country_flags/country_flags.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:tm_app/core/utils/date_utils.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/size_config.dart';
class TenderCard extends StatelessWidget {
final bool isDesktop;
final TenderData tender;
const TenderCard({required this.isDesktop, required this.tender, super.key});
@override
Widget build(BuildContext context) {
// Determine styling based on tender status
Color backgroundColor;
Color borderColor;
String? statusIcon;
Color statusCardColor;
Color statusTextColor;
if (tender.status == 'Won') {
backgroundColor = AppColors.green0;
borderColor = AppColors.green10;
statusIcon = AssetsManager.tickCircle;
statusCardColor = AppColors.green20;
statusTextColor = AppColors.green30;
} else if (tender.status == 'submitted') {
backgroundColor = AppColors.grey0;
borderColor = AppColors.grey30;
statusIcon = null;
statusCardColor = AppColors.green20;
statusTextColor = AppColors.green30;
} else {
backgroundColor = AppColors.red0.withValues(alpha: 0.2);
borderColor = AppColors.red0;
statusIcon = AssetsManager.closeCircle;
statusCardColor = AppColors.red0;
statusTextColor = AppColors.red10;
}
return Container(
height: isDesktop ? 182.0.h() : 240.0.h(),
width: double.infinity,
margin: EdgeInsets.only(
left: 24.0.w(),
right: 24.0.w(),
bottom: 24.0.h(),
),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: borderColor),
),
child: Padding(
padding: EdgeInsets.all(16.0.w()),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Top section with date and status
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Date
Text(
unixToDate(int.parse(tender.publicationDate!.toString())),
style: TextStyle(
color: AppColors.grey60,
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
),
),
// Completed status badge
Container(
padding: EdgeInsets.symmetric(
horizontal: 16.0.w(),
vertical: 4.0.h(),
),
decoration: BoxDecoration(
color: statusCardColor,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
if (statusIcon != null)
SvgPicture.asset(
statusIcon,
width: 16.0.w(),
height: 16.0.h(),
colorFilter: ColorFilter.mode(
statusTextColor,
BlendMode.srcIn,
),
),
SizedBox(width: 4.0.w()),
Text(
tender.status!,
style: TextStyle(
color: statusTextColor,
fontSize: 12.0.sp(),
fontWeight: FontWeight.w500,
),
),
],
),
),
],
),
SizedBox(height: 12.0.h()),
// Title
Text(
tender.title!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: AppColors.grey80,
fontSize: 16.0.sp(),
fontWeight: FontWeight.w600,
height: 1.3,
),
),
SizedBox(height: 8.0.h()),
// Description
Text(
tender.description!,
maxLines: isDesktop ? 2 : 3,
style: TextStyle(
color: AppColors.grey70,
fontSize: 14.0.sp(),
fontWeight: FontWeight.w400,
height: 1.4,
),
overflow: TextOverflow.ellipsis,
),
Spacer(),
// Bottom section with location and action button
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Location with flag
Expanded(
child: Row(
children: [
SvgPicture.asset(
AssetsManager.location,
width: 16.0.w(),
height: 16.0.h(),
),
SizedBox(width: 4.0.w()),
Text(
tender.countryCode!,
style: TextStyle(
color: AppColors.grey80,
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
),
),
SizedBox(width: 8.0.w()),
// Country flag
SizedBox(
width: 32.0.w(),
height: 21.0.h(),
child: CountryFlag.fromCountryCode(
tender.countryCode!,
shape: RoundedRectangle(4),
),
),
],
),
),
// Self Control button
Container(
padding: EdgeInsets.symmetric(
horizontal: 16.0.w(),
vertical: 4.0.h(),
),
decoration: BoxDecoration(
color: AppColors.grey20,
borderRadius: BorderRadius.circular(88),
border: Border.all(color: AppColors.grey40),
),
child: Text(
tender.procurementTypeCode!,
style: TextStyle(
color: AppColors.grey60,
fontSize: 12.0.sp(),
fontWeight: FontWeight.w500,
),
),
),
],
),
],
),
),
);
}
}