merge branches

This commit is contained in:
amirrezaghabeli
2025-08-20 13:11:22 +03:30
parent 1af9c0a76b
commit 4b51071aad
36 changed files with 1894 additions and 167 deletions
@@ -40,12 +40,15 @@ class _MainTendersSliderState extends State<MainTendersSlider> {
currentPage = currentPage - 1;
});
// Fetch feedback for the previous tender if not already loaded
// Fetch feedback and approvals for the previous tender if not already loaded
final viewModel = context.read<TendersViewModel>();
final previousTenderId = widget.tenders[currentPage - 2].id!;
if (!viewModel.hasFeedbackForTender(previousTenderId)) {
viewModel.getTenderFeedback(previousTenderId);
}
if (!viewModel.hasTenderApprovalForTender(previousTenderId)) {
viewModel.getTenderApprovals(previousTenderId);
}
}
void _goToNextPage() {
@@ -61,12 +64,15 @@ class _MainTendersSliderState extends State<MainTendersSlider> {
currentPage = currentPage + 1;
});
// Fetch feedback for the next tender if not already loaded
// Fetch feedback and approvals for the next tender if not already loaded
final viewModel = context.read<TendersViewModel>();
final nextTenderId = widget.tenders[currentPage].id!;
if (!viewModel.hasFeedbackForTender(nextTenderId)) {
viewModel.getTenderFeedback(nextTenderId);
}
if (!viewModel.hasTenderApprovalForTender(nextTenderId)) {
viewModel.getTenderApprovals(nextTenderId);
}
}
@override
@@ -95,11 +101,16 @@ class _MainTendersSliderState extends State<MainTendersSlider> {
currentPage = index + 1;
});
// Fetch feedback for the new tender if not already loaded
// Fetch feedback and approvals for the new tender if not already loaded
final viewModel = context.read<TendersViewModel>();
if (!viewModel.hasFeedbackForTender(widget.tenders[index].id!)) {
viewModel.getTenderFeedback(widget.tenders[index].id!);
}
if (!viewModel.hasTenderApprovalForTender(
widget.tenders[index].id!,
)) {
viewModel.getTenderApprovals(widget.tenders[index].id!);
}
// Check if we need to load more tenders (when user reaches near the end)
if (index >= widget.tenders.length - 1 &&
@@ -154,28 +165,26 @@ class _MainTendersSliderState extends State<MainTendersSlider> {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
viewModel.isLoadingMore ?
Padding(
padding: EdgeInsets.only(top: 4.0.h()),
child: SizedBox(
width: 16.0.w(),
height: 16.0.w(),
child: CircularProgressIndicator(
strokeWidth: 2.0,
color: AppColors.jellyBean,
viewModel.isLoadingMore
? Padding(
padding: EdgeInsets.only(top: 4.0.h()),
child: SizedBox(
width: 16.0.w(),
height: 16.0.w(),
child: CircularProgressIndicator(
strokeWidth: 2.0,
color: AppColors.jellyBean,
),
),
)
: Text(
'$currentPage/${widget.tenders.length}',
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey,
),
),
):
Text(
'$currentPage/${widget.tenders.length}',
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey,
),
),
],
);
}
@@ -8,6 +8,7 @@ import 'package:tm_app/view_models/tenders_view_model.dart';
import '../../../core/constants/assets.dart';
import '../../../core/theme/colors.dart';
import '../../../core/utils/size_config.dart';
import '../../shared/select_submission_bottom_sheet.dart';
class TenderActionButtonsRow extends StatelessWidget {
final TenderData tender;
@@ -35,7 +36,7 @@ class TenderActionButtonsRow extends StatelessWidget {
_rejectButton(viewModel),
SizedBox(width: 32.0.w()),
//submit button
_submitButton(viewModel),
_submitButton(viewModel, context),
SizedBox(width: 32.0.w()),
// Like button
_likeButton(viewModel),
@@ -46,12 +47,22 @@ class TenderActionButtonsRow extends StatelessWidget {
}
Widget _rejectButton(TendersViewModel viewModel) {
// Find approval for this specific tender
if (tender.id == null) return const SizedBox.shrink();
final approval = viewModel.getTenderApprovalForTender(tender.id!);
final isRejected = approval?.status == 'rejected';
return Tooltip(
message: AppStrings.reject,
child: InkWell(
splashColor: Colors.transparent,
onTap: () {
// viewModel.toggleReject(tender);
viewModel.toggleApprovals(
tenderId: tender.id!,
submissionMode: 'self-apply',
status: 'rejected',
);
},
child: Column(
children: [
@@ -61,22 +72,14 @@ class TenderActionButtonsRow extends StatelessWidget {
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color:
// tender.rejected ?? false
// ? AppColors.errorColor
// :
AppColors.grey60,
color: isRejected ? AppColors.errorColor : AppColors.grey60,
width: 1.5.w(),
),
),
alignment: Alignment.center,
child: Icon(
Icons.close,
color:
// tender.rejected ?? false
// ? AppColors.errorColor
// :
AppColors.grey60,
color: isRejected ? AppColors.errorColor : AppColors.grey60,
size: 16,
),
),
@@ -87,11 +90,7 @@ class TenderActionButtonsRow extends StatelessWidget {
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
color:
// tender.rejected ?? false
// ? AppColors.errorColor
// :
AppColors.grey60,
color: isRejected ? AppColors.errorColor : AppColors.grey60,
),
),
],
@@ -100,13 +99,41 @@ class TenderActionButtonsRow extends StatelessWidget {
);
}
Widget _submitButton(TendersViewModel viewModel) {
Widget _submitButton(TendersViewModel viewModel, BuildContext context) {
// Find approval for this specific tender
if (tender.id == null) return const SizedBox.shrink();
final approval = viewModel.getTenderApprovalForTender(tender.id!);
final isApproved = approval?.status == 'approved';
return Tooltip(
message: AppStrings.submit,
child: InkWell(
splashColor: Colors.transparent,
onTap: () {
// viewModel.toggleSubmit(tender);
if (isApproved) {
viewModel.toggleApprovals(
tenderId: tender.id!,
submissionMode: approval?.submissionMode ?? 'self-apply',
status: 'approved',
);
} else {
showModalBottomSheet(
isDismissible: true,
context: context,
builder: (context) {
return SelectSubmissionBottomSheet(
onConfirm: (value) {
viewModel.toggleApprovals(
tenderId: tender.id!,
submissionMode: value,
status: 'approved',
);
},
);
},
);
}
},
child: Column(
children: [
@@ -116,24 +143,15 @@ class TenderActionButtonsRow extends StatelessWidget {
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color:
// tender.submitted ?? false
// ? AppColors.successColor
// :
AppColors.grey60,
color: isApproved ? AppColors.successColor : AppColors.grey60,
width: 1.5.w(),
),
),
alignment: Alignment.center,
child: SvgPicture.asset(
AssetsManager.tick,
colorFilter: ColorFilter.mode(
// tender.submitted ?? false
// ? AppColors.successColor
// :
AppColors.grey60,
BlendMode.srcATop,
),
child: Icon(
Icons.check,
color: isApproved ? AppColors.successColor : AppColors.grey60,
size: 16,
),
),
SizedBox(height: 8.0.h()),
@@ -143,11 +161,7 @@ class TenderActionButtonsRow extends StatelessWidget {
style: TextStyle(
fontSize: 12.0.sp(),
fontWeight: FontWeight.w400,
color:
// tender.submitted ?? false
// ? AppColors.successColor
// :
AppColors.grey60,
color: isApproved ? AppColors.successColor : AppColors.grey60,
),
),
],
@@ -158,6 +172,8 @@ class TenderActionButtonsRow extends StatelessWidget {
Widget _dislikeButton(TendersViewModel viewModel) {
// Find feedback for this specific tender
if (tender.id == null) return const SizedBox.shrink();
final feedback = viewModel.getFeedbackForTender(tender.id!);
final isDisliked = feedback?.feedbackType == 'dislike';
@@ -198,6 +214,8 @@ class TenderActionButtonsRow extends StatelessWidget {
Widget _likeButton(TendersViewModel viewModel) {
// Find feedback for this specific tender
if (tender.id == null) return const SizedBox.shrink();
final feedback = viewModel.getFeedbackForTender(tender.id!);
final isLiked = feedback?.feedbackType == 'like';
+68 -8
View File
@@ -55,6 +55,10 @@ class TenderCard extends StatelessWidget {
_deadlineBadge(),
SizedBox(height: 12.0.h()),
// Approval status badge
// _approvalStatusBadge(),
SizedBox(height: 12.0.h()),
// Title
_tenderTitle(),
SizedBox(height: 8.0.h()),
@@ -148,6 +152,59 @@ class TenderCard extends StatelessWidget {
);
}
// 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 ?? '',
@@ -244,14 +301,15 @@ class TenderCard extends StatelessWidget {
),
SizedBox(width: 8.0.w()),
// Country flag placeholder
SizedBox(
width: 32.0.w(),
height: 21.0.h(),
child: CountryFlag.fromCountryCode(
tender.countryCode!,
shape: RoundedRectangle(4),
if (tender.countryCode != null)
SizedBox(
width: 32.0.w(),
height: 21.0.h(),
child: CountryFlag.fromCountryCode(
tender.countryCode!,
shape: RoundedRectangle(4),
),
),
),
],
),
);
@@ -260,7 +318,9 @@ class TenderCard extends StatelessWidget {
Widget _seeMoreButton(BuildContext context) {
return InkWell(
onTap: () {
TenderDetailRouteData(tenderId: tender.id!).push(context);
if (tender.id != null) {
TenderDetailRouteData(tenderId: tender.id!).push(context);
}
},
child: Container(
width: 108.0.w(),