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