Merge branch 'blood_pressure' into 'development'

fix pharmacy products filtering

See merge request Cloud_Solution/diplomatic-quarter!388
merge-update-with-lab-changes
Mohammad Aljammal 4 years ago
commit 473f372a85

@ -95,9 +95,8 @@ class PharmacyCategoriseService extends BaseService {
Future searchProducts({String productName}) async {
hasError = false;
_searchList.clear();
String endPoint = productName != null
? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1'
: GET_SEARCH_PRODUCTS + "";
String endPoint =
productName != null ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' : GET_SEARCH_PRODUCTS + "";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
@ -132,8 +131,7 @@ class PharmacyCategoriseService extends BaseService {
Future getCategoriseParent({String id}) async {
hasError = false;
_parentCategoriseList.clear();
String endPoint =
id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + "";
String endPoint = id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + "";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
@ -151,9 +149,7 @@ class PharmacyCategoriseService extends BaseService {
Future getParentProducts({String id}) async {
hasError = false;
_parentProductsList.clear();
String endPoint = id != null
? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50'
: GET_PARENT_PRODUCTS + "";
String endPoint = id != null ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' : GET_PARENT_PRODUCTS + "";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
@ -172,8 +168,7 @@ class PharmacyCategoriseService extends BaseService {
hasError = false;
_subCategoriseList.clear();
String endPoint =
id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + "";
String endPoint = id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + "";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
@ -191,9 +186,7 @@ class PharmacyCategoriseService extends BaseService {
Future getSubProducts({String id}) async {
hasError = false;
_subProductsList.clear();
String endPoint = id != null
? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50'
: GET_SUB_PRODUCTS + "";
String endPoint = id != null ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' : GET_SUB_PRODUCTS + "";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
@ -211,8 +204,7 @@ class PharmacyCategoriseService extends BaseService {
Future getFinalProducts({String id}) async {
hasError = false;
_finalProducts.clear();
String endPoint =
id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + "";
String endPoint = id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + "";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
@ -249,14 +241,11 @@ class PharmacyCategoriseService extends BaseService {
Future getLastVisitedProducts() async {
String lastVisited = "";
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) !=
null) {
lastVisited =
await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) {
lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
try {
await baseAppClient
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited",
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited",
onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
@ -277,8 +266,7 @@ class PharmacyCategoriseService extends BaseService {
'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews',
};
try {
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT,
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
@ -292,8 +280,7 @@ class PharmacyCategoriseService extends BaseService {
}
}
Future getFilteredProducts(
{String categoryId, String brandId, String min, String max}) async {
Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async {
hasError = false;
String endPoint;
@ -317,24 +304,47 @@ class PharmacyCategoriseService extends BaseService {
);
}
Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async {
hasError = false;
String endPoint;
_subProductsList.clear();
endPoint = FILTERED_PRODUCTS +
"$categoryId" +
"&manufacturerids=$brandId" +
"&price_min=$min" +
"&price_max=$max&page=1&limit=50";
await baseAppClient.getPharmacy(
endPoint,
onSuccess: (dynamic response, int statusCode) {
response['products'].forEach((item) {
_subProductsList.add(PharmacyProduct.fromJson(item));
});
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
);
}
Future getMostViewedProducts() async {
Map<String, String> queryParams = {
'fields':
'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage',
'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage',
};
try {
await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS,
onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
});
print("most viewed products ---------");
print(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
});
print("most viewed products ---------");
print(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}
@ -342,22 +352,20 @@ class PharmacyCategoriseService extends BaseService {
Future getNewProducts() async {
Map<String, String> queryParams = {
'fields':
'Id,name,namen,localized_names,price,images,sku,stock_availability,published',
'fields': 'Id,name,namen,localized_names,price,images,sku,stock_availability,published',
};
try {
await baseAppClient.getPharmacy(GET_NEW_PRODUCTS,
onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
});
print("new products ---------");
print(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
});
print("new products ---------");
print(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}

@ -17,28 +17,20 @@ import 'base_view_model.dart';
class PharmacyCategoriseViewModel extends BaseViewModel {
bool hasError = false;
PharmacyCategoriseService _pharmacyCategoriseService =
locator<PharmacyCategoriseService>();
PharmacyCategoriseService _pharmacyCategoriseService = locator<PharmacyCategoriseService>();
List<PharmacyCategorise> get categorise =>
_pharmacyCategoriseService.categoriseList;
List<PharmacyCategorise> get categorise => _pharmacyCategoriseService.categoriseList;
List<CategoriseParentModel> get categoriseParent =>
_pharmacyCategoriseService.parentCategoriseList;
List<CategoriseParentModel> get categoriseParent => _pharmacyCategoriseService.parentCategoriseList;
List<PharmacyProduct> get parentProducts =>
_pharmacyCategoriseService.parentProductsList;
List<PharmacyProduct> get parentProducts => _pharmacyCategoriseService.parentProductsList;
List<CategoriseParentModel> get subCategorise =>
_pharmacyCategoriseService.subCategoriseList;
List<CategoriseParentModel> get subCategorise => _pharmacyCategoriseService.subCategoriseList;
List<PharmacyProduct> get subProducts =>
_pharmacyCategoriseService.subProductsList;
List<PharmacyProduct> get subProducts => _pharmacyCategoriseService.subProductsList;
List<PharmacyProduct> get finalProducts =>
_pharmacyCategoriseService.finalProducts;
List<CategoriseParentModel> get brandsList =>
_pharmacyCategoriseService.brandsList;
List<PharmacyProduct> get finalProducts => _pharmacyCategoriseService.finalProducts;
List<CategoriseParentModel> get brandsList => _pharmacyCategoriseService.brandsList;
List<PharmacyProduct> get searchList => _pharmacyCategoriseService.searchList;
@ -157,12 +149,23 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getFilteredProducts(
{String categoryId, String brandId, String min, String max}) async {
Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async {
hasError = false;
// _insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
await _pharmacyCategoriseService.getFilteredProducts(
await _pharmacyCategoriseService.getFilteredProducts(categoryId: categoryId, brandId: brandId, max: max, min: min);
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async {
hasError = false;
// _insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
await _pharmacyCategoriseService.getFilteredSubProducts(
categoryId: categoryId, brandId: brandId, max: max, min: min);
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;

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

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

Loading…
Cancel
Save