Merge branch 'hussam_pharmacy_fix' into 'development_new_design_2.0'

sub categorise fix

See merge request Cloud_Solution/diplomatic-quarter!511
merge-requests/515/merge
haroon amjad 4 years ago
commit d78d1f1068

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

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save