Merge branch 'hussam_pharmacy_fix' into 'development_new_design_2.0'

sub categorise fix

See merge request Cloud_Solution/diplomatic-quarter!511
merge-requests/511/merge
hussam alhababieh 5 years ago
commit 1344bd7508

@ -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],
),
),
)
],
),
),

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