sub categories pagnation

merge-update-with-lab-changes
hussam al-habibeh 4 years ago
parent e917da9183
commit ff86dcbdc0

@ -187,11 +187,14 @@ class PharmacyCategoriseService extends BaseService {
); );
} }
Future getSubProducts({String id}) async { Future getSubProducts(
{String id, int pageIndex, bool isLoading = false}) async {
hasError = false; hasError = false;
if (isLoading == false) {
_subProductsList.clear(); _subProductsList.clear();
}
String endPoint = id != null String endPoint = id != null
? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' ? GET_SUB_PRODUCTS + "$id" + '&page=' + '$pageIndex' + '&limit=24'
: GET_SUB_PRODUCTS + ""; : GET_SUB_PRODUCTS + "";
await baseAppClient.getPharmacy( await baseAppClient.getPharmacy(
endPoint, endPoint,

@ -121,7 +121,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
hasError = false; hasError = false;
// _insuranceCardService.clearInsuranceCard(); // _insuranceCardService.clearInsuranceCard();
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
//GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await _pharmacyCategoriseService.getParentProducts( await _pharmacyCategoriseService.getParentProducts(
id: i, pageNumber: pageIndex, isLoading: isLoading); id: i, pageNumber: pageIndex, isLoading: isLoading);
if (_pharmacyCategoriseService.hasError) { if (_pharmacyCategoriseService.hasError) {
@ -129,31 +129,45 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
//GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
Future getSubCategorise({String i}) async { Future getSubCategorise(
{String i,
int pageIndex,
bool isLoading = false,
BuildContext context}) async {
hasError = false; hasError = false;
// _insuranceCardService.clearInsuranceCard(); // _insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy); setState(ViewState.Busy);
await _pharmacyCategoriseService.getSubCategorise(id: i); await _pharmacyCategoriseService.getSubCategorise(
id: i,
);
if (_pharmacyCategoriseService.hasError) { if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error; error = _pharmacyCategoriseService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else
getSubProducts(i: i); getSubProducts(
i: i, pageIndex: pageIndex, isLoading: isLoading, context: context);
} }
Future getSubProducts({String i}) async { Future getSubProducts(
{String i,
int pageIndex,
bool isLoading = false,
BuildContext context}) async {
hasError = false; hasError = false;
// _insuranceCardService.clearInsuranceCard(); // _insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy); setState(ViewState.BusyLocal);
await _pharmacyCategoriseService.getSubProducts(id: i); GifLoaderDialogUtils.showMyDialog(context);
await _pharmacyCategoriseService.getSubProducts(
id: i, pageIndex: pageIndex, isLoading: isLoading);
if (_pharmacyCategoriseService.hasError) { if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error; error = _pharmacyCategoriseService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
GifLoaderDialogUtils.hideDialog(context);
} }
Future getFinalProducts({String i}) async { Future getFinalProducts({String i}) async {

@ -689,10 +689,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
model.parentProducts.isNotEmpty model.parentProducts.isNotEmpty
? styleOne == true ? styleOne == true
? model.state != ViewState.BusyLocal
? Container( ? Container(
height: height: model.parentProducts.length *
model.parentProducts.length *
MediaQuery.of(context) MediaQuery.of(context)
.size .size
.height * .height *
@ -709,8 +707,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
itemCount: itemCount:
model.parentProducts.length, model.parentProducts.length,
itemBuilder: itemBuilder: (BuildContext context,
(BuildContext context,
int index) { int index) {
return NetworkBaseView( return NetworkBaseView(
baseViewModel: model, baseViewModel: model,
@ -721,34 +718,33 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index] index]
.discountName != .discountName !=
null null
? Color( ? Color(0xffFFFF00)
0xffFFFF00)
: Colors.white, : Colors.white,
elevation: 0, elevation: 0,
shape: Border( shape: Border(
right: BorderSide( right: BorderSide(
color: Colors.grey color: Colors
.shade300, .grey.shade300,
width: 1, width: 1,
), ),
left: BorderSide( left: BorderSide(
color: Colors.grey color: Colors
.shade300, .grey.shade300,
width: 1, width: 1,
), ),
bottom: BorderSide( bottom: BorderSide(
color: Colors.grey color: Colors
.shade300, .grey.shade300,
width: 1, width: 1,
), ),
top: BorderSide( top: BorderSide(
color: Colors.grey color: Colors
.shade300, .grey.shade300,
width: 1, width: 1,
), ),
), ),
margin: EdgeInsets margin:
.symmetric( EdgeInsets.symmetric(
horizontal: 8, horizontal: 8,
vertical: 4, vertical: 4,
), ),
@ -756,19 +752,16 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
decoration: decoration:
BoxDecoration( BoxDecoration(
borderRadius: borderRadius:
BorderRadius BorderRadius.only(
.only( topLeft:
topLeft: Radius Radius.circular(
.circular(
110.0), 110.0),
), ),
color: color: Colors.white,
Colors.white,
), ),
padding: EdgeInsets padding: EdgeInsets
.symmetric( .symmetric(
horizontal: horizontal: 0),
0),
width: MediaQuery.of( width: MediaQuery.of(
context) context)
.size .size
@ -782,7 +775,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Stack( Stack(
children: [ children: [
if (model if (model
.parentProducts[index] .parentProducts[
index]
.discountName != .discountName !=
null) null)
RotatedBox( RotatedBox(
@ -796,20 +790,29 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Padding( Padding(
padding: padding:
EdgeInsets.only( EdgeInsets.only(
right: 5.0, right:
top: 20.0, 5.0,
bottom: 5.0, top:
20.0,
bottom:
5.0,
), ),
child: child:
Texts( Texts(
TranslationBase.of(context).offers.toUpperCase(), TranslationBase.of(context)
color: Colors.red, .offers
fontSize: 13.0, .toUpperCase(),
fontWeight: FontWeight.w900, color:
Colors.red,
fontSize:
13.0,
fontWeight:
FontWeight.w900,
), ),
), ),
transform: transform:
new Matrix4.rotationZ(5.837200), new Matrix4.rotationZ(
5.837200),
), ),
), ),
Container( Container(
@ -824,13 +827,19 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.center, .center,
child: Image child: Image
.network( .network(
model.parentProducts[index].images.isNotEmpty model
? model.parentProducts[index].images[0].thumb .parentProducts[
index]
.images
.isNotEmpty
? model
.parentProducts[index]
.images[0]
.thumb
: 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png',
fit: BoxFit fit: BoxFit
.cover, .cover,
height: height: 80,
80,
), ),
), ),
// Container( // Container(
@ -887,8 +896,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container( Container(
margin: EdgeInsets margin: EdgeInsets
.symmetric( .symmetric(
horizontal: horizontal: 6,
6,
vertical: 0, vertical: 0,
), ),
child: Column( child: Column(
@ -897,45 +905,58 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.start, .start,
children: [ children: [
if (model if (model
.parentProducts[index] .parentProducts[
index]
.discountName != .discountName !=
null) null)
Container( Container(
width: width: double
double.infinity, .infinity,
height: height:
13.0, 13.0,
decoration: decoration:
BoxDecoration( BoxDecoration(
color: color: Color(
Color(0xff5AB145), 0xff5AB145),
), ),
child: child:
Center( Center(
child: child:
Texts( Texts(
model.parentProducts[index].discountName, model
regular: true, .parentProducts[index]
color: Colors.white, .discountName,
fontSize: 10.4, regular:
true,
color:
Colors.white,
fontSize:
10.4,
), ),
), ),
), ),
Texts( Texts(
projectViewModel.isArabic projectViewModel
? model.parentProducts[index].namen .isArabic
: model.parentProducts[index].name, ? model
.parentProducts[
index]
.namen
: model
.parentProducts[index]
.name,
regular: regular:
true, true,
fontSize: fontSize:
12, 12,
fontWeight: fontWeight:
FontWeight.w700, FontWeight
.w700,
), ),
Padding( Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets
top: .only(
4, top: 4,
bottom: bottom:
4), 4),
child: child:
@ -956,8 +977,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
// forceStars: true), // forceStars: true),
RatingBar RatingBar
.readOnly( .readOnly(
initialRating: initialRating: model
model.parentProducts[index].approvedRatingSum.toDouble(), .parentProducts[index]
.approvedRatingSum
.toDouble(),
size: size:
15.0, 15.0,
filledColor: filledColor:
@ -1005,8 +1028,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
) )
: Container( : Container(
height: height: model.parentProducts.length *
model.parentProducts.length *
MediaQuery.of(context) MediaQuery.of(context)
.size .size
.height * .height *
@ -1014,8 +1036,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: ListView.builder( child: ListView.builder(
physics: physics:
NeverScrollableScrollPhysics(), NeverScrollableScrollPhysics(),
itemCount: model itemCount:
.parentProducts.length, model.parentProducts.length,
itemBuilder: itemBuilder:
(BuildContext context, (BuildContext context,
int index) { int index) {
@ -1033,11 +1055,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: child:
Padding( Padding(
padding: padding:
EdgeInsets.only( EdgeInsets
left: .only(
9.0, left: 9.0,
top: top: 8.0,
8.0,
right: right:
10.0, 10.0,
), ),
@ -1060,12 +1081,18 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.isNotEmpty .isNotEmpty
? Image ? Image
.network( .network(
model.parentProducts[index].images[0].thumb, model
fit: BoxFit.contain, .parentProducts[index]
height: 70, .images[0]
.thumb,
fit: BoxFit
.contain,
height:
70,
) )
: Text( : Text(TranslationBase.of(
TranslationBase.of(context).noImage), context)
.noImage),
), ),
], ],
), ),
@ -1074,30 +1101,41 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container( Container(
width: model.parentProducts[index].rxMessage != width: model.parentProducts[index].rxMessage !=
null null
? MediaQuery.of(context).size.width / ? MediaQuery.of(context)
.size
.width /
5.3 5.3
: 0, : 0,
padding: padding:
EdgeInsets.all( EdgeInsets
.all(
4), 4),
decoration: decoration:
BoxDecoration( BoxDecoration(
color: Color( color: Color(
0xffb23838), 0xffb23838),
borderRadius: borderRadius:
BorderRadius.only(topLeft: Radius.circular(6)), BorderRadius.only(
topLeft:
Radius.circular(6)),
), ),
child: model.parentProducts[index].rxMessage != child: model.parentProducts[index]
.rxMessage !=
null null
? Texts( ? Texts(
projectProvider.isArabic ? model.parentProducts[index].rxMessagen : model.parentProducts[index].rxMessage, projectProvider.isArabic
color: Colors.white, ? model.parentProducts[index].rxMessagen
regular: true, : model.parentProducts[index].rxMessage,
fontSize: 10, color:
fontWeight: FontWeight.w400, Colors.white,
regular:
true,
fontSize:
10,
fontWeight:
FontWeight.w400,
) )
: Texts( : Texts(""),
""),
// Texts( // Texts(
// model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", // model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "",
// color: Colors.white, // color: Colors.white,
@ -1128,12 +1166,12 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
height: 4.0, height: 4.0,
), ),
Container( Container(
width: MediaQuery.of(context) width: MediaQuery.of(
context)
.size .size
.width * .width *
0.635, 0.635,
child: child: Texts(
Texts(
projectViewModel projectViewModel
.isArabic .isArabic
? model ? model
@ -1141,35 +1179,32 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index] index]
.namen .namen
: model : model
.parentProducts[index] .parentProducts[
index]
.name, .name,
regular: regular: true,
true,
fontSize: fontSize:
13.2, 13.2,
fontWeight: fontWeight:
FontWeight FontWeight
.w500, .w500,
maxLines: maxLines: 5,
5,
), ),
), ),
SizedBox( SizedBox(
height: 8.0, height: 8.0,
), ),
Padding( Padding(
padding: const EdgeInsets padding:
const EdgeInsets
.only( .only(
top: 4, top: 4,
bottom: bottom:
4), 4),
child: child: Texts(
Texts(
"SAR ${model.parentProducts[index].price}", "SAR ${model.parentProducts[index].price}",
bold: bold: true,
true, fontSize: 14,
fontSize:
14,
), ),
), ),
Row( Row(
@ -1182,23 +1217,28 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
RatingBar RatingBar
.readOnly( .readOnly(
initialRating: model initialRating: model
.parentProducts[index] .parentProducts[
index]
.approvedRatingSum .approvedRatingSum
.toDouble(), .toDouble(),
size: size: 15.0,
15.0,
filledColor: filledColor:
Colors.yellow[700], Colors.yellow[
700],
emptyColor: emptyColor:
Colors.grey[500], Colors.grey[
500],
isHalfAllowed: isHalfAllowed:
true, true,
halfFilledIcon: halfFilledIcon:
Icons.star_half, Icons
.star_half,
filledIcon: filledIcon:
Icons.star, Icons
.star,
emptyIcon: emptyIcon:
Icons.star, Icons
.star,
), ),
Texts( Texts(
"(${model.parentProducts[index].approvedTotalReviews})", "(${model.parentProducts[index].approvedTotalReviews})",
@ -1207,7 +1247,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
fontSize: fontSize:
10, 10,
fontWeight: fontWeight:
FontWeight.w400, FontWeight
.w400,
) )
], ],
), ),
@ -1217,8 +1258,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
widget.authenticatedUserObject widget.authenticatedUserObject
.isLogin .isLogin
? Container( ? Container(
child: IconButton( child:
icon: Icon( IconButton(
icon:
Icon(
Icons Icons
.shopping_cart, .shopping_cart,
size: size:
@ -1226,7 +1269,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
color: color:
CustomColors.green, CustomColors.green,
), ),
onPressed: () async { onPressed:
() async {
if (model.parentProducts[index].rxMessage == if (model.parentProducts[index].rxMessage ==
null) { null) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
@ -1265,8 +1309,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
children: [ children: [
Padding( Padding(
padding: padding:
const EdgeInsets.all( const EdgeInsets.all(8.0),
8.0),
child: Image.asset( child: Image.asset(
'assets/images/new-design/empty_box.png', 'assets/images/new-design/empty_box.png',
width: 100, width: 100,
@ -1276,15 +1319,13 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
Padding( Padding(
padding: padding:
const EdgeInsets.all( const EdgeInsets.all(8.0),
8.0),
child: Text( child: Text(
TranslationBase.of( TranslationBase.of(context)
context)
.noData, .noData,
// 'There is no data', // 'There is no data',
style: TextStyle( style:
fontSize: 30), TextStyle(fontSize: 30),
), ),
) )
], ],
@ -1292,15 +1333,6 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
), ),
) )
: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor:
AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
)
], ],
), ),
), ),

@ -121,7 +121,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
// '${value.quantityCount ?? 0}'); // '${value.quantityCount ?? 0}');
} }
}); });
})) }, model))
], ],
), ),
), ),

@ -1,6 +1,9 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -11,8 +14,10 @@ class ProductOrderItem extends StatefulWidget {
final ShoppingCart item; final ShoppingCart item;
final VoidCallback changeCartItems; final VoidCallback changeCartItems;
final VoidCallback deleteCartItems; final VoidCallback deleteCartItems;
final OrderPreviewViewModel model;
ProductOrderItem(this.item, this.changeCartItems, this.deleteCartItems); ProductOrderItem(
this.item, this.changeCartItems, this.deleteCartItems, this.model);
@override @override
_ProductOrderItemState createState() => _ProductOrderItemState(); _ProductOrderItemState createState() => _ProductOrderItemState();
@ -40,7 +45,8 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
leading: InkWell( leading: InkWell(
onTap: () => {widget.deleteCartItems()}, onTap: () => {widget.deleteCartItems()},
child: Icon( child: Icon(
FontAwesomeIcons.trashAlt,size: 15, FontAwesomeIcons.trashAlt,
size: 15,
color: Colors.grey.shade700, color: Colors.grey.shade700,
), ),
), ),
@ -50,7 +56,8 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
(widget.item.product.images != null && widget.item.product.images.length > 0) (widget.item.product.images != null &&
widget.item.product.images.length > 0)
? Image.network( ? Image.network(
widget.item.product.images[0].src, widget.item.product.images[0].src,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -95,13 +102,17 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
child: Row( child: Row(
children: [ children: [
InkWell( InkWell(
onTap: () => onTap: () => widget.model.error.isEmpty
{_quantityOnChangeClick(Operation.dec)}, ? {_quantityOnChangeClick(Operation.dec)}
: Utils.showErrorToast(
widget.model.error),
child: Container( child: Container(
width: 25, width: 25,
height: 25, height: 25,
child: Icon( child: Icon(
Icons.remove, color: Colors.grey.shade400, size: 20, Icons.remove,
color: Colors.grey.shade400,
size: 20,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
@ -129,7 +140,8 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
if (value == null) { if (value == null) {
widget.item.quantity = 0; widget.item.quantity = 0;
} else { } else {
widget.item.quantity = int.parse(text); widget.item.quantity =
int.parse(text);
} }
_totalPrice = _totalPrice =
"${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}";
@ -138,13 +150,17 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
)), )),
), ),
InkWell( InkWell(
onTap: () => onTap: () => widget.model.error == null
{_quantityOnChangeClick(Operation.inc)}, ? {_quantityOnChangeClick(Operation.inc)}
: Utils.showErrorToast(
widget.model.error),
child: Container( child: Container(
width: 25, width: 25,
height: 25, height: 25,
child: Icon( child: Icon(
Icons.add, color: Colors.grey.shade400, size: 20, Icons.add,
color: Colors.grey.shade400,
size: 20,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
@ -169,21 +185,21 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
widget.item.product.stockQuantity == 0 ? widget.item.product.stockQuantity == 0
Texts( ? Texts(
projectProvider.isArabic projectProvider.isArabic
? widget.item.product.stockAvailabilityn ? widget.item.product
: widget.item.product.stockAvailability, .stockAvailabilityn
: widget.item.product
.stockAvailability,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
fontSize: 13, fontSize: 13,
color:Colors.red, color: Colors.red,
)
): Texts(""), : Texts(""),
], ],
), ),
), ),
], ],
), ),
) )
@ -209,6 +225,7 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
_quantityOnChangeClick(Operation operation) { _quantityOnChangeClick(Operation operation) {
int newValue = 0; int newValue = 0;
setState(() { setState(() {
switch (operation) { switch (operation) {
case Operation.inc: case Operation.inc:

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
@ -18,6 +19,7 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:rating_bar/rating_bar.dart'; import 'package:rating_bar/rating_bar.dart';
import 'base/base_view.dart'; import 'base/base_view.dart';
@ -55,6 +57,10 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
color: Colors.blue, color: Colors.blue,
size: 29.0, size: 29.0,
); );
int pageIndex = 1;
RefreshController controller = RefreshController();
List<CategoriseParentModel> entityList = List(); List<CategoriseParentModel> entityList = List();
List<CategoriseParentModel> entityListBrands = List(); List<CategoriseParentModel> entityListBrands = List();
@ -65,7 +71,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
ProjectViewModel projectProvider = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context);
return BaseView<PharmacyCategoriseViewModel>( return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) => model.getSubCategorise(i: id), onModelReady: (model) => model.getSubCategorise(
i: id, pageIndex: pageIndex, isLoading: false, context: context),
allowAny: true, allowAny: true,
builder: (BuildContext context, PharmacyCategoriseViewModel model, builder: (BuildContext context, PharmacyCategoriseViewModel model,
Widget child) => Widget child) =>
@ -75,9 +82,26 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
isShowAppBar: true, isShowAppBar: true,
backgroundColor: Colors.white, backgroundColor: Colors.white,
isShowDecPage: false, isShowDecPage: false,
//baseViewModel: model,
body: NetworkBaseView(
baseViewModel: model, baseViewModel: model,
body: SmartRefresher(
controller: controller,
enablePullDown: false,
enablePullUp: true,
onLoading: () async {
setState(() {
++pageIndex;
});
await model.getSubProducts(
pageIndex: pageIndex,
i: id,
isLoading: true,
context: context);
if (model.state != ViewState.BusyLocal && pageIndex < 5) {
controller.loadComplete();
} else {
controller.loadFailed();
}
},
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(
child: Column( child: Column(

Loading…
Cancel
Save