From ca9c7f7e5daf108619c42e5db6fed150abe11505 Mon Sep 17 00:00:00 2001 From: FaizHashmi Date: Mon, 19 Oct 2026 16:44:58 +0300 Subject: [PATCH] Filters Fix --- lib/classes/consts.dart | 4 +- .../dashboard_screen_for_dependet.dart | 63 ++++++++++++++----- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 6635d82..f07b470 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -4,12 +4,12 @@ class ApiConsts { // static String baseUrl = "http://10.201.214.101:2027"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server + // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server // static String baseUrl = "http://10.201.204.101:2024"; // static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://hmgwebservices.com"; // Live server - // static String baseUrl = "https://mohemm.hmg.com"; // New Live server + static String baseUrl = "https://mohemm.hmg.com"; // New Live server static String ssoBaseUrl = "https://sso.hmg.com"; // New Live server // // static String baseUrl = "https://uat.hmgwebservices.com"; // diff --git a/lib/ui/landing/dashboard_screen_for_dependet.dart b/lib/ui/landing/dashboard_screen_for_dependet.dart index 3c3da7a..edf5647 100644 --- a/lib/ui/landing/dashboard_screen_for_dependet.dart +++ b/lib/ui/landing/dashboard_screen_for_dependet.dart @@ -53,8 +53,8 @@ class _DashboardScreenForDependetState extends State // WP_Radius (null when "any"), _filterMinDiscount drives WP_Min_Discount (null when "any"). // Committed on "Apply filters"/"Reset"; persisted here so reopening the sheet shows the // last-applied selection (availability's source of truth is selectedTypeFilter itself). - String _filterSortBy = 'nearest'; - String _filterDistance = '5km'; + String _filterSortBy = 'newest'; + String _filterDistance = 'any'; String _filterMinDiscount = 'any'; bool isNearestOffers = true; bool isFavoriteOnly = false; @@ -894,10 +894,22 @@ class _DashboardScreenForDependetState extends State // Replaces the old All/In Store/Online chip row: a fixed "Filters" chip (opens the filters // bottom sheet) + a divider, then a horizontally scrollable row of subcategory chips fetched // from the API for whichever main category is currently selected (see fetchSubcategories). + // How many of the 4 filter sections are away from their default value + // (Availability: all, Sort by: newest, Distance: any, Minimum discount: any). + int _activeFilterCount() { + int count = 0; + if (selectedTypeFilter != 'all') count++; + if (_filterSortBy != 'newest') count++; + if (_filterDistance != 'any') count++; + if (_filterMinDiscount != 'any') count++; + return count; + } + Widget _buildFiltersRow(bool isAr) { // "All Categories" (or nothing selected) has no subcategories to show at all - only a // specific main category, once it has actually loaded some, gets the divider + chip row. bool showSubcategoriesRow = currentCategoryId.isNotEmpty && currentCategoryId != "all" && (isSubcategoriesLoading || subcategoriesList.isNotEmpty); + int activeFilterCount = _activeFilterCount(); return Padding( padding: const EdgeInsets.only(top: 14, bottom: 2), @@ -905,22 +917,39 @@ class _DashboardScreenForDependetState extends State height: 38, child: Row( children: [ - InkWell( - borderRadius: BorderRadius.circular(6), - onTap: _showFiltersBottomSheet, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), - alignment: Alignment.center, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(6), color: MyColors.lightGreyEAColor), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - SvgPicture.asset("assets/icons/filter_icon.svg", width: 14, height: 14, colorFilter: const ColorFilter.mode(MyColors.black, BlendMode.srcIn)), - const SizedBox(width: 5), - LocaleKeys.filters.tr().toText12(color: MyColors.black), - ], + Stack( + clipBehavior: Clip.none, + children: [ + InkWell( + borderRadius: BorderRadius.circular(6), + onTap: _showFiltersBottomSheet, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + alignment: Alignment.center, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(6), color: MyColors.lightGreyEAColor), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset("assets/icons/filter_icon.svg", width: 14, height: 14, colorFilter: const ColorFilter.mode(MyColors.black, BlendMode.srcIn)), + const SizedBox(width: 5), + LocaleKeys.filters.tr().toText12(color: MyColors.black), + ], + ), + ), ), - ), + if (activeFilterCount > 0) + PositionedDirectional( + top: -6, + end: -6, + child: Container( + width: 18, + height: 18, + alignment: Alignment.center, + decoration: const BoxDecoration(color: MyColors.darkIconColor, shape: BoxShape.circle), + child: '$activeFilterCount'.toText10(isBold: true, color: Colors.white), + ), + ), + ], ), if (showSubcategoriesRow) ...[ Container(margin: const EdgeInsets.symmetric(horizontal: 10), width: 1, height: 20, color: const Color(0xFFE2E8F0)),