From aa9c9444fa2f5dbe4c36b3a7bca9841437a817fa Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Sat, 6 Jun 2026 12:25:49 +0330 Subject: [PATCH] Remove unused DetailDropDown and TenderDetailCard components to streamline codebase and improve maintainability. These components were previously disabled and retained for potential future use. --- .../detail/widgets/detail_drop_down.dart | 86 ---------------- .../detail/widgets/tender_detail_card.dart | 98 ------------------- .../tenders/widgets/main_tenders_slider.dart | 20 +++- 3 files changed, 16 insertions(+), 188 deletions(-) delete mode 100644 lib/views/detail/widgets/detail_drop_down.dart delete mode 100644 lib/views/detail/widgets/tender_detail_card.dart diff --git a/lib/views/detail/widgets/detail_drop_down.dart b/lib/views/detail/widgets/detail_drop_down.dart deleted file mode 100644 index b4bd410..0000000 --- a/lib/views/detail/widgets/detail_drop_down.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Currently unused — previously used by the mock sections in TenderDetailHeader, -// which are now disabled. Kept for when those sections are re-enabled. -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:tm_app/core/utils/size_config.dart'; - -import '../../../core/theme/colors.dart'; - -class DetailDropDown extends StatefulWidget { - final String title; - final List items; - const DetailDropDown({required this.title, required this.items, super.key}); - - @override - State createState() => _DetailDropDownState(); -} - -class _DetailDropDownState extends State - with SingleTickerProviderStateMixin { - bool isOpen = true; - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - InkWell( - onTap: () { - setState(() { - isOpen = !isOpen; - }); - }, - child: Container( - width: 24.0.w(), - height: 24.0.h(), - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all(color: AppColors.grey60), - ), - alignment: Alignment.center, - child: Icon( - isOpen - ? CupertinoIcons.chevron_up - : CupertinoIcons.chevron_down, - color: AppColors.grey60, - size: 12, - ), - ), - ), - SizedBox(width: 8.0.w()), - Text( - widget.title, - style: TextStyle( - color: AppColors.grey80, - fontSize: 16.0.sp(), - fontWeight: FontWeight.w600, - ), - ), - ], - ), - SizedBox(height: 12.0.h()), - isOpen - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: - widget.items - .map( - (e) => Padding( - padding: EdgeInsets.only(left: 12.0.w()), - child: Text(e), - ), - ) - .toList(), - ) - : const SizedBox.shrink(), - ], - ); - } -} diff --git a/lib/views/detail/widgets/tender_detail_card.dart b/lib/views/detail/widgets/tender_detail_card.dart deleted file mode 100644 index 55bfb02..0000000 --- a/lib/views/detail/widgets/tender_detail_card.dart +++ /dev/null @@ -1,98 +0,0 @@ -// Currently unused — its usages on the tender-details pages are disabled because -// it renders a static/mock "profile match + incomplete resume" card rather than -// backend data. Kept for when the profile-match score is available from the API. -import 'package:flutter/material.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/tender_data/tender_data.dart'; -import 'package:tm_app/views/detail/strings/tender_details_strings.dart'; - -class TenderDetailCard extends StatelessWidget { - final TenderData detail; - - const TenderDetailCard({required this.detail, super.key}); - - @override - Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: AppColors.paleOrange, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColors.veryPaleOrange), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - TenderDetailsStrings.tenderMatchProfile, - style: TextStyle( - fontSize: 12.0.sp(), - color: AppColors.grey80, - fontWeight: FontWeight.w400, - ), - ), - Text( - '75%', - style: TextStyle( - fontSize: 12.0.sp(), - fontWeight: FontWeight.w600, - color: AppColors.jellyBean, - ), - ), - ], - ), - SizedBox(height: 6.0.h()), - - ClipRRect( - borderRadius: BorderRadius.circular(4), - child: LinearProgressIndicator( - value: 0.75, - backgroundColor: AppColors.grey20, - valueColor: const AlwaysStoppedAnimation( - AppColors.jellyBean, - ), - minHeight: 6.0.h(), - ), - ), - SizedBox(height: 16.0.h()), - - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Icon(Icons.warning_rounded, color: AppColors.red), - SizedBox(width: 8.0.w()), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TenderDetailsStrings.tenderIncompleteResume, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 16.0.sp(), - color: AppColors.grey80, - ), - ), - SizedBox(height: 4.0.h()), - Text( - TenderDetailsStrings.tenderNoExperience, - style: TextStyle( - fontSize: 14.0.sp(), - color: AppColors.grey70, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - ), - ], - ), - ], - ), - ); - } -} diff --git a/lib/views/tenders/widgets/main_tenders_slider.dart b/lib/views/tenders/widgets/main_tenders_slider.dart index 214c7d5..e9e2136 100644 --- a/lib/views/tenders/widgets/main_tenders_slider.dart +++ b/lib/views/tenders/widgets/main_tenders_slider.dart @@ -35,7 +35,12 @@ class _MainTendersSliderState extends State { @override void initState() { super.initState(); - _scrollController.addListener(_onScroll); + // The scroll controller is only attached to the desktop ListView, so only + // register the prefetch listener there. Mobile prefetching is driven by + // PageView's onPageChanged instead. + if (widget.isDesktop) { + _scrollController.addListener(_onScroll); + } } void _onScroll() { @@ -140,6 +145,10 @@ class _MainTendersSliderState extends State { controller: pageController, itemCount: widget.tenders.length, onPageChanged: (index) { + // currentPage is still the previous page here; a forward swipe means + // the new (1-indexed) page is greater than the old one. + final bool isForwardSwipe = index + 1 > currentPage; + setState(() { currentPage = index + 1; }); @@ -150,9 +159,12 @@ class _MainTendersSliderState extends State { viewModel.getTenderFeedback(id); } - // Infinite scroll: once we pass the halfway point of the loaded - // tenders, prefetch the next page in the background. - if (index >= (widget.tenders.length * _prefetchFraction).floor()) { + // Infinite scroll: once we swipe forward past the halfway point of the + // loaded tenders, prefetch the next page in the background. Skip + // back-swipes so we don't refetch while the user reviews earlier + // tenders. + if (isForwardSwipe && + index >= (widget.tenders.length * _prefetchFraction).floor()) { _maybeLoadMore(); } },