|  |  |  | @ -1,5 +1,6 @@ | 
		
	
		
			
				|  |  |  |  | import 'dart:convert'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import 'package:easy_localization/easy_localization.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:flutter/material.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:flutter_svg/flutter_svg.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_api_client.dart'; | 
		
	
	
		
			
				
					|  |  |  | @ -9,9 +10,9 @@ import 'package:mohem_flutter_app/config/routes.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/extensions/int_extensions.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/extensions/string_extensions.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/models/items_for_sale/get_items_for_sale_list.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/ui/screens/items_for_sale/items_for_sale_home.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class ItemsForSaleFragment extends StatefulWidget { | 
		
	
	
		
			
				
					|  |  |  | @ -35,7 +36,7 @@ class _ItemsForSaleFragmentState extends State<ItemsForSaleFragment> { | 
		
	
		
			
				|  |  |  |  |     gridScrollController.addListener(() { | 
		
	
		
			
				|  |  |  |  |       if (gridScrollController.position.atEdge) { | 
		
	
		
			
				|  |  |  |  |         bool isTop = gridScrollController.position.pixels == 0; | 
		
	
		
			
				|  |  |  |  |         if (!isTop) { | 
		
	
		
			
				|  |  |  |  |         if (!isTop && getItemsForSaleList.length == currentPageNo * 10) { | 
		
	
		
			
				|  |  |  |  |           print('At the bottom'); | 
		
	
		
			
				|  |  |  |  |           currentPageNo++; | 
		
	
		
			
				|  |  |  |  |           getItemsForSale(currentPageNo, currentCategoryID); | 
		
	
	
		
			
				
					|  |  |  | @ -47,103 +48,100 @@ class _ItemsForSaleFragmentState extends State<ItemsForSaleFragment> { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   Widget build(BuildContext context) { | 
		
	
		
			
				|  |  |  |  |     return SingleChildScrollView( | 
		
	
		
			
				|  |  |  |  |     return ListView( | 
		
	
		
			
				|  |  |  |  |       controller: gridScrollController, | 
		
	
		
			
				|  |  |  |  |       child: Column( | 
		
	
		
			
				|  |  |  |  |         crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |         mainAxisSize: MainAxisSize.min, | 
		
	
		
			
				|  |  |  |  |         children: [ | 
		
	
		
			
				|  |  |  |  |           DynamicTextFieldWidget( | 
		
	
		
			
				|  |  |  |  |             "Search", | 
		
	
		
			
				|  |  |  |  |             "Search Items", | 
		
	
		
			
				|  |  |  |  |             isEnable: true, | 
		
	
		
			
				|  |  |  |  |             suffixIconData: Icons.search, | 
		
	
		
			
				|  |  |  |  |             isPopup: false, | 
		
	
		
			
				|  |  |  |  |             lines: 1, | 
		
	
		
			
				|  |  |  |  |             isInputTypeNum: false, | 
		
	
		
			
				|  |  |  |  |             isReadOnly: false, | 
		
	
		
			
				|  |  |  |  |             onChange: (String value) { | 
		
	
		
			
				|  |  |  |  |               // _runFilter(value); | 
		
	
		
			
				|  |  |  |  |             }, | 
		
	
		
			
				|  |  |  |  |           ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), | 
		
	
		
			
				|  |  |  |  |           Row( | 
		
	
		
			
				|  |  |  |  |             mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
		
	
		
			
				|  |  |  |  |             children: [ | 
		
	
		
			
				|  |  |  |  |               "Browse Categories".toText17(), | 
		
	
		
			
				|  |  |  |  |               IconButton( | 
		
	
		
			
				|  |  |  |  |                 icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), | 
		
	
		
			
				|  |  |  |  |                 onPressed: () => Navigator.pop(context), | 
		
	
		
			
				|  |  |  |  |               ), | 
		
	
		
			
				|  |  |  |  |             ], | 
		
	
		
			
				|  |  |  |  |           ).paddingOnly(left: 21, right: 21), | 
		
	
		
			
				|  |  |  |  |           SizedBox( | 
		
	
		
			
				|  |  |  |  |             height: 105.0, | 
		
	
		
			
				|  |  |  |  |             child: getSaleCategoriesList.isNotEmpty | 
		
	
		
			
				|  |  |  |  |                 ? ListView.separated( | 
		
	
		
			
				|  |  |  |  |                     shrinkWrap: true, | 
		
	
		
			
				|  |  |  |  |                     physics: const BouncingScrollPhysics(), | 
		
	
		
			
				|  |  |  |  |                     padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), | 
		
	
		
			
				|  |  |  |  |                     scrollDirection: Axis.horizontal, | 
		
	
		
			
				|  |  |  |  |                     itemBuilder: (cxt, index) { | 
		
	
		
			
				|  |  |  |  |                       return AspectRatio( | 
		
	
		
			
				|  |  |  |  |                         aspectRatio: 1 / 1, | 
		
	
		
			
				|  |  |  |  |                         child: InkWell( | 
		
	
		
			
				|  |  |  |  |                           onTap: () { | 
		
	
		
			
				|  |  |  |  |                             setState(() { | 
		
	
		
			
				|  |  |  |  |                               currentCategoryID = getSaleCategoriesList[index].categoryID!; | 
		
	
		
			
				|  |  |  |  |                               getItemsForSaleList.clear(); | 
		
	
		
			
				|  |  |  |  |                               currentPageNo = 1; | 
		
	
		
			
				|  |  |  |  |                               getItemsForSale(currentPageNo, currentCategoryID); | 
		
	
		
			
				|  |  |  |  |                             }); | 
		
	
		
			
				|  |  |  |  |                           }, | 
		
	
		
			
				|  |  |  |  |                           child: Container( | 
		
	
		
			
				|  |  |  |  |                             decoration: BoxDecoration( | 
		
	
		
			
				|  |  |  |  |                               color: Colors.white, | 
		
	
		
			
				|  |  |  |  |                               borderRadius: BorderRadius.circular(15), | 
		
	
		
			
				|  |  |  |  |                               boxShadow: [ | 
		
	
		
			
				|  |  |  |  |                                 BoxShadow( | 
		
	
		
			
				|  |  |  |  |                                   color: const Color(0xff000000).withOpacity(.05), | 
		
	
		
			
				|  |  |  |  |                                   blurRadius: 26, | 
		
	
		
			
				|  |  |  |  |                                   offset: const Offset(0, -3), | 
		
	
		
			
				|  |  |  |  |                                 ), | 
		
	
		
			
				|  |  |  |  |                               ], | 
		
	
		
			
				|  |  |  |  |                             ), | 
		
	
		
			
				|  |  |  |  |                             child: Column( | 
		
	
		
			
				|  |  |  |  |                               mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
		
	
		
			
				|  |  |  |  |                               crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                               children: [ | 
		
	
		
			
				|  |  |  |  |                                 Row( | 
		
	
		
			
				|  |  |  |  |                                   mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
		
	
		
			
				|  |  |  |  |                                   crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                                   children: [ | 
		
	
		
			
				|  |  |  |  |                                     SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), | 
		
	
		
			
				|  |  |  |  |                                     currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), | 
		
	
		
			
				|  |  |  |  |                                   ], | 
		
	
		
			
				|  |  |  |  |                                 ).expanded, | 
		
	
		
			
				|  |  |  |  |                                 getSaleCategoriesList[index].title!.toText10() | 
		
	
		
			
				|  |  |  |  |                               ], | 
		
	
		
			
				|  |  |  |  |                             ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), | 
		
	
		
			
				|  |  |  |  |       children: [ | 
		
	
		
			
				|  |  |  |  |         DynamicTextFieldWidget( | 
		
	
		
			
				|  |  |  |  |           LocaleKeys.search.tr(), | 
		
	
		
			
				|  |  |  |  |           LocaleKeys.searchItems.tr(), | 
		
	
		
			
				|  |  |  |  |           isEnable: true, | 
		
	
		
			
				|  |  |  |  |           suffixIconData: Icons.search, | 
		
	
		
			
				|  |  |  |  |           isPopup: false, | 
		
	
		
			
				|  |  |  |  |           lines: 1, | 
		
	
		
			
				|  |  |  |  |           isInputTypeNum: false, | 
		
	
		
			
				|  |  |  |  |           isReadOnly: false, | 
		
	
		
			
				|  |  |  |  |           onChange: (String value) { | 
		
	
		
			
				|  |  |  |  |             // _runFilter(value); | 
		
	
		
			
				|  |  |  |  |           }, | 
		
	
		
			
				|  |  |  |  |         ).paddingOnly(left: 21, right: 21, top: 21), | 
		
	
		
			
				|  |  |  |  |         Row( | 
		
	
		
			
				|  |  |  |  |           mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
		
	
		
			
				|  |  |  |  |           children: [ | 
		
	
		
			
				|  |  |  |  |             LocaleKeys.browseCategories.tr().toText17(), | 
		
	
		
			
				|  |  |  |  |             // todo @haroon define the purpose of this icon button | 
		
	
		
			
				|  |  |  |  |             IconButton( | 
		
	
		
			
				|  |  |  |  |               icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), | 
		
	
		
			
				|  |  |  |  |               onPressed: () => Navigator.pop(context), | 
		
	
		
			
				|  |  |  |  |             ), | 
		
	
		
			
				|  |  |  |  |           ], | 
		
	
		
			
				|  |  |  |  |         ).paddingOnly(left: 21, right: 21), | 
		
	
		
			
				|  |  |  |  |         SizedBox( | 
		
	
		
			
				|  |  |  |  |           height: 105.0, | 
		
	
		
			
				|  |  |  |  |           child: getSaleCategoriesList.isNotEmpty | 
		
	
		
			
				|  |  |  |  |               ? ListView.separated( | 
		
	
		
			
				|  |  |  |  |                   shrinkWrap: true, | 
		
	
		
			
				|  |  |  |  |                   physics: const BouncingScrollPhysics(), | 
		
	
		
			
				|  |  |  |  |                   padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), | 
		
	
		
			
				|  |  |  |  |                   scrollDirection: Axis.horizontal, | 
		
	
		
			
				|  |  |  |  |                   itemBuilder: (cxt, index) { | 
		
	
		
			
				|  |  |  |  |                     return AspectRatio( | 
		
	
		
			
				|  |  |  |  |                       aspectRatio: 1 / 1, | 
		
	
		
			
				|  |  |  |  |                       child: InkWell( | 
		
	
		
			
				|  |  |  |  |                         onTap: () { | 
		
	
		
			
				|  |  |  |  |                           setState(() { | 
		
	
		
			
				|  |  |  |  |                             currentCategoryID = getSaleCategoriesList[index].categoryID!; | 
		
	
		
			
				|  |  |  |  |                             getItemsForSaleList.clear(); | 
		
	
		
			
				|  |  |  |  |                             currentPageNo = 1; | 
		
	
		
			
				|  |  |  |  |                             getItemsForSale(currentPageNo, currentCategoryID); | 
		
	
		
			
				|  |  |  |  |                           }); | 
		
	
		
			
				|  |  |  |  |                         }, | 
		
	
		
			
				|  |  |  |  |                         child: Container( | 
		
	
		
			
				|  |  |  |  |                           decoration: BoxDecoration( | 
		
	
		
			
				|  |  |  |  |                             color: Colors.white, | 
		
	
		
			
				|  |  |  |  |                             borderRadius: BorderRadius.circular(15), | 
		
	
		
			
				|  |  |  |  |                             boxShadow: [ | 
		
	
		
			
				|  |  |  |  |                               BoxShadow( | 
		
	
		
			
				|  |  |  |  |                                 color: const Color(0xff000000).withOpacity(.05), | 
		
	
		
			
				|  |  |  |  |                                 blurRadius: 26, | 
		
	
		
			
				|  |  |  |  |                                 offset: const Offset(0, -3), | 
		
	
		
			
				|  |  |  |  |                               ), | 
		
	
		
			
				|  |  |  |  |                             ], | 
		
	
		
			
				|  |  |  |  |                           ), | 
		
	
		
			
				|  |  |  |  |                           child: Column( | 
		
	
		
			
				|  |  |  |  |                             mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
		
	
		
			
				|  |  |  |  |                             crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                             children: [ | 
		
	
		
			
				|  |  |  |  |                               Row( | 
		
	
		
			
				|  |  |  |  |                                 mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
		
	
		
			
				|  |  |  |  |                                 crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                                 children: [ | 
		
	
		
			
				|  |  |  |  |                                   SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), | 
		
	
		
			
				|  |  |  |  |                                   currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), | 
		
	
		
			
				|  |  |  |  |                                 ], | 
		
	
		
			
				|  |  |  |  |                               ).expanded, | 
		
	
		
			
				|  |  |  |  |                               getSaleCategoriesList[index].title!.toText10() | 
		
	
		
			
				|  |  |  |  |                             ], | 
		
	
		
			
				|  |  |  |  |                           ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), | 
		
	
		
			
				|  |  |  |  |                         ), | 
		
	
		
			
				|  |  |  |  |                       ); | 
		
	
		
			
				|  |  |  |  |                     }, | 
		
	
		
			
				|  |  |  |  |                     separatorBuilder: (cxt, index) => 12.width, | 
		
	
		
			
				|  |  |  |  |                     itemCount: getSaleCategoriesList.length) | 
		
	
		
			
				|  |  |  |  |                 : Container(), | 
		
	
		
			
				|  |  |  |  |           ), | 
		
	
		
			
				|  |  |  |  |           getItemsForSaleList.isNotEmpty | 
		
	
		
			
				|  |  |  |  |               ? GridView( | 
		
	
		
			
				|  |  |  |  |                   gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), | 
		
	
		
			
				|  |  |  |  |                   padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), | 
		
	
		
			
				|  |  |  |  |                   shrinkWrap: true, | 
		
	
		
			
				|  |  |  |  |                   primary: false, | 
		
	
		
			
				|  |  |  |  |                   physics: const ScrollPhysics(), | 
		
	
		
			
				|  |  |  |  |                   children: getItemsForSaleWidgets(), | 
		
	
		
			
				|  |  |  |  |                 ) | 
		
	
		
			
				|  |  |  |  |               : Utils.getNoDataWidget(context).paddingOnly(top: 50), | 
		
	
		
			
				|  |  |  |  |           // 32.height, | 
		
	
		
			
				|  |  |  |  |         ], | 
		
	
		
			
				|  |  |  |  |       ), | 
		
	
		
			
				|  |  |  |  |                       ), | 
		
	
		
			
				|  |  |  |  |                     ); | 
		
	
		
			
				|  |  |  |  |                   }, | 
		
	
		
			
				|  |  |  |  |                   separatorBuilder: (cxt, index) => 12.width, | 
		
	
		
			
				|  |  |  |  |                   itemCount: getSaleCategoriesList.length) | 
		
	
		
			
				|  |  |  |  |               : Container(), | 
		
	
		
			
				|  |  |  |  |         ), | 
		
	
		
			
				|  |  |  |  |         getItemsForSaleList.isNotEmpty | 
		
	
		
			
				|  |  |  |  |             ? GridView( | 
		
	
		
			
				|  |  |  |  |                 gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), | 
		
	
		
			
				|  |  |  |  |                 padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), | 
		
	
		
			
				|  |  |  |  |                 shrinkWrap: true, | 
		
	
		
			
				|  |  |  |  |                 primary: false, | 
		
	
		
			
				|  |  |  |  |                 physics: const ScrollPhysics(), | 
		
	
		
			
				|  |  |  |  |                 children: getItemsForSaleWidgets(), | 
		
	
		
			
				|  |  |  |  |               ) | 
		
	
		
			
				|  |  |  |  |             : Utils.getNoDataWidget(context).paddingOnly(top: 50), | 
		
	
		
			
				|  |  |  |  |         // 32.height, | 
		
	
		
			
				|  |  |  |  |       ], | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | 
 |