daynimic listing

merge-update-with-lab-changes
hussam al-habibeh 5 years ago
parent 299a1bed25
commit 2723422bbf

@ -4,29 +4,29 @@ import 'PharmacyImageObject.dart';
import 'Reviews.dart';
class PharmacyProduct {
String id;
dynamic id;
bool visibleIndividually;
String name;
String namen;
String shortDescription;
String shortDescriptionn;
String fullDescription;
String fullDescriptionn;
dynamic name;
dynamic namen;
dynamic shortDescription;
dynamic shortDescriptionn;
dynamic fullDescription;
dynamic fullDescriptionn;
bool markasNew;
bool showOnHomePage;
String metaKeywords;
String metaDescription;
String metaTitle;
dynamic metaKeywords;
dynamic metaDescription;
dynamic metaTitle;
bool allowCustomerReviews;
int approvedRatingSum;
int notApprovedRatingSum;
int approvedTotalReviews;
int notApprovedTotalReviews;
String sku;
dynamic sku;
bool isRx;
bool prescriptionRequired;
String rxMessage;
String rxMessagen;
dynamic rxMessage;
dynamic rxMessagen;
String manufacturerPartNumber;
String gtin;
bool isGiftCard;
@ -115,7 +115,6 @@ class PharmacyProduct {
int vendorId;
String seName;
PharmacyProduct(
{this.id,
this.visibleIndividually,

@ -112,7 +112,7 @@ class PharmacyCategoriseService extends BaseService {
);
}
Future getBrands() async {
Future getBrands({String id}) async {
hasError = false;
_brandsList.clear();
await baseAppClient.getPharmacy(

@ -55,11 +55,11 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getBrands() async {
Future getBrands({String id}) async {
hasError = false;
// _insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
await _pharmacyCategoriseService.getBrands();
await _pharmacyCategoriseService.getBrands(id: id);
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.ErrorLocal);
@ -105,7 +105,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.ErrorLocal);
} else
await getParentProducts(i: i);
await getBrands();
await getBrands(id: i);
}
Future getParentProducts({String i}) async {

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/size_config.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/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart';
@ -7,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
@ -42,7 +44,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
color: Colors.blue,
size: 29.0,
);
List<CategoriseParentModel> entityList = List();
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
@ -57,11 +59,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
backgroundColor: Colors.white,
isShowDecPage: false,
baseViewModel: model,
body: Container(
child: ListView(
scrollDirection: Axis.vertical,
children: [
Container(
body: SingleChildScrollView(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -97,8 +96,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: EdgeInsets.all(10.0),
@ -125,16 +123,14 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
scrollDirection:
Axis.vertical,
itemCount: model
.categoriseParent
.length,
.categoriseParent.length,
itemBuilder:
(BuildContext context,
int index) {
return Container(
child: Padding(
padding:
EdgeInsets.all(
4.0),
EdgeInsets.all(4.0),
child: InkWell(
child: Column(
crossAxisAlignment:
@ -146,8 +142,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.name),
Divider(
thickness:
0.6,
thickness: 0.6,
color: Colors
.black12,
)
@ -167,8 +162,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.categoriseParent[
index]
.id,
parentId:
id,
parentId: id,
)),
);
},
@ -204,11 +198,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
itemCount: model.categoriseParent.length > 8
? 8
: model.categoriseParent.length,
itemBuilder:
(BuildContext context, int index) {
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.0),
padding:
EdgeInsets.symmetric(horizontal: 8.0),
child: InkWell(
child: Column(
crossAxisAlignment:
@ -222,8 +215,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
width: 65.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors
.orange.shade200
color: Colors.orange.shade200
.withOpacity(0.45),
),
child: Center(
@ -247,12 +239,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: Texts(
projectViewModel.isArabic
? model
.categoriseParent[
index]
.categoriseParent[index]
.namen
: model
.categoriseParent[
index]
.categoriseParent[index]
.name,
fontSize: 13.4,
fontWeight: FontWeight.w600,
@ -268,8 +258,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
FadePage(
page: SubCategorisePage(
title: model
.categoriseParent[index]
.name,
.categoriseParent[index].name,
id: model
.categoriseParent[index].id,
parentId: id,
@ -318,11 +307,11 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
maxChildSize: 0.95,
minChildSize: 0.9,
builder: (BuildContext context,
ScrollController
scrollController) {
ScrollController scrollController) {
return SingleChildScrollView(
controller: scrollController,
child: Container(
color: Colors.white,
height: MediaQuery.of(context)
.size
.height *
@ -343,8 +332,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Texts(
'Refine',
fontWeight:
FontWeight
.w600,
FontWeight.w600,
),
SizedBox(
width: 250.0,
@ -352,11 +340,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
InkWell(
child: Texts(
'Close',
color:
Colors.red,
color: Colors.red,
fontWeight:
FontWeight
.w600,
FontWeight.w600,
fontSize: 15.0,
),
onTap: () {
@ -374,54 +360,46 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Column(
children: [
ExpansionTile(
title: Texts(
'Categorise'),
children: [
Container(
height: 350,
child: ListView
.builder(
controller:
scrollController,
scrollDirection:
Axis
.vertical,
shrinkWrap:
true,
itemCount: model
.categoriseParent
.length,
itemBuilder:
(BuildContext context,
int index) {
return CheckboxListTile(
tristate:
true,
title:
Texts(model.categoriseParent[index].name),
controlAffinity:
ListTileControlAffinity.leading,
value:
checkedCategorise,
onChanged:
(bool value) {
Texts('Categorise'),
children: [
ProcedureListWidget(
model: model,
masterList: model
.categoriseParent,
removeHistory:
(item) {
setState(() {
checkedCategorise = value;
entityList
.remove(
item);
});
},
);
}),
addHistory:
(history) {
setState(() {
entityList.add(
history);
});
},
addSelectedHistories:
() {
//TODO build your fun herr
// widget.addSelectedHistories();
},
isEntityListSelected:
(master) =>
isEntityListSelected(
master),
)
],
),
Divider(
thickness: 1.0,
color:
Colors.black12,
color: Colors.black12,
),
ExpansionTile(
title:
Texts('Brands'),
title: Texts('Brands'),
children: [
Container(
height: 350,
@ -436,21 +414,26 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.brandsList
.length,
itemBuilder:
(BuildContext context,
(BuildContext
context,
int index) {
return CheckboxListTile(
tristate:
true,
title:
Texts(model.brandsList[index].name),
title: Texts(model
.brandsList[index]
.name),
controlAffinity:
ListTileControlAffinity.leading,
value:
checkedBrands,
onChanged:
(bool value) {
setState(() {
checkedBrands = value;
(bool
value) {
setState(
() {
checkedBrands =
value;
});
},
autofocus:
@ -462,12 +445,10 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
Divider(
thickness: 1.0,
color:
Colors.black12,
color: Colors.black12,
),
ExpansionTile(
title:
Texts('Price'),
title: Texts('Price'),
children: [
Container(
color: Color(
@ -485,8 +466,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Texts(
'Min'),
Container(
color:
Colors.white,
color: Colors
.white,
width:
200,
height:
@ -495,7 +476,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
TextFormField(
decoration:
InputDecoration(
border: OutlineInputBorder(),
border:
OutlineInputBorder(),
),
),
),
@ -509,8 +491,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Texts(
'Max'),
Container(
color:
Colors.white,
color: Colors
.white,
width:
200,
height:
@ -519,7 +501,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
TextFormField(
decoration:
InputDecoration(
border: OutlineInputBorder(),
border:
OutlineInputBorder(),
),
),
),
@ -532,8 +515,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
Divider(
thickness: 1.0,
color:
Colors.black12,
color: Colors.black12,
),
SizedBox(
height: MediaQuery.of(
@ -544,8 +526,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
Padding(
padding:
EdgeInsets.all(
8.0),
EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment
@ -554,11 +535,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container(
width: 100,
child: Button(
label:
'Reset',
label: 'Reset',
backgroundColor:
Colors
.red,
Colors.red,
),
),
SizedBox(
@ -567,8 +546,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Container(
width: 200,
child: Button(
label:
'Apply',
label: 'Apply',
backgroundColor:
Colors
.green,
@ -637,7 +615,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
styleOne == true
? Container(
height: SizeConfig.screenHeight * 7.8,
height: model.parentProducts.length *
MediaQuery.of(context).size.height *
0.15,
child: GridView.builder(
physics: NeverScrollableScrollPhysics(),
gridDelegate:
@ -648,8 +628,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
childAspectRatio: 0.9,
),
itemCount: model.parentProducts.length,
itemBuilder:
(BuildContext context, int index) {
itemBuilder: (BuildContext context, int index) {
return NetworkBaseView(
baseViewModel: model,
child: InkWell(
@ -684,10 +663,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.only(
topLeft:
Radius.circular(110.0),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(110.0),
),
color: Colors.white,
),
@ -715,8 +692,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
BoxDecoration(),
child: Padding(
padding:
EdgeInsets
.only(
EdgeInsets.only(
right: 5.0,
top: 20.0,
bottom: 5.0,
@ -724,10 +700,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
child: Texts(
'offer'
.toUpperCase(),
color: Colors
.red,
fontSize:
13.0,
color: Colors.red,
fontSize: 13.0,
fontWeight:
FontWeight
.w900,
@ -739,8 +713,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
),
Container(
margin: EdgeInsets
.fromLTRB(
margin:
EdgeInsets.fromLTRB(
0, 16, 0, 0),
alignment:
Alignment.center,
@ -774,10 +748,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
: 0,
padding:
EdgeInsets.all(4),
decoration:
BoxDecoration(
color: Color(
0xffb23838),
decoration: BoxDecoration(
color:
Color(0xffb23838),
borderRadius:
BorderRadius.only(
topLeft: Radius
@ -805,8 +778,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
],
),
Container(
margin:
EdgeInsets.symmetric(
margin: EdgeInsets.symmetric(
horizontal: 6,
vertical: 0,
),
@ -821,8 +793,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
.discountName !=
null)
Container(
width: double
.infinity,
width:
double.infinity,
height: 13.0,
decoration:
BoxDecoration(
@ -836,10 +808,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.discountName,
regular: true,
color: Colors
.white,
fontSize:
10.4,
color:
Colors.white,
fontSize: 10.4,
),
),
),
@ -873,20 +844,21 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.approvedRatingSum >
0
? (model.parentProducts[index].approvedRatingSum.toDouble() /
model.parentProducts[index].approvedRatingSum
? (model.parentProducts[index].approvedRatingSum
.toDouble() /
model
.parentProducts[index]
.approvedRatingSum
.toDouble())
.toDouble()
: 0,
forceStars:
true),
forceStars: true),
Texts(
"(${model.parentProducts[index].approvedTotalReviews})",
regular: true,
fontSize: 10,
fontWeight:
FontWeight
.w400,
FontWeight.w400,
)
],
),
@ -901,9 +873,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Navigator.push(
context,
FadePage(
page: ProductDetailPage(
model.parentProducts[
index]),
page: ProductDetailPage(model
.parentProducts[index]),
)),
},
));
@ -911,8 +882,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
)
: Container(
height:
MediaQuery.of(context).size.height * 5.0,
height: model.parentProducts.length *
MediaQuery.of(context).size.height *
0.122,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: model.parentProducts.length,
@ -939,8 +911,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
),
Container(
margin: EdgeInsets
.fromLTRB(
margin:
EdgeInsets.fromLTRB(
0, 0, 0, 0),
alignment:
Alignment.center,
@ -978,17 +950,15 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
: 0,
padding:
EdgeInsets.all(4),
decoration:
BoxDecoration(
color: Color(
0xffb23838),
decoration: BoxDecoration(
color:
Color(0xffb23838),
borderRadius:
BorderRadius.only(
topLeft: Radius
.circular(
6)),
),
child: Expanded(
child: Texts(
model
.parentProducts[
@ -1000,14 +970,11 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.rxMessage
: "",
color:
Colors.white,
color: Colors.white,
regular: true,
fontSize: 10,
fontWeight:
FontWeight
.w400,
),
FontWeight.w400,
),
),
],
@ -1024,22 +991,20 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
MainAxisAlignment
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment
.start,
CrossAxisAlignment.start,
children: [
SizedBox(
height: 4.0,
),
Container(
width: MediaQuery.of(
context)
width:
MediaQuery.of(context)
.size
.width *
0.65,
child: Texts(
model
.parentProducts[
index]
.parentProducts[index]
.name,
regular: true,
fontSize: 13.2,
@ -1053,10 +1018,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
),
Padding(
padding:
const EdgeInsets
.only(
top: 4,
bottom: 4),
const EdgeInsets.only(
top: 4, bottom: 4),
child: Texts(
"SAR ${model.parentProducts[index].price}",
bold: true,
@ -1071,10 +1034,14 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
index]
.approvedRatingSum >
0
? (model.parentProducts[index].approvedRatingSum
? (model
.parentProducts[
index]
.approvedRatingSum
.toDouble() /
model
.parentProducts[index]
.parentProducts[
index]
.approvedRatingSum
.toDouble())
.toDouble()
@ -1099,8 +1066,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Navigator.push(
context,
FadePage(
page: ProductDetailPage(model
.parentProducts[index]),
page: ProductDetailPage(
model.parentProducts[index]),
)),
},
);
@ -1109,9 +1076,16 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
],
),
),
],
),
),
));
}
bool isEntityListSelected(CategoriseParentModel masterKey) {
Iterable<CategoriseParentModel> history =
entityList.where((element) => masterKey.id == element.id);
if (history.length > 0) {
return true;
}
return false;
}
}

@ -56,7 +56,6 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
baseViewModel: model,
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height * 5.97,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -596,7 +595,9 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
styleOne == true
? Container(
height: MediaQuery.of(context).size.height * 3.85,
height: model.subProducts.length *
MediaQuery.of(context).size.height *
0.15,
child: GridView.builder(
physics: NeverScrollableScrollPhysics(),
gridDelegate:
@ -604,7 +605,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
crossAxisCount: 2,
crossAxisSpacing: 0.5,
mainAxisSpacing: 2.0,
childAspectRatio: 1.0,
childAspectRatio: 0.9,
),
itemCount: model.subProducts.length,
itemBuilder: (BuildContext context, int index) {
@ -798,7 +799,9 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
),
)
: Container(
height: MediaQuery.of(context).size.height * 5.0,
height: model.subProducts.length *
MediaQuery.of(context).size.height *
0.122,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: model.subProducts.length,

@ -0,0 +1,170 @@
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ProcedureListWidget extends StatefulWidget {
final PharmacyCategoriseViewModel model;
final Function addSelectedHistories;
final Function(CategoriseParentModel) removeHistory;
final Function(CategoriseParentModel) addHistory;
final Function(CategoriseParentModel) addRemarks;
final bool Function(CategoriseParentModel) isEntityListSelected;
final List<CategoriseParentModel> masterList;
ProcedureListWidget(
{Key key,
this.model,
this.addSelectedHistories,
this.removeHistory,
this.masterList,
this.addHistory,
this.isEntityListSelected,
this.addRemarks})
: super(key: key);
@override
_ProcedureListWidgetState createState() => _ProcedureListWidgetState();
}
class _ProcedureListWidgetState extends State<ProcedureListWidget> {
int selectedType = 0;
int typeUrgent;
int typeRegular;
setSelectedType(int val) {
setState(() {
selectedType = val;
});
}
List<CategoriseParentModel> items = List();
List<String> remarksList = List();
List<int> typeList = List();
@override
void initState() {
items.addAll(widget.masterList);
super.initState();
}
TextEditingController remarksController = TextEditingController();
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
NetworkBaseView(
baseViewModel: widget.model,
child: Container(
height: MediaQuery.of(context).size.height * 0.35,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: ListView(
children: [
// TextFields(
// hintText:
// 'sss', //TranslationBase.of(context).searchProcedures,
// suffixIcon: EvaIcons.search,
// onChanged: (value) {
// filterSearchResults(value);
// },
// ),
SizedBox(
height: 15,
),
items.length != 0
? Column(
children: items.map((historyInfo) {
return Column(
children: [
Row(
children: [
Checkbox(
value: widget.isEntityListSelected(
historyInfo),
activeColor: Colors.red[800],
onChanged: (bool newValue) {
setState(() {
if (widget.isEntityListSelected(
historyInfo)) {
widget
.removeHistory(historyInfo);
} else {
widget.addHistory(historyInfo);
}
});
}),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 0),
child: Texts(historyInfo.name,
variant: "bodyText",
bold: true,
color: Colors.black),
),
),
],
),
Divider(
height: 1,
),
],
);
}).toList(),
)
: Center(
child: Container(
child: AppText(
"There's no procedures for this category",
color: Color(0xFFB9382C)),
),
)
],
),
)),
),
),
SizedBox(
height: 10,
),
],
),
);
}
void filterSearchResults(String query) {
List<CategoriseParentModel> dummySearchList = List();
dummySearchList.addAll(widget.masterList);
if (query.isNotEmpty) {
List<CategoriseParentModel> dummyListData = List();
dummySearchList.forEach((item) {
if (item.name.toLowerCase().contains(query.toLowerCase())) {
dummyListData.add(item);
}
});
setState(() {
items.clear();
items.addAll(dummyListData);
});
return;
} else {
setState(() {
items.clear();
items.addAll(widget.masterList);
});
}
}
}
Loading…
Cancel
Save