feat: add AI recommendations flow for tenders
Implement company AI onboarding/recommendation models, services, repository, and tender UI integration with supporting tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
import 'package:flutter/material.dart';
|
||||
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/recommendation_item/recommendation_item.dart';
|
||||
|
||||
import '../strings/tenders_strings.dart';
|
||||
|
||||
/// A single AI recommendation: rank badge + the AI's analysis, tappable to open
|
||||
/// the tender detail via [RecommendationItem.tenderId].
|
||||
class RecommendationCard extends StatelessWidget {
|
||||
const RecommendationCard({required this.item, super.key});
|
||||
|
||||
final RecommendationItem item;
|
||||
|
||||
void _openDetail(BuildContext context) {
|
||||
final tenderId = item.tenderId;
|
||||
if (tenderId == null || tenderId.isEmpty) {
|
||||
return;
|
||||
}
|
||||
TenderDetailRouteData(tenderId: tenderId).push(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final analysis = item.analysis?.trim() ?? '';
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(12.0.w()),
|
||||
onTap: () => _openDetail(context),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(16.0.h()),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.grey0,
|
||||
borderRadius: BorderRadius.circular(12.0.w()),
|
||||
border: Border.all(color: AppColors.grey30),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
_rankBadge(),
|
||||
SizedBox(width: 12.0.w()),
|
||||
Text(
|
||||
TendersStrings.recommendedMatchLabel,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (analysis.isNotEmpty) ...[
|
||||
SizedBox(height: 12.0.h()),
|
||||
Text(
|
||||
analysis,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey80,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 16.0.h()),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: Text(
|
||||
TendersStrings.tenderSeeMore,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _rankBadge() {
|
||||
final rank = item.rank?.trim();
|
||||
final label =
|
||||
(rank == null || rank.isEmpty)
|
||||
? TendersStrings.recommendedRankPrefix
|
||||
: '${TendersStrings.recommendedRankPrefix}$rank';
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12.0.w(), vertical: 4.0.h()),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary10,
|
||||
borderRadius: BorderRadius.circular(8.0.w()),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user