fix pharmacy products filtering

merge-update-with-lab-changes
hussam al-habibeh 5 years ago
parent 428b45528b
commit b0165c0d29

@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_mo
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart';
import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.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';
@ -24,8 +25,7 @@ class ParentCategorisePage extends StatefulWidget {
ParentCategorisePage({this.id, this.titleName}); ParentCategorisePage({this.id, this.titleName});
@override @override
_ParentCategorisePageState createState() => _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName);
_ParentCategorisePageState(id: id, titleName: titleName);
} }
class _ParentCategorisePageState extends State<ParentCategorisePage> { class _ParentCategorisePageState extends State<ParentCategorisePage> {
@ -56,9 +56,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<PharmacyCategoriseViewModel>( return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) => model.getCategoriseParent(i: id), onModelReady: (model) => model.getCategoriseParent(i: id),
builder: (BuildContext context, PharmacyCategoriseViewModel model, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold(
Widget child) =>
PharmacyAppScaffold(
appBarTitle: titleName, appBarTitle: titleName,
isBottomBar: false, isBottomBar: false,
isShowAppBar: true, isShowAppBar: true,
@ -126,31 +124,20 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
color: Colors.white, color: Colors.white,
child: Center( child: Center(
child: ListView.builder( child: ListView.builder(
scrollDirection: scrollDirection: Axis.vertical,
Axis.vertical, itemCount: model.categoriseParent.length,
itemCount: model itemBuilder: (BuildContext context, int index) {
.categoriseParent.length,
itemBuilder:
(BuildContext context,
int index) {
return Container( return Container(
child: Padding( child: Padding(
padding: padding: EdgeInsets.all(4.0),
EdgeInsets.all(4.0),
child: InkWell( child: InkWell(
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment
.start,
children: [ children: [
Texts(model Texts(model.categoriseParent[index].name),
.categoriseParent[
index]
.name),
Divider( Divider(
thickness: 0.6, thickness: 0.6,
color: Colors color: Colors.black12,
.black12,
) )
], ],
), ),
@ -158,16 +145,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: page: SubCategorisePage(
SubCategorisePage( title: model.categoriseParent[index].name,
title: model id: model.categoriseParent[index].id,
.categoriseParent[
index]
.name,
id: model
.categoriseParent[
index]
.id,
parentId: id, parentId: id,
)), )),
); );
@ -201,28 +181,22 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: Center( child: Center(
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: model.categoriseParent.length > 8 itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.length,
? 8
: model.categoriseParent.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: padding: EdgeInsets.symmetric(horizontal: 8.0),
EdgeInsets.symmetric(horizontal: 8.0),
child: InkWell( child: InkWell(
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.center,
CrossAxisAlignment.center,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(horizontal: 13.0),
horizontal: 13.0),
child: Container( child: Container(
height: 60.0, height: 60.0,
width: 65.0, width: 65.0,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: Colors.orange.shade200 color: Colors.orange.shade200.withOpacity(0.45),
.withOpacity(0.45),
), ),
child: Center( child: Center(
child: Icon( child: Icon(
@ -233,10 +207,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
), ),
Container( Container(
width: MediaQuery.of(context) width: MediaQuery.of(context).size.width * 0.197,
.size
.width *
0.197,
// height: MediaQuery.of(context) // height: MediaQuery.of(context)
// .size // .size
// .height * // .height *
@ -244,12 +215,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: Center( child: Center(
child: Texts( child: Texts(
projectViewModel.isArabic projectViewModel.isArabic
? model ? model.categoriseParent[index].namen
.categoriseParent[index] : model.categoriseParent[index].name,
.namen
: model
.categoriseParent[index]
.name,
fontSize: 13.4, fontSize: 13.4,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
maxLines: 3, maxLines: 3,
@ -263,10 +230,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
context, context,
FadePage( FadePage(
page: SubCategorisePage( page: SubCategorisePage(
title: model title: model.categoriseParent[index].name,
.categoriseParent[index].name, id: model.categoriseParent[index].id,
id: model
.categoriseParent[index].id,
parentId: id, parentId: id,
)), )),
); );
@ -312,21 +277,16 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
initialChildSize: 0.95, initialChildSize: 0.95,
maxChildSize: 0.95, maxChildSize: 0.95,
minChildSize: 0.9, minChildSize: 0.9,
builder: (BuildContext context, builder: (BuildContext context, ScrollController scrollController) {
ScrollController scrollController) {
return SingleChildScrollView( return SingleChildScrollView(
controller: scrollController, controller: scrollController,
child: Container( child: Container(
color: Colors.white, color: Colors.white,
height: MediaQuery.of(context) height: MediaQuery.of(context).size.height * 1.95,
.size
.height *
1.95,
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: padding: EdgeInsets.all(8.0),
EdgeInsets.all(8.0),
child: Row( child: Row(
children: [ children: [
Icon( Icon(
@ -337,8 +297,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
Texts( Texts(
'Refine', 'Refine',
fontWeight: fontWeight: FontWeight.w600,
FontWeight.w600,
), ),
SizedBox( SizedBox(
width: 250.0, width: 250.0,
@ -347,13 +306,11 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: Texts( child: Texts(
'Close', 'Close',
color: Colors.red, color: Colors.red,
fontWeight: fontWeight: FontWeight.w600,
FontWeight.w600,
fontSize: 15.0, fontSize: 15.0,
), ),
onTap: () { onTap: () {
Navigator.pop( Navigator.pop(context);
context);
}, },
), ),
], ],
@ -366,37 +323,27 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Column( Column(
children: [ children: [
ExpansionTile( ExpansionTile(
title: title: Texts('Categorise'),
Texts('Categorise'),
children: [ children: [
ProcedureListWidget( ProcedureListWidget(
model: model, model: model,
masterList: model masterList: model.categoriseParent,
.categoriseParent, removeHistory: (item) {
removeHistory:
(item) {
setState(() { setState(() {
entityList entityList.remove(item);
.remove(
item);
}); });
}, },
addHistory: addHistory: (history) {
(history) {
setState(() { setState(() {
entityList.add( entityList.add(history);
history);
}); });
}, },
addSelectedHistories: addSelectedHistories: () {
() {
//TODO build your fun herr //TODO build your fun herr
// widget.addSelectedHistories(); // widget.addSelectedHistories();
}, },
isEntityListSelected: isEntityListSelected: (master) =>
(master) => isEntityListSelected(master),
isEntityListSelected(
master),
) )
], ],
), ),
@ -409,33 +356,23 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
children: [ children: [
ProcedureListWidget( ProcedureListWidget(
model: model, model: model,
masterList: model masterList: model.brandsList,
.brandsList, removeHistory: (item) {
removeHistory:
(item) {
setState(() { setState(() {
entityListBrands entityListBrands.remove(item);
.remove(
item);
}); });
}, },
addHistory: addHistory: (history) {
(history) {
setState(() { setState(() {
entityListBrands entityListBrands.add(history);
.add(
history);
}); });
}, },
addSelectedHistories: addSelectedHistories: () {
() {
//TODO build your fun herr //TODO build your fun herr
// widget.addSelectedHistories(); // widget.addSelectedHistories();
}, },
isEntityListSelected: isEntityListSelected: (master) =>
(master) => isEntityListSelectedBrands(master),
isEntityListSelectedBrands(
master),
) )
], ],
), ),
@ -447,63 +384,40 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
title: Texts('Price'), title: Texts('Price'),
children: [ children: [
Container( Container(
color: Color( color: Color(0xffEEEEEE),
0xffEEEEEE),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceAround,
MainAxisAlignment
.spaceAround,
children: [ children: [
Column( Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment
.start,
children: [ children: [
Texts( Texts('Min'),
'Min'),
Container( Container(
color: Colors color: Colors.white,
.white, width: 200,
width: height: 40,
200, child: TextFormField(
height: decoration: InputDecoration(
40, border: OutlineInputBorder(),
child:
TextFormField(
decoration:
InputDecoration(
border:
OutlineInputBorder(),
), ),
controller: controller: minField,
minField,
), ),
), ),
], ],
), ),
Column( Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment
.start,
children: [ children: [
Texts( Texts('Max'),
'Max'),
Container( Container(
color: Colors color: Colors.white,
.white, width: 200,
width: height: 40,
200, child: TextFormField(
height: decoration: InputDecoration(
40, border: OutlineInputBorder(),
child:
TextFormField(
decoration:
InputDecoration(
border:
OutlineInputBorder(),
), ),
controller: controller: maxField,
maxField,
), ),
), ),
], ],
@ -518,26 +432,18 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
color: Colors.black12, color: Colors.black12,
), ),
SizedBox( SizedBox(
height: MediaQuery.of( height: MediaQuery.of(context).size.height * 0.4,
context)
.size
.height *
0.4,
), ),
Padding( Padding(
padding: padding: EdgeInsets.all(8.0),
EdgeInsets.all(8.0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceEvenly,
MainAxisAlignment
.spaceEvenly,
children: [ children: [
Container( Container(
width: 100, width: 100,
child: Button( child: Button(
label: 'Reset', label: 'Reset',
backgroundColor: backgroundColor: Colors.red,
Colors.red,
), ),
), ),
SizedBox( SizedBox(
@ -546,54 +452,38 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container( Container(
width: 200, width: 200,
child: Button( child: Button(
onTap: () { onTap: () async {
String String categoriesId = "";
categoriesId = for (CategoriseParentModel category in entityList) {
""; if (categoriesId == "") {
for (CategoriseParentModel category categoriesId = category.id;
in entityList) {
if (categoriesId ==
"") {
categoriesId =
category
.id;
} else { } else {
categoriesId = categoriesId = "$categoriesId,${category.id}";
"$categoriesId,${category.id}";
} }
} }
String String brandIds = "";
brandIds =
"";
for (CategoriseParentModel brand for (CategoriseParentModel brand
in entityListBrands) { in entityListBrands) {
if (brandIds == if (brandIds == "") {
"") { brandIds = brand.id;
brandIds =
brand
.id;
} else { } else {
brandIds = brandIds = "$brandIds,${brand.id}";
"$brandIds,${brand.id}";
} }
} }
model.getFilteredProducts( GifLoaderDialogUtils.showMyDialog(context);
min: minField
.text await model.getFilteredProducts(
.toString(), min: minField.text.toString(),
max: maxField max: maxField.text.toString(),
.text categoryId: categoriesId,
.toString(), brandId: brandIds);
categoryId: GifLoaderDialogUtils.hideDialog(context);
categoriesId,
brandId: Navigator.pop(context);
brandIds);
}, },
label: 'Apply', label: 'Apply',
backgroundColor: backgroundColor: Colors.green,
Colors
.green,
), ),
), ),
], ],
@ -659,13 +549,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
styleOne == true styleOne == true
? Container( ? Container(
height: model.parentProducts.length * height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15,
MediaQuery.of(context).size.height *
0.15,
child: GridView.builder( child: GridView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
gridDelegate: gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisCount: 2,
crossAxisSpacing: 0.5, crossAxisSpacing: 0.5,
mainAxisSpacing: 2.0, mainAxisSpacing: 2.0,
@ -677,9 +564,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
baseViewModel: model, baseViewModel: model,
child: InkWell( child: InkWell(
child: Card( child: Card(
color: model.parentProducts[index] color: model.parentProducts[index].discountName != null
.discountName !=
null
? Color(0xffFFFF00) ? Color(0xffFFFF00)
: Colors.white, : Colors.white,
elevation: 0, elevation: 0,
@ -712,111 +597,62 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
color: Colors.white, color: Colors.white,
), ),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(horizontal: 0),
horizontal: 0), width: MediaQuery.of(context).size.width / 3,
width: MediaQuery.of(context)
.size
.width /
3,
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [ children: [
Stack( Stack(
children: [ children: [
if (model if (model.parentProducts[index].discountName != null)
.parentProducts[
index]
.discountName !=
null)
RotatedBox( RotatedBox(
quarterTurns: 4, quarterTurns: 4,
child: Container( child: Container(
decoration: decoration: BoxDecoration(),
BoxDecoration(),
child: Padding( child: Padding(
padding: padding: EdgeInsets.only(
EdgeInsets.only(
right: 5.0, right: 5.0,
top: 20.0, top: 20.0,
bottom: 5.0, bottom: 5.0,
), ),
child: Texts( child: Texts(
'offer' 'offer'.toUpperCase(),
.toUpperCase(),
color: Colors.red, color: Colors.red,
fontSize: 13.0, fontSize: 13.0,
fontWeight: fontWeight: FontWeight.w900,
FontWeight
.w900,
), ),
), ),
transform: new Matrix4 transform: new Matrix4.rotationZ(5.837200),
.rotationZ(
5.837200),
), ),
), ),
Container( Container(
margin: margin: EdgeInsets.fromLTRB(0, 16, 0, 0),
EdgeInsets.fromLTRB( alignment: Alignment.center,
0, 16, 0, 0),
alignment:
Alignment.center,
child: Image.network( child: Image.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.cover, fit: BoxFit.cover,
height: 80, height: 80,
), ),
), ),
Container( Container(
width: model width: model.parentProducts[index].rxMessage != null
.parentProducts[ ? MediaQuery.of(context).size.width / 5
index]
.rxMessage !=
null
? MediaQuery.of(
context)
.size
.width /
5
: 0, : 0,
padding: padding: EdgeInsets.all(4),
EdgeInsets.all(4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: Color(0xffb23838),
Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)),
borderRadius:
BorderRadius.only(
topLeft: Radius
.circular(
6)),
), ),
child: Texts( child: Texts(
model model.parentProducts[index].rxMessage != null
.parentProducts[ ? model.parentProducts[index].rxMessage
index]
.rxMessage !=
null
? model
.parentProducts[
index]
.rxMessage
: "", : "",
color: Colors.white, color: Colors.white,
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
), ),
), ),
], ],
@ -827,53 +663,32 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
vertical: 0, vertical: 0,
), ),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment
.start,
children: [ children: [
if (model if (model.parentProducts[index].discountName != null)
.parentProducts[
index]
.discountName !=
null)
Container( Container(
width: width: double.infinity,
double.infinity,
height: 13.0, height: 13.0,
decoration: decoration: BoxDecoration(
BoxDecoration( color: Color(0xff5AB145),
color: Color(
0xff5AB145),
), ),
child: Center( child: Center(
child: Texts( child: Texts(
model model.parentProducts[index].discountName,
.parentProducts[
index]
.discountName,
regular: true, regular: true,
color: color: Colors.white,
Colors.white,
fontSize: 10.4, fontSize: 10.4,
), ),
), ),
), ),
Texts( Texts(
model model.parentProducts[index].name,
.parentProducts[
index]
.name,
regular: true, regular: true,
fontSize: 12, fontSize: 12,
fontWeight: fontWeight: FontWeight.w700,
FontWeight.w700,
), ),
Padding( Padding(
padding: padding: const EdgeInsets.only(top: 4, bottom: 4),
const EdgeInsets
.only(
top: 4,
bottom: 4),
child: Texts( child: Texts(
"SAR ${model.parentProducts[index].price}", "SAR ${model.parentProducts[index].price}",
bold: true, bold: true,
@ -883,26 +698,21 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Row( Row(
children: [ children: [
StarRating( StarRating(
totalAverage: model totalAverage:
.parentProducts[ model.parentProducts[index].approvedRatingSum > 0
index] ? (model.parentProducts[index].approvedRatingSum
.approvedRatingSum > .toDouble() /
0 model.parentProducts[index]
? (model.parentProducts[index].approvedRatingSum .approvedRatingSum
.toDouble() / .toDouble())
model .toDouble()
.parentProducts[index] : 0,
.approvedRatingSum
.toDouble())
.toDouble()
: 0,
forceStars: true), forceStars: true),
Texts( Texts(
"(${model.parentProducts[index].approvedTotalReviews})", "(${model.parentProducts[index].approvedTotalReviews})",
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
) )
], ],
), ),
@ -917,8 +727,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: ProductDetailPage(model page: ProductDetailPage(model.parentProducts[index]),
.parentProducts[index]),
)), )),
}, },
)); ));
@ -926,14 +735,11 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
) )
: Container( : Container(
height: model.parentProducts.length * height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122,
MediaQuery.of(context).size.height *
0.122,
child: ListView.builder( child: ListView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemCount: model.parentProducts.length, itemCount: model.parentProducts.length,
itemBuilder: itemBuilder: (BuildContext context, int index) {
(BuildContext context, int index) {
return InkWell( return InkWell(
child: Card( child: Card(
child: Row( child: Row(
@ -943,11 +749,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Column( Column(
children: [ children: [
Container( Container(
decoration: decoration: BoxDecoration(),
BoxDecoration(),
child: Padding( child: Padding(
padding: padding: EdgeInsets.only(
EdgeInsets.only(
left: 9.0, left: 9.0,
top: 8.0, top: 8.0,
right: 10.0, right: 10.0,
@ -955,22 +759,11 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
), ),
Container( Container(
margin: margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
EdgeInsets.fromLTRB( alignment: Alignment.center,
0, 0, 0, 0),
alignment:
Alignment.center,
child: Image.network( child: Image.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.contain, fit: BoxFit.contain,
height: 80, height: 80,
@ -981,44 +774,22 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Column( Column(
children: [ children: [
Container( Container(
width: model width: model.parentProducts[index].rxMessage != null
.parentProducts[ ? MediaQuery.of(context).size.width / 5
index]
.rxMessage !=
null
? MediaQuery.of(
context)
.size
.width /
5
: 0, : 0,
padding: padding: EdgeInsets.all(4),
EdgeInsets.all(4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: Color(0xffb23838),
Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)),
borderRadius:
BorderRadius.only(
topLeft: Radius
.circular(
6)),
), ),
child: Texts( child: Texts(
model model.parentProducts[index].rxMessage != null
.parentProducts[ ? model.parentProducts[index].rxMessage
index]
.rxMessage !=
null
? model
.parentProducts[
index]
.rxMessage
: "", : "",
color: Colors.white, color: Colors.white,
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
), ),
), ),
], ],
@ -1031,29 +802,19 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
vertical: 0, vertical: 0,
), ),
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceAround,
MainAxisAlignment crossAxisAlignment: CrossAxisAlignment.start,
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
height: 4.0, height: 4.0,
), ),
Container( Container(
width: width: MediaQuery.of(context).size.width * 0.65,
MediaQuery.of(context)
.size
.width *
0.65,
child: Texts( child: Texts(
model model.parentProducts[index].name,
.parentProducts[index]
.name,
regular: true, regular: true,
fontSize: 13.2, fontSize: 13.2,
fontWeight: fontWeight: FontWeight.w500,
FontWeight.w500,
maxLines: 5, maxLines: 5,
), ),
), ),
@ -1061,9 +822,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
height: 8.0, height: 8.0,
), ),
Padding( Padding(
padding: padding: const EdgeInsets.only(top: 4, bottom: 4),
const EdgeInsets.only(
top: 4, bottom: 4),
child: Texts( child: Texts(
"SAR ${model.parentProducts[index].price}", "SAR ${model.parentProducts[index].price}",
bold: true, bold: true,
@ -1073,30 +832,20 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Row( Row(
children: [ children: [
StarRating( StarRating(
totalAverage: model totalAverage:
.parentProducts[ model.parentProducts[index].approvedRatingSum > 0
index] ? (model.parentProducts[index].approvedRatingSum
.approvedRatingSum > .toDouble() /
0 model.parentProducts[index].approvedRatingSum
? (model .toDouble())
.parentProducts[ .toDouble()
index] : 0,
.approvedRatingSum
.toDouble() /
model
.parentProducts[
index]
.approvedRatingSum
.toDouble())
.toDouble()
: 0,
forceStars: true), forceStars: true),
Texts( Texts(
"(${model.parentProducts[index].approvedTotalReviews})", "(${model.parentProducts[index].approvedTotalReviews})",
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
) )
], ],
), ),
@ -1110,8 +859,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: ProductDetailPage( page: ProductDetailPage(model.parentProducts[index]),
model.parentProducts[index]),
)), )),
}, },
); );
@ -1125,8 +873,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
} }
bool isEntityListSelected(CategoriseParentModel masterKey) { bool isEntityListSelected(CategoriseParentModel masterKey) {
Iterable<CategoriseParentModel> history = Iterable<CategoriseParentModel> history = entityList.where((element) => masterKey.id == element.id);
entityList.where((element) => masterKey.id == element.id);
if (history.length > 0) { if (history.length > 0) {
return true; return true;
} }
@ -1134,8 +881,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
} }
bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { bool isEntityListSelectedBrands(CategoriseParentModel masterKey) {
Iterable<CategoriseParentModel> history = Iterable<CategoriseParentModel> history = entityListBrands.where((element) => masterKey.id == element.id);
entityListBrands.where((element) => masterKey.id == element.id);
if (history.length > 0) { if (history.length > 0) {
return true; return true;
} }

@ -1,6 +1,7 @@
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.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';
@ -21,8 +22,7 @@ class SubCategorisePage extends StatefulWidget {
SubCategorisePage({this.id, this.parentId, this.title}); SubCategorisePage({this.id, this.parentId, this.title});
@override @override
_SubCategorisePageState createState() => _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId);
_SubCategorisePageState(id: id, title: title, parentId: parentId);
} }
class _SubCategorisePageState extends State<SubCategorisePage> { class _SubCategorisePageState extends State<SubCategorisePage> {
@ -50,9 +50,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
TextEditingController maxField = TextEditingController(); TextEditingController maxField = TextEditingController();
return BaseView<PharmacyCategoriseViewModel>( return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) => model.getSubCategorise(i: id), onModelReady: (model) => model.getSubCategorise(i: id),
builder: (BuildContext context, PharmacyCategoriseViewModel model, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold(
Widget child) =>
PharmacyAppScaffold(
appBarTitle: title, appBarTitle: title,
isBottomBar: false, isBottomBar: false,
isShowAppBar: true, isShowAppBar: true,
@ -84,8 +82,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png'
: parentId == '9' : parentId == '9'
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png'
: parentId == : parentId == '10'
'10'
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png'
: '', : '',
fit: BoxFit.fill, fit: BoxFit.fill,
@ -97,8 +94,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
children: [ children: [
InkWell( InkWell(
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.all(10.0), padding: EdgeInsets.all(10.0),
@ -115,30 +111,21 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return Container(
height: height: MediaQuery.of(context).size.height * 0.89,
MediaQuery.of(context).size.height *
0.89,
color: Colors.white, color: Colors.white,
child: Center( child: Center(
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
itemCount: itemCount: model.subCategorise.length,
model.subCategorise.length, itemBuilder: (BuildContext context, int index) {
itemBuilder: (BuildContext context,
int index) {
return Container( return Container(
child: Padding( child: Padding(
padding: EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: InkWell( child: InkWell(
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment
.start,
children: [ children: [
Texts(model Texts(model.subCategorise[index].name),
.subCategorise[
index]
.name),
Divider( Divider(
thickness: 0.6, thickness: 0.6,
color: Colors.black12, color: Colors.black12,
@ -149,12 +136,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: page: FinalProductsPage(
FinalProductsPage( id: model.subCategorise[index].id,
id: model
.subCategorise[
index]
.id,
), ),
), ),
); );
@ -187,23 +170,19 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
itemCount: model.subCategorise.length, itemCount: model.subCategorise.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: padding: EdgeInsets.symmetric(horizontal: 8.0),
EdgeInsets.symmetric(horizontal: 8.0),
child: InkWell( child: InkWell(
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.center,
CrossAxisAlignment.center,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(horizontal: 13.0),
horizontal: 13.0),
child: Container( child: Container(
height: 60.0, height: 60.0,
width: 65.0, width: 65.0,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: Colors.orange.shade200 color: Colors.orange.shade200.withOpacity(0.45),
.withOpacity(0.45),
), ),
child: Center( child: Center(
child: Icon( child: Icon(
@ -214,14 +193,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
), ),
), ),
Container( Container(
width: MediaQuery.of(context) width: MediaQuery.of(context).size.width * 0.17,
.size height: MediaQuery.of(context).size.height * 0.10,
.width *
0.17,
height: MediaQuery.of(context)
.size
.height *
0.10,
child: Center( child: Center(
child: Texts( child: Texts(
model.subCategorise[index].name, model.subCategorise[index].name,
@ -281,21 +254,16 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
initialChildSize: 0.95, initialChildSize: 0.95,
maxChildSize: 0.95, maxChildSize: 0.95,
minChildSize: 0.9, minChildSize: 0.9,
builder: (BuildContext context, builder: (BuildContext context, ScrollController scrollController) {
ScrollController scrollController) {
return SingleChildScrollView( return SingleChildScrollView(
controller: scrollController, controller: scrollController,
child: Container( child: Container(
color: Colors.white, color: Colors.white,
height: MediaQuery.of(context) height: MediaQuery.of(context).size.height * 1.95,
.size
.height *
1.95,
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: padding: EdgeInsets.all(8.0),
EdgeInsets.all(8.0),
child: Row( child: Row(
children: [ children: [
Icon( Icon(
@ -306,8 +274,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
), ),
Texts( Texts(
'Refine', 'Refine',
fontWeight: fontWeight: FontWeight.w600,
FontWeight.w600,
), ),
SizedBox( SizedBox(
width: 250.0, width: 250.0,
@ -316,13 +283,11 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
child: Texts( child: Texts(
'Close', 'Close',
color: Colors.red, color: Colors.red,
fontWeight: fontWeight: FontWeight.w600,
FontWeight.w600,
fontSize: 15.0, fontSize: 15.0,
), ),
onTap: () { onTap: () {
Navigator.pop( Navigator.pop(context);
context);
}, },
), ),
], ],
@ -335,37 +300,27 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Column( Column(
children: [ children: [
ExpansionTile( ExpansionTile(
title: title: Texts('Categorise'),
Texts('Categorise'),
children: [ children: [
ProcedureListWidget( ProcedureListWidget(
model: model, model: model,
masterList: model masterList: model.subCategorise,
.subCategorise, removeHistory: (item) {
removeHistory:
(item) {
setState(() { setState(() {
entityList entityList.remove(item);
.remove(
item);
}); });
}, },
addHistory: addHistory: (history) {
(history) {
setState(() { setState(() {
entityList.add( entityList.add(history);
history);
}); });
}, },
addSelectedHistories: addSelectedHistories: () {
() {
//TODO build your fun herr //TODO build your fun herr
// widget.addSelectedHistories(); // widget.addSelectedHistories();
}, },
isEntityListSelected: isEntityListSelected: (master) =>
(master) => isEntityListSelected(master),
isEntityListSelected(
master),
) )
], ],
), ),
@ -378,33 +333,23 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
children: [ children: [
ProcedureListWidget( ProcedureListWidget(
model: model, model: model,
masterList: model masterList: model.brandsList,
.brandsList, removeHistory: (item) {
removeHistory:
(item) {
setState(() { setState(() {
entityListBrands entityListBrands.remove(item);
.remove(
item);
}); });
}, },
addHistory: addHistory: (history) {
(history) {
setState(() { setState(() {
entityListBrands entityListBrands.add(history);
.add(
history);
}); });
}, },
addSelectedHistories: addSelectedHistories: () {
() {
//TODO build your fun herr //TODO build your fun herr
// widget.addSelectedHistories(); // widget.addSelectedHistories();
}, },
isEntityListSelected: isEntityListSelected: (master) =>
(master) => isEntityListSelectedBrands(master),
isEntityListSelectedBrands(
master),
) )
], ],
), ),
@ -416,63 +361,40 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
title: Texts('Price'), title: Texts('Price'),
children: [ children: [
Container( Container(
color: Color( color: Color(0xffEEEEEE),
0xffEEEEEE),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceAround,
MainAxisAlignment
.spaceAround,
children: [ children: [
Column( Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment
.start,
children: [ children: [
Texts( Texts('Min'),
'Min'),
Container( Container(
color: Colors color: Colors.white,
.white, width: 200,
width: height: 40,
200, child: TextFormField(
height: decoration: InputDecoration(
40, border: OutlineInputBorder(),
child:
TextFormField(
decoration:
InputDecoration(
border:
OutlineInputBorder(),
), ),
controller: controller: minField,
minField,
), ),
), ),
], ],
), ),
Column( Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment
.start,
children: [ children: [
Texts( Texts('Max'),
'Max'),
Container( Container(
color: Colors color: Colors.white,
.white, width: 200,
width: height: 40,
200, child: TextFormField(
height: decoration: InputDecoration(
40, border: OutlineInputBorder(),
child:
TextFormField(
decoration:
InputDecoration(
border:
OutlineInputBorder(),
), ),
controller: controller: maxField,
maxField,
), ),
), ),
], ],
@ -487,26 +409,18 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
color: Colors.black12, color: Colors.black12,
), ),
SizedBox( SizedBox(
height: MediaQuery.of( height: MediaQuery.of(context).size.height * 0.4,
context)
.size
.height *
0.4,
), ),
Padding( Padding(
padding: padding: EdgeInsets.all(8.0),
EdgeInsets.all(8.0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceEvenly,
MainAxisAlignment
.spaceEvenly,
children: [ children: [
Container( Container(
width: 100, width: 100,
child: Button( child: Button(
label: 'Reset', label: 'Reset',
backgroundColor: backgroundColor: Colors.red,
Colors.red,
), ),
), ),
SizedBox( SizedBox(
@ -515,54 +429,36 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Container( Container(
width: 200, width: 200,
child: Button( child: Button(
onTap: () { onTap: () async {
String String categoriesId = "";
categoriesId = for (CategoriseParentModel category in entityList) {
""; if (categoriesId == "") {
for (CategoriseParentModel category categoriesId = category.id;
in entityList) {
if (categoriesId ==
"") {
categoriesId =
category
.id;
} else { } else {
categoriesId = categoriesId = "$categoriesId,${category.id}";
"$categoriesId,${category.id}";
} }
} }
String String brandIds = "";
brandIds =
"";
for (CategoriseParentModel brand for (CategoriseParentModel brand
in entityListBrands) { in entityListBrands) {
if (brandIds == if (brandIds == "") {
"") { brandIds = brand.id;
brandIds =
brand
.id;
} else { } else {
brandIds = brandIds = "$brandIds,${brand.id}";
"$brandIds,${brand.id}";
} }
} }
GifLoaderDialogUtils.showMyDialog(context);
model.getFilteredProducts( await model.getFilteredProducts(
min: minField min: minField.text.toString(),
.text max: maxField.text.toString(),
.toString(), categoryId: categoriesId,
max: maxField brandId: brandIds);
.text GifLoaderDialogUtils.hideDialog(context);
.toString(), Navigator.pop(context);
categoryId:
categoriesId,
brandId:
brandIds);
}, },
label: 'Apply', label: 'Apply',
backgroundColor: backgroundColor: Colors.green,
Colors
.green,
), ),
), ),
], ],
@ -628,27 +524,22 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
), ),
styleOne == true styleOne == true
? Container( ? Container(
height: model.subProducts.length * height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15,
MediaQuery.of(context).size.height *
0.15,
child: GridView.builder( child: GridView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
gridDelegate: gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisCount: 2,
crossAxisSpacing: 0.5, crossAxisSpacing: 0.5,
mainAxisSpacing: 2.0, mainAxisSpacing: 2.0,
childAspectRatio: 0.9, childAspectRatio: 0.9,
), ),
itemCount: model.subProducts.length, itemCount: model.parentProducts.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return NetworkBaseView( return NetworkBaseView(
baseViewModel: model, baseViewModel: model,
child: InkWell( child: InkWell(
child: Card( child: Card(
color: model.subProducts[index] color: model.parentProducts[index].discountName != null
.discountName !=
null
? Color(0xffFFFF00) ? Color(0xffFFFF00)
: Colors.white, : Colors.white,
elevation: 0, elevation: 0,
@ -681,77 +572,41 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
), ),
color: Colors.white, color: Colors.white,
), ),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(horizontal: 0),
horizontal: 0), width: MediaQuery.of(context).size.width / 3,
width: MediaQuery.of(context)
.size
.width /
3,
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [ children: [
Stack( Stack(
children: [ children: [
Container( Container(
margin: margin: EdgeInsets.fromLTRB(0, 16, 0, 0),
EdgeInsets.fromLTRB( alignment: Alignment.center,
0, 16, 0, 0),
alignment:
Alignment.center,
child: Image.network( child: Image.network(
model model.parentProducts[index].images.isNotEmpty
.subProducts[ ? model.parentProducts[index].images[0].thumb
index]
.images
.isNotEmpty
? model
.subProducts[
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.cover, fit: BoxFit.cover,
height: 80, height: 80,
), ),
), ),
Container( Container(
width: model width: model.parentProducts[index].rxMessage != null
.subProducts[ ? MediaQuery.of(context).size.width / 5
index]
.rxMessage !=
null
? MediaQuery.of(
context)
.size
.width /
5
: 0, : 0,
padding: padding: EdgeInsets.all(4),
EdgeInsets.all(4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: Color(0xffb23838),
Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)),
borderRadius:
BorderRadius.only(
topLeft: Radius
.circular(
6)),
), ),
child: Texts( child: Texts(
model.subProducts[index] model.parentProducts[index].rxMessage != null
.rxMessage != ? model.parentProducts[index].rxMessage
null
? model
.subProducts[
index]
.rxMessage
: "", : "",
color: Colors.white, color: Colors.white,
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
), ),
), ),
], ],
@ -762,26 +617,18 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
vertical: 0, vertical: 0,
), ),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment
.start,
children: [ children: [
Texts( Texts(
model.subProducts[index] model.parentProducts[index].name,
.name,
regular: true, regular: true,
fontSize: 12, fontSize: 12,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
), ),
Padding( Padding(
padding: padding: const EdgeInsets.only(top: 4, bottom: 4),
const EdgeInsets
.only(
top: 4,
bottom: 4),
child: Texts( child: Texts(
"SAR ${model.subProducts[index].price}", "SAR ${model.parentProducts[index].price}",
bold: true, bold: true,
fontSize: 14, fontSize: 14,
), ),
@ -789,26 +636,21 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Row( Row(
children: [ children: [
StarRating( StarRating(
totalAverage: model totalAverage:
.subProducts[ model.parentProducts[index].approvedRatingSum > 0
index] ? (model.parentProducts[index].approvedRatingSum
.approvedRatingSum > .toDouble() /
0 model.parentProducts[index]
? (model.subProducts[index].approvedRatingSum .approvedRatingSum
.toDouble() / .toDouble())
model .toDouble()
.subProducts[index] : 0,
.approvedRatingSum
.toDouble())
.toDouble()
: 0,
forceStars: true), forceStars: true),
Texts( Texts(
"(${model.subProducts[index].approvedTotalReviews})", "(${model.parentProducts[index].approvedTotalReviews})",
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
) )
], ],
), ),
@ -823,8 +665,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: ProductDetailPage( page: ProductDetailPage(model.parentProducts[index]),
model.subProducts[index]),
)), )),
}, },
)); ));
@ -832,14 +673,11 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
), ),
) )
: Container( : Container(
height: model.subProducts.length * height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122,
MediaQuery.of(context).size.height *
0.122,
child: ListView.builder( child: ListView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemCount: model.subProducts.length, itemCount: model.parentProducts.length,
itemBuilder: itemBuilder: (BuildContext context, int index) {
(BuildContext context, int index) {
return InkWell( return InkWell(
child: Card( child: Card(
child: Row( child: Row(
@ -849,11 +687,9 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Column( Column(
children: [ children: [
Container( Container(
decoration: decoration: BoxDecoration(),
BoxDecoration(),
child: Padding( child: Padding(
padding: padding: EdgeInsets.only(
EdgeInsets.only(
left: 9.0, left: 9.0,
top: 8.0, top: 8.0,
right: 10.0, right: 10.0,
@ -861,22 +697,11 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
), ),
), ),
Container( Container(
margin: margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
EdgeInsets.fromLTRB( alignment: Alignment.center,
0, 0, 0, 0),
alignment:
Alignment.center,
child: Image.network( child: Image.network(
model model.parentProducts[index].images.isNotEmpty
.subProducts[ ? model.parentProducts[index].images[0].thumb
index]
.images
.isNotEmpty
? model
.subProducts[
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.contain, fit: BoxFit.contain,
height: 80, height: 80,
@ -887,42 +712,22 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Column( Column(
children: [ children: [
Container( Container(
width: model width: model.parentProducts[index].rxMessage != null
.subProducts[ ? MediaQuery.of(context).size.width / 5
index]
.rxMessage !=
null
? MediaQuery.of(
context)
.size
.width /
5
: 0, : 0,
padding: padding: EdgeInsets.all(4),
EdgeInsets.all(4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: Color(0xffb23838),
Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)),
borderRadius:
BorderRadius.only(
topLeft: Radius
.circular(
6)),
), ),
child: Texts( child: Texts(
model.subProducts[index] model.parentProducts[index].rxMessage != null
.rxMessage != ? model.parentProducts[index].rxMessage
null
? model
.subProducts[
index]
.rxMessage
: "", : "",
color: Colors.white, color: Colors.white,
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
), ),
), ),
], ],
@ -936,28 +741,19 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
vertical: 0, vertical: 0,
), ),
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceAround,
MainAxisAlignment crossAxisAlignment: CrossAxisAlignment.start,
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
height: 4.0, height: 4.0,
), ),
Container( Container(
width: width: MediaQuery.of(context).size.width * 0.65,
MediaQuery.of(context)
.size
.width *
0.65,
child: Texts( child: Texts(
model.subProducts[index] model.parentProducts[index].name,
.name,
regular: true, regular: true,
fontSize: 13.2, fontSize: 13.2,
fontWeight: fontWeight: FontWeight.w500,
FontWeight.w500,
maxLines: 5, maxLines: 5,
), ),
), ),
@ -965,11 +761,9 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
height: 8.0, height: 8.0,
), ),
Padding( Padding(
padding: padding: const EdgeInsets.only(top: 4, bottom: 4),
const EdgeInsets.only(
top: 4, bottom: 4),
child: Texts( child: Texts(
"SAR ${model.subProducts[index].price}", "SAR ${model.parentProducts[index].price}",
bold: true, bold: true,
fontSize: 14, fontSize: 14,
), ),
@ -977,30 +771,20 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Row( Row(
children: [ children: [
StarRating( StarRating(
totalAverage: model totalAverage:
.subProducts[ model.parentProducts[index].approvedRatingSum > 0
index] ? (model.parentProducts[index].approvedRatingSum
.approvedRatingSum > .toDouble() /
0 model.parentProducts[index].approvedRatingSum
? (model .toDouble())
.subProducts[ .toDouble()
index] : 0,
.approvedRatingSum
.toDouble() /
model
.parentProducts[
index]
.approvedRatingSum
.toDouble())
.toDouble()
: 0,
forceStars: true), forceStars: true),
Texts( Texts(
"(${model.subProducts[index].approvedTotalReviews})", "(${model.parentProducts[index].approvedTotalReviews})",
regular: true, regular: true,
fontSize: 10, fontSize: 10,
fontWeight: fontWeight: FontWeight.w400,
FontWeight.w400,
) )
], ],
), ),
@ -1014,8 +798,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: ProductDetailPage( page: ProductDetailPage(model.parentProducts[index]),
model.subProducts[index]),
)), )),
}, },
); );
@ -1029,8 +812,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
} }
bool isEntityListSelected(CategoriseParentModel masterKey) { bool isEntityListSelected(CategoriseParentModel masterKey) {
Iterable<CategoriseParentModel> history = Iterable<CategoriseParentModel> history = entityList.where((element) => masterKey.id == element.id);
entityList.where((element) => masterKey.id == element.id);
if (history.length > 0) { if (history.length > 0) {
return true; return true;
} }
@ -1038,8 +820,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
} }
bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { bool isEntityListSelectedBrands(CategoriseParentModel masterKey) {
Iterable<CategoriseParentModel> history = Iterable<CategoriseParentModel> history = entityListBrands.where((element) => masterKey.id == element.id);
entityListBrands.where((element) => masterKey.id == element.id);
if (history.length > 0) { if (history.length > 0) {
return true; return true;
} }

Loading…
Cancel
Save