sub Categorise fixed

merge-requests/511/head
hussam al-habibeh 5 years ago
parent d7b32df024
commit 300668cc81

@ -5,6 +5,8 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dar
import 'package:diplomaticquarterapp/core/model/pharmacy/scan_qr_model.dart';
import 'package:diplomaticquarterapp/core/service/pharmacy_categorise_service.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import 'base_view_model.dart';
@ -97,23 +99,29 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getCategoriseParent({String i, int pageIndex, bool isLoading}) async {
Future getCategoriseParent(
{String i, int pageIndex, bool isLoading, BuildContext context}) async {
hasError = false;
// _insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
// GifLoaderDialogUtils.showMyDialog(context);
await _pharmacyCategoriseService.getCategoriseParent(id: i);
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.ErrorLocal);
} else
await getBrands(id: i);
await getParentProducts(i: i, pageIndex: pageIndex, isLoading: isLoading);
await getParentProducts(
i: i, pageIndex: pageIndex, isLoading: isLoading, context: context);
// GifLoaderDialogUtils.showMyDialog(context);
}
Future getParentProducts({String i, int pageIndex, bool isLoading}) async {
Future getParentProducts(
{String i, int pageIndex, bool isLoading, BuildContext context}) async {
hasError = false;
// _insuranceCardService.clearInsuranceCard();
setState(ViewState.BusyLocal);
//GifLoaderDialogUtils.showMyDialog(context);
await _pharmacyCategoriseService.getParentProducts(
id: i, pageNumber: pageIndex, isLoading: isLoading);
if (_pharmacyCategoriseService.hasError) {
@ -121,6 +129,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
//GifLoaderDialogUtils.hideDialog(context);
}
Future getSubCategorise({String i}) async {

@ -14,6 +14,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
@ -80,7 +81,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
ProjectViewModel projectProvider = Provider.of(context);
return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) => model.getCategoriseParent(
i: id, pageIndex: pageIndex, isLoading: false),
i: id, pageIndex: pageIndex, isLoading: false, context: context),
allowAny: true,
builder:
(BuildContext context, PharmacyCategoriseViewModel model,
@ -102,7 +103,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
++pageIndex;
});
await model.getParentProducts(
pageIndex: pageIndex, i: id, isLoading: true);
pageIndex: pageIndex,
i: id,
isLoading: true,
context: context);
if (model.state != ViewState.BusyLocal &&
pageIndex < 5) {
controller.loadComplete();
@ -685,8 +689,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
model.parentProducts.isNotEmpty
? styleOne == true
? model.state != ViewState.BusyLocal
? Container(
height: model.parentProducts.length *
height:
model.parentProducts.length *
MediaQuery.of(context)
.size
.height *
@ -703,7 +709,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
itemCount:
model.parentProducts.length,
itemBuilder: (BuildContext context,
itemBuilder:
(BuildContext context,
int index) {
return NetworkBaseView(
baseViewModel: model,
@ -714,33 +721,34 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.discountName !=
null
? Color(0xffFFFF00)
? Color(
0xffFFFF00)
: Colors.white,
elevation: 0,
shape: Border(
right: BorderSide(
color: Colors
.grey.shade300,
color: Colors.grey
.shade300,
width: 1,
),
left: BorderSide(
color: Colors
.grey.shade300,
color: Colors.grey
.shade300,
width: 1,
),
bottom: BorderSide(
color: Colors
.grey.shade300,
color: Colors.grey
.shade300,
width: 1,
),
top: BorderSide(
color: Colors
.grey.shade300,
color: Colors.grey
.shade300,
width: 1,
),
),
margin:
EdgeInsets.symmetric(
margin: EdgeInsets
.symmetric(
horizontal: 8,
vertical: 4,
),
@ -748,16 +756,19 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
decoration:
BoxDecoration(
borderRadius:
BorderRadius.only(
topLeft:
Radius.circular(
BorderRadius
.only(
topLeft: Radius
.circular(
110.0),
),
color: Colors.white,
color:
Colors.white,
),
padding: EdgeInsets
.symmetric(
horizontal: 0),
horizontal:
0),
width: MediaQuery.of(
context)
.size
@ -771,8 +782,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Stack(
children: [
if (model
.parentProducts[
index]
.parentProducts[index]
.discountName !=
null)
RotatedBox(
@ -786,29 +796,20 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Padding(
padding:
EdgeInsets.only(
right:
5.0,
top:
20.0,
bottom:
5.0,
right: 5.0,
top: 20.0,
bottom: 5.0,
),
child:
Texts(
TranslationBase.of(context)
.offers
.toUpperCase(),
color:
Colors.red,
fontSize:
13.0,
fontWeight:
FontWeight.w900,
TranslationBase.of(context).offers.toUpperCase(),
color: Colors.red,
fontSize: 13.0,
fontWeight: FontWeight.w900,
),
),
transform:
new Matrix4.rotationZ(
5.837200),
new Matrix4.rotationZ(5.837200),
),
),
Container(
@ -823,19 +824,13 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.center,
child: Image
.network(
model
.parentProducts[
index]
.images
.isNotEmpty
? model
.parentProducts[index]
.images[0]
.thumb
model.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',
fit: BoxFit
.cover,
height: 80,
height:
80,
),
),
// Container(
@ -892,7 +887,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container(
margin: EdgeInsets
.symmetric(
horizontal: 6,
horizontal:
6,
vertical: 0,
),
child: Column(
@ -901,58 +897,45 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.start,
children: [
if (model
.parentProducts[
index]
.parentProducts[index]
.discountName !=
null)
Container(
width: double
.infinity,
width:
double.infinity,
height:
13.0,
decoration:
BoxDecoration(
color: Color(
0xff5AB145),
color:
Color(0xff5AB145),
),
child:
Center(
child:
Texts(
model
.parentProducts[index]
.discountName,
regular:
true,
color:
Colors.white,
fontSize:
10.4,
model.parentProducts[index].discountName,
regular: true,
color: Colors.white,
fontSize: 10.4,
),
),
),
Texts(
projectViewModel
.isArabic
? model
.parentProducts[
index]
.namen
: model
.parentProducts[index]
.name,
projectViewModel.isArabic
? model.parentProducts[index].namen
: model.parentProducts[index].name,
regular:
true,
fontSize:
12,
fontWeight:
FontWeight
.w700,
FontWeight.w700,
),
Padding(
padding: const EdgeInsets
.only(
top: 4,
padding: const EdgeInsets.only(
top:
4,
bottom:
4),
child:
@ -973,10 +956,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
// forceStars: true),
RatingBar
.readOnly(
initialRating: model
.parentProducts[index]
.approvedRatingSum
.toDouble(),
initialRating:
model.parentProducts[index].approvedRatingSum.toDouble(),
size:
15.0,
filledColor:
@ -1024,7 +1005,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
)
: Container(
height: model.parentProducts.length *
height:
model.parentProducts.length *
MediaQuery.of(context)
.size
.height *
@ -1032,8 +1014,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: ListView.builder(
physics:
NeverScrollableScrollPhysics(),
itemCount:
model.parentProducts.length,
itemCount: model
.parentProducts.length,
itemBuilder:
(BuildContext context,
int index) {
@ -1051,10 +1033,11 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child:
Padding(
padding:
EdgeInsets
.only(
left: 9.0,
top: 8.0,
EdgeInsets.only(
left:
9.0,
top:
8.0,
right:
10.0,
),
@ -1077,18 +1060,12 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.isNotEmpty
? Image
.network(
model
.parentProducts[index]
.images[0]
.thumb,
fit: BoxFit
.contain,
height:
70,
model.parentProducts[index].images[0].thumb,
fit: BoxFit.contain,
height: 70,
)
: Text(TranslationBase.of(
context)
.noImage),
: Text(
TranslationBase.of(context).noImage),
),
],
),
@ -1097,41 +1074,30 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container(
width: model.parentProducts[index].rxMessage !=
null
? MediaQuery.of(context)
.size
.width /
? MediaQuery.of(context).size.width /
5.3
: 0,
padding:
EdgeInsets
.all(
EdgeInsets.all(
4),
decoration:
BoxDecoration(
color: Color(
0xffb23838),
borderRadius:
BorderRadius.only(
topLeft:
Radius.circular(6)),
BorderRadius.only(topLeft: Radius.circular(6)),
),
child: model.parentProducts[index]
.rxMessage !=
child: model.parentProducts[index].rxMessage !=
null
? Texts(
projectProvider.isArabic
? model.parentProducts[index].rxMessagen
: model.parentProducts[index].rxMessage,
color:
Colors.white,
regular:
true,
fontSize:
10,
fontWeight:
FontWeight.w400,
projectProvider.isArabic ? model.parentProducts[index].rxMessagen : model.parentProducts[index].rxMessage,
color: Colors.white,
regular: true,
fontSize: 10,
fontWeight: FontWeight.w400,
)
: Texts(""),
: Texts(
""),
// Texts(
// model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "",
// color: Colors.white,
@ -1162,12 +1128,12 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
height: 4.0,
),
Container(
width: MediaQuery.of(
context)
width: MediaQuery.of(context)
.size
.width *
0.635,
child: Texts(
child:
Texts(
projectViewModel
.isArabic
? model
@ -1175,32 +1141,35 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.namen
: model
.parentProducts[
index]
.parentProducts[index]
.name,
regular: true,
regular:
true,
fontSize:
13.2,
fontWeight:
FontWeight
.w500,
maxLines: 5,
maxLines:
5,
),
),
SizedBox(
height: 8.0,
),
Padding(
padding:
const EdgeInsets
padding: const EdgeInsets
.only(
top: 4,
bottom:
4),
child: Texts(
child:
Texts(
"SAR ${model.parentProducts[index].price}",
bold: true,
fontSize: 14,
bold:
true,
fontSize:
14,
),
),
Row(
@ -1213,28 +1182,23 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
RatingBar
.readOnly(
initialRating: model
.parentProducts[
index]
.parentProducts[index]
.approvedRatingSum
.toDouble(),
size: 15.0,
size:
15.0,
filledColor:
Colors.yellow[
700],
Colors.yellow[700],
emptyColor:
Colors.grey[
500],
Colors.grey[500],
isHalfAllowed:
true,
halfFilledIcon:
Icons
.star_half,
Icons.star_half,
filledIcon:
Icons
.star,
Icons.star,
emptyIcon:
Icons
.star,
Icons.star,
),
Texts(
"(${model.parentProducts[index].approvedTotalReviews})",
@ -1243,8 +1207,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
fontSize:
10,
fontWeight:
FontWeight
.w400,
FontWeight.w400,
)
],
),
@ -1254,10 +1217,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
widget.authenticatedUserObject
.isLogin
? Container(
child:
IconButton(
icon:
Icon(
child: IconButton(
icon: Icon(
Icons
.shopping_cart,
size:
@ -1265,8 +1226,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
color:
CustomColors.green,
),
onPressed:
() async {
onPressed: () async {
if (model.parentProducts[index].rxMessage ==
null) {
GifLoaderDialogUtils.showMyDialog(context);
@ -1305,7 +1265,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
children: [
Padding(
padding:
const EdgeInsets.all(8.0),
const EdgeInsets.all(
8.0),
child: Image.asset(
'assets/images/new-design/empty_box.png',
width: 100,
@ -1315,13 +1276,15 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
Padding(
padding:
const EdgeInsets.all(8.0),
const EdgeInsets.all(
8.0),
child: Text(
TranslationBase.of(context)
TranslationBase.of(
context)
.noData,
// 'There is no data',
style:
TextStyle(fontSize: 30),
style: TextStyle(
fontSize: 30),
),
)
],
@ -1329,6 +1292,15 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
),
)
: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor:
AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
)
],
),
),

@ -77,8 +77,10 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
isShowAppBar: true,
backgroundColor: Colors.white,
isShowDecPage: false,
//baseViewModel: model,
body: NetworkBaseView(
baseViewModel: model,
body: SingleChildScrollView(
child: SingleChildScrollView(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -144,11 +146,13 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
scrollDirection: Axis.vertical,
itemCount:
model.subCategorise.length,
itemBuilder: (BuildContext context,
itemBuilder:
(BuildContext context,
int index) {
return Container(
child: Padding(
padding: EdgeInsets.all(8.0),
padding:
EdgeInsets.all(8.0),
child: InkWell(
child: Column(
crossAxisAlignment:
@ -170,7 +174,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
Divider(
thickness: 0.6,
color: Colors.black12,
color:
Colors.black12,
)
],
),
@ -214,7 +219,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: model.subCategorise.length,
itemBuilder: (BuildContext context, int index) {
itemBuilder:
(BuildContext context, int index) {
return Padding(
padding:
EdgeInsets.symmetric(horizontal: 8.0),
@ -254,9 +260,11 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
child: Center(
child: Texts(
projectViewModel.isArabic
? model.subCategorise[index]
? model
.subCategorise[index]
.namen
: model.subCategorise[index]
: model
.subCategorise[index]
.name,
// model.subCategorise[index].name,
fontSize: 14,
@ -272,7 +280,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
context,
FadePage(
page: FinalProductsPage(
id: model.subCategorise[index].id,
id: model
.subCategorise[index].id,
),
),
);
@ -317,7 +326,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
maxChildSize: 0.95,
minChildSize: 0.9,
builder: (BuildContext context,
ScrollController scrollController) {
ScrollController
scrollController) {
return SingleChildScrollView(
controller: scrollController,
child: Container(
@ -358,7 +368,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
// 'Close',
color: Colors.red,
fontWeight:
FontWeight.w600,
FontWeight
.w600,
fontSize: 15.0,
),
onTap: () {
@ -546,14 +557,16 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
Padding(
padding:
EdgeInsets.all(8.0),
EdgeInsets.all(
8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
Expanded(
child: Container(
child:
Container(
width: 100,
child: Button(
label: TranslationBase.of(
@ -582,8 +595,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
if (categoriesId ==
"") {
categoriesId =
category
.id;
category.id;
} else {
categoriesId =
"$categoriesId,${category.id}";
@ -597,8 +609,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
if (brandIds ==
"") {
brandIds =
brand
.id;
brand.id;
} else {
brandIds =
"$brandIds,${brand.id}";
@ -713,9 +724,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
itemCount: model.subProducts.length,
itemBuilder:
(BuildContext context, int index) {
return NetworkBaseView(
baseViewModel: model,
child: InkWell(
return InkWell(
child: Card(
color: model.subProducts[index]
.discountName !=
@ -747,8 +756,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.only(
borderRadius: BorderRadius.only(
topLeft:
Radius.circular(110.0),
),
@ -767,8 +775,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Stack(
children: [
Container(
margin: EdgeInsets
.fromLTRB(
margin:
EdgeInsets.fromLTRB(
0, 16, 0, 0),
alignment:
Alignment.center,
@ -804,8 +812,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
EdgeInsets.all(4),
decoration:
BoxDecoration(
color: Color(
0xffb23838),
color:
Color(0xffb23838),
borderRadius:
BorderRadius.only(
topLeft: Radius
@ -894,8 +902,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble()
// : 0,
// forceStars: true),
RatingBar
.readOnly(
RatingBar.readOnly(
initialRating: model
.subProducts[
index]
@ -905,9 +912,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
filledColor:
Colors.yellow[
700],
emptyColor:
Colors.grey[
500],
emptyColor: Colors
.grey[500],
isHalfAllowed:
true,
halfFilledIcon:
@ -940,11 +946,10 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
context,
FadePage(
page: ProductDetailPage(
model.subProducts[
index]),
model.subProducts[index]),
)),
},
));
);
},
),
)
@ -970,7 +975,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
BoxDecoration(),
child: Padding(
padding:
EdgeInsets.only(
EdgeInsets
.only(
left: 9.0,
top: 8.0,
right: 10.0,
@ -981,8 +987,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
margin: EdgeInsets
.fromLTRB(
0, 0, 0, 0),
alignment:
Alignment.center,
alignment: Alignment
.center,
child: model
.subProducts[
index]
@ -992,14 +998,15 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
model
.subProducts[
index]
.images[0]
.images[
0]
.thumb,
fit: BoxFit
.contain,
height: 70,
)
: Text(TranslationBase
.of(context)
: Text(TranslationBase.of(
context)
.noImage),
),
],
@ -1019,13 +1026,13 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
5.3
: 0,
padding:
EdgeInsets.all(4),
EdgeInsets.all(
4),
decoration:
BoxDecoration(
color: Color(
0xffb23838),
borderRadius:
BorderRadius.only(
borderRadius: BorderRadius.only(
topLeft: Radius
.circular(
6)),
@ -1043,13 +1050,14 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
index]
.rxMessagen
: model
.subProducts[
index]
.subProducts[index]
.rxMessage,
color: Colors
.white,
regular: true,
fontSize: 10,
regular:
true,
fontSize:
10,
fontWeight:
FontWeight
.w400,
@ -1069,7 +1077,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
Container(
height: 130.0,
margin: EdgeInsets.symmetric(
margin:
EdgeInsets.symmetric(
horizontal: 0,
vertical: 0,
),
@ -1138,13 +1147,16 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
.approvedRatingSum
.toDouble(),
size: 15.0,
filledColor: Colors
.yellow[700],
filledColor:
Colors.yellow[
700],
emptyColor: Colors
.grey[500],
isHalfAllowed: true,
isHalfAllowed:
true,
halfFilledIcon:
Icons.star_half,
Icons
.star_half,
filledIcon:
Icons.star,
emptyIcon:
@ -1155,7 +1167,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
regular: true,
fontSize: 10,
fontWeight:
FontWeight.w400,
FontWeight
.w400,
)
],
),
@ -1212,7 +1225,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
context,
FadePage(
page: ProductDetailPage(
model.subProducts[index]),
model.subProducts[
index]),
)),
},
);
@ -1223,7 +1237,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
child: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
@ -1250,6 +1265,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
),
),
),
));
}

Loading…
Cancel
Save