Merge branch 'fix-pharmacy' into 'development'

Fix pharmacy

See merge request Cloud_Solution/diplomatic-quarter!271
merge-requests/272/merge
Mohammad Aljammal 5 years ago
commit a211248cfa

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart';
@ -229,12 +230,12 @@ class PharmacyCategoriseService extends BaseService {
hasError = false; hasError = false;
Map<String, String> queryParams = {'ManufacturerId': id}; Map<String, String> queryParams = {'ManufacturerId': id};
manufacturerProducts.clear(); _finalProducts.clear();
await baseAppClient.getPharmacy( await baseAppClient.getPharmacy(
GET_BRAND_ITEMS, GET_BRAND_ITEMS,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
response['products'].forEach((item) { response['products'].forEach((item) {
manufacturerProducts.add(FinalProductsModel.fromJson(item)); _finalProducts.add(FinalProductsModel.fromJson(item));
}); });
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
@ -243,4 +244,44 @@ class PharmacyCategoriseService extends BaseService {
}, queryParams: queryParams, }, queryParams: queryParams,
); );
} }
Future getLastVisitedProducts() async {
String lastVisited = "";
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) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(FinalProductsModel.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
});
} catch (error) {
throw error;
}
}
}
Future getBestSellerProducts() async {
Map<String, String> queryParams = {
'fields':
'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) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(FinalProductsModel.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}
}
} }

@ -158,4 +158,26 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
Future getLastVisitedProducts() async {
setState(ViewState.Busy);
await _pharmacyCategoriseService.getLastVisitedProducts();
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
Future getBestSellerProducts() async {
setState(ViewState.Busy);
await _pharmacyCategoriseService.getBestSellerProducts();
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
} }

@ -10,7 +10,7 @@ import 'base/base_view.dart';
class FinalProductsPage extends StatefulWidget { class FinalProductsPage extends StatefulWidget {
final String id; final String id;
final int productType; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed
FinalProductsPage({this.id, this.productType = 1}); FinalProductsPage({this.id, this.productType = 1});
@ -35,9 +35,18 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PharmacyCategoriseViewModel>( return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) => widget.productType == 1 onModelReady: (model) {
? model.getFinalProducts(i: id) if (widget.productType == 1) {
: model.getManufacturerProducts(id), model.getFinalProducts(i: id);
} else if (widget.productType == 2) {
model.getManufacturerProducts(id);
} else if (widget.productType == 3) {
model.getLastVisitedProducts();
} else {
model.getBestSellerProducts();
}
},
allowAny: true,
builder: (BuildContext context, PharmacyCategoriseViewModel model, builder: (BuildContext context, PharmacyCategoriseViewModel model,
Widget child) => Widget child) =>
PharmacyAppScaffold( PharmacyAppScaffold(

@ -49,78 +49,74 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: appBar: currentTab != 4
? AppBar(
// currentTab == 0 || currentTab == 1 || currentTab == 2 backgroundColor: Color(0xff5AB145),
// ? elevation: 0,
title: Container(
AppBar( height: MediaQuery.of(context).size.height * 0.056,
backgroundColor: Color(0xff5AB145), decoration: BoxDecoration(
elevation: 0, borderRadius: BorderRadius.circular(5.0),
title: Container( color: Colors.white,
height: MediaQuery.of(context).size.height * 0.056, ),
decoration: BoxDecoration( child: InkWell(
borderRadius: BorderRadius.circular(5.0), child: Padding(
color: Colors.white, padding: EdgeInsets.all(8.0),
), child: Row(
child: InkWell( //crossAxisAlignment: CrossAxisAlignment.center,
child: Padding( mainAxisAlignment: MainAxisAlignment.start,
padding: EdgeInsets.all(8.0), children: [
child: Row( Icon(Icons.search, size: 25.0),
//crossAxisAlignment: CrossAxisAlignment.center, SizedBox(
mainAxisAlignment: MainAxisAlignment.start, width: 15.0,
children: [ ),
Icon(Icons.search, size: 25.0), Texts(
SizedBox( TranslationBase.of(context).searchProductHere,
width: 15.0, fontSize: 13,
)
],
),
), ),
Texts( onTap: () {
TranslationBase.of(context).searchProductHere, Navigator.push(
fontSize: 13, context,
) MaterialPageRoute(
], builder: (context) => SearchProductsPage()),
), );
), },
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SearchProductsPage()),
);
},
),
),
leading: Builder(
builder: (BuildContext context) {
return InkWell(
onTap: () {
setState(() {
currentTab = 0;
pageController.jumpToPage(0);
});
},
child: Container(
height: 2.0,
width: 10.0,
child: Image.asset(
'assets/images/pharmacy_logo.png',
), ),
), ),
); leading: Builder(
}, builder: (BuildContext context) {
), return InkWell(
actions: [ onTap: () {
IconButton( setState(() {
// iconSize: 70, currentTab = 0;
icon: Image.asset( pageController.jumpToPage(0);
'assets/images/new-design/qr-code.png', });
},
child: Container(
height: 2.0,
width: 10.0,
child: Image.asset(
'assets/images/pharmacy_logo.png',
),
),
);
},
), ),
onPressed: _scanQrAndGetProduct //do something, actions: [
) IconButton(
], // iconSize: 70,
centerTitle: true, icon: Image.asset(
), 'assets/images/new-design/qr-code.png',
// : currentTab == 4 ),
// ? null:null, onPressed: _scanQrAndGetProduct //do something,
)
],
centerTitle: true,
)
: null,
// : AppBar( // : AppBar(
// backgroundColor: Color(0xff5AB145), // backgroundColor: Color(0xff5AB145),
// elevation: 0, // elevation: 0,
@ -155,7 +151,6 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
controller: pageController, controller: pageController,
children: [ children: [
// TODO mosa_comeback
PharmacyPage(), PharmacyPage(),
PharmacyCategorisePage(), PharmacyCategorisePage(),
// OffersCategorisePage(), // OffersCategorisePage(),
@ -180,8 +175,9 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
try { try {
String barcode = result; String barcode = result;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await BaseAppClient().getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", await BaseAppClient()
onSuccess: (dynamic response, int statusCode) { .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode",
onSuccess: (dynamic response, int statusCode) {
print(response); print(response);
var product = PharmacyProduct.fromJson(response["products"][0]); var product = PharmacyProduct.fromJson(response["products"][0]);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);

@ -27,7 +27,7 @@ class CartOrderPage extends StatelessWidget {
value: model.cartResponse, value: model.cartResponse,
child: AppScaffold( child: AppScaffold(
appBarTitle: TranslationBase.of(context).shoppingCart, appBarTitle: TranslationBase.of(context).shoppingCart,
isShowAppBar: false, isShowAppBar: true,
isPharmacy: true, isPharmacy: true,
baseViewModel: model, baseViewModel: model,
backgroundColor: Colors.white, backgroundColor: Colors.white,

@ -20,6 +20,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:rating_bar/rating_bar.dart'; import 'package:rating_bar/rating_bar.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart';
import '../../final_products_page.dart';
import 'lacum-activitaion-vida-page.dart'; import 'lacum-activitaion-vida-page.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
@ -48,8 +49,8 @@ class PharmacyPage extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
BannerPager(model), BannerPager(model),
// GridViewButtons(model), GridViewButtons(model),
Container( Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10), margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row( child: Row(
@ -77,181 +78,193 @@ class PharmacyPage extends StatelessWidget {
], ],
), ),
), ),
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0), padding:
EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
height: MediaQuery.of(context).size.height * 0.30, height: MediaQuery.of(context).size.height * 0.30,
// width: 200.0, // width: 200.0,
// height: MediaQuery.of(context).size.height / 4 + 20, // height: MediaQuery.of(context).size.height / 4 + 20,
margin: EdgeInsets.only(left: 10), margin: EdgeInsets.only(left: 10),
child: BaseView<PharmacyModuleViewModel>( child: BaseView<PharmacyModuleViewModel>(
onModelReady: (model) => model.getPrescription(), onModelReady: (model) => model.getPrescription(),
builder: (_, model, wi) => model.prescriptionsList.length != 0 builder: (_, model, wi) => model.prescriptionsList.length !=
0
// model.getPrescription(); // model.getPrescription();
? ListView.builder( ? ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
shrinkWrap: true, shrinkWrap: true,
physics: ScrollPhysics(), physics: ScrollPhysics(),
// physics: NeverScrollableScrollPhysics(), // physics: NeverScrollableScrollPhysics(),
// itemCount: 4, // itemCount: 4,
itemCount: model.prescriptionsList.length, itemCount: model.prescriptionsList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Container( return Container(
// width: 160.0, // width: 160.0,
height: MediaQuery.of(context).size.height * 0.6, height:
padding: EdgeInsets.only(bottom: 5.0, left: 5.0), MediaQuery.of(context).size.height * 0.6,
margin: EdgeInsets.only(right: 10.0), padding:
decoration: BoxDecoration( EdgeInsets.only(bottom: 5.0, left: 5.0),
border: Border.all( margin: EdgeInsets.only(right: 10.0),
color: Colors.grey, decoration: BoxDecoration(
style: BorderStyle.solid, border: Border.all(
width: 1.0, color: Colors.grey,
), style: BorderStyle.solid,
color: Colors.white, width: 1.0,
borderRadius: BorderRadius.circular(10.0)), ),
child: Column( color: Colors.white,
crossAxisAlignment: CrossAxisAlignment.start, borderRadius: BorderRadius.circular(10.0)),
children: <Widget>[ child: Column(
Row( crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Column(children: [ Row(
Container( children: <Widget>[
padding: EdgeInsets.only( Column(children: [
top: 10.0, Container(
left: 10.0,
right: 3.0,
bottom: 15.0,
),
child: Image.network(
model.prescriptionsList[index]
.doctorImageURL,
width: 60,
height: 60,
),
),
]),
Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(left: 1),
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: 15.0, right: 15.0), top: 10.0,
decoration: BoxDecoration( left: 10.0,
border: Border.all( right: 3.0,
color: Colors.green, bottom: 15.0,
style: BorderStyle.solid, ),
width: 4.0, child: Image.network(
model.prescriptionsList[index]
.doctorImageURL,
width: 60,
height: 60,
),
),
]),
Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin:
EdgeInsets.only(left: 1),
padding: EdgeInsets.only(
left: 15.0, right: 15.0),
decoration: BoxDecoration(
border: Border.all(
color: Colors.green,
style:
BorderStyle.solid,
width: 4.0,
),
color: Colors.green,
borderRadius:
BorderRadius.circular(
30.0)),
child: Text(
model
.prescriptionsList[
index]
.isInOutPatientDescription
.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
),
)),
Row(children: <Widget>[
Image.asset(
'assets/images/Icon-awesome-calendar.png',
width: 30,
height: 30,
),
Text(
model.prescriptionsList[index]
.appointmentDate
.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
), ),
color: Colors.green, )
borderRadius: ]),
BorderRadius.circular( ],
30.0)), ),
child: Text( ],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Row(children: <Widget>[
Text(
model.prescriptionsList[index] model.prescriptionsList[index]
.isInOutPatientDescription .doctorTitle
.toString(), .toString(),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.black,
fontSize: 15.0, fontSize: 15.0,
// fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
)), ),
Row(children: <Widget>[ Text(
Image.asset( model.prescriptionsList[index]
'assets/images/Icon-awesome-calendar.png', .doctorName
width: 30, .toString(),
height: 30, style: TextStyle(
), color: Colors.black,
Text( fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
]),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Text(
model.prescriptionsList[index] model.prescriptionsList[index]
.appointmentDate .clinicDescription
.toString(), .toString(),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.green,
fontSize: 15.0, fontSize: 15.0,
// fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), ),
)
]),
],
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Row(children: <Widget>[
Text(
model.prescriptionsList[index]
.doctorTitle
.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold,
), ),
), ),
Text( ],
model.prescriptionsList[index]
.doctorName
.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
]),
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Text(
model.prescriptionsList[index]
.clinicDescription
.toString(),
style: TextStyle(
color: Colors.green,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
),
),
), ),
], Row(
), crossAxisAlignment:
Row( CrossAxisAlignment.start,
crossAxisAlignment: children: <Widget>[
CrossAxisAlignment.start, Container(
children: <Widget>[ margin: EdgeInsets.only(left: 5),
Container( child: Align(
margin: EdgeInsets.only(left: 5), alignment: Alignment.topLeft,
child: Align( child: RatingBar.readOnly(
alignment: Alignment.topLeft,
child: RatingBar.readOnly(
// initialRating: productRate, // initialRating: productRate,
size: 15.0, size: 15.0,
filledColor: Colors.yellow[700], filledColor:
emptyColor: Colors.grey[500], Colors.yellow[700],
isHalfAllowed: true, emptyColor: Colors.grey[500],
halfFilledIcon: Icons.star_half, isHalfAllowed: true,
filledIcon: Icons.star, halfFilledIcon:
emptyIcon: Icons.star, Icons.star_half,
), filledIcon: Icons.star,
), emptyIcon: Icons.star,
) ),
]), ),
]), )
); ]),
}) ]),
: Container(), );
), })
: Container(),
),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10), margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
@ -333,7 +346,17 @@ class PharmacyPage extends StatelessWidget {
hPadding: 4, hPadding: 4,
borderColor: Colors.green, borderColor: Colors.green,
textColor: Colors.green, textColor: Colors.green,
handler: () {}, handler: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FinalProductsPage(
id: "",
productType: 3,
),
),
);
},
), ),
], ],
), ),
@ -367,7 +390,14 @@ class PharmacyPage extends StatelessWidget {
hPadding: 4, hPadding: 4,
handler: () => { handler: () => {
Navigator.push( Navigator.push(
context, FadePage(page: ProductBrandsPage())), context,
MaterialPageRoute(
builder: (context) => FinalProductsPage(
id: "",
productType: 4,
),
),
),
}, },
), ),
], ],

Loading…
Cancel
Save