fix bugs pharmacy home

merge-update-with-lab-changes
mosazaid 4 years ago
parent a398ede172
commit fdb61c78c5

@ -1,5 +1,26 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import '../../../locator.dart';
class BestSellerViewModel extends BaseViewModel { class BestSellerViewModel extends BaseViewModel {
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
List<PharmacyProduct> get bestSellerProduct =>
_pharmacyService.bestSellerProducts;
getBestSellerProducts() async {
setState(ViewState.Busy);
await _pharmacyService.getBestSellerProducts();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
} }

@ -2,10 +2,8 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:provider/provider.dart';
import '../../../locator.dart'; import '../../../locator.dart';
import '../project_view_model.dart';
class PrescriptionViewModel extends BaseViewModel { class PrescriptionViewModel extends BaseViewModel {
@ -15,16 +13,15 @@ class PrescriptionViewModel extends BaseViewModel {
_prescriptionService.prescriptionsList; _prescriptionService.prescriptionsList;
getPrescription() async { getPrescription() async {
await getSavedLanguage();
/*
setState(ViewState.Busy); setState(ViewState.Busy);
await getSavedLanguage();
await _prescriptionService.getPrescription(); await _prescriptionService.getPrescription();
if (_prescriptionService.hasError) { if (_prescriptionService.hasError) {
error = _prescriptionService.error; error = _prescriptionService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else { } else {
setState(ViewState.Idle); setState(ViewState.Idle);
}*/ }
} }
} }

@ -11,6 +11,8 @@ import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_s
import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProduct_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProduct_service.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/navigation_service.dart';
import '../../../locator.dart'; import '../../../locator.dart';
@ -23,21 +25,23 @@ class PharmacyModuleViewModel extends BaseViewModel {
List<PharmacyImageObject> get bannerList => _pharmacyService.bannerItems; List<PharmacyImageObject> get bannerList => _pharmacyService.bannerItems;
List<PharmacyProduct> get bestSellerProduct =>
_pharmacyService.bestSellerProducts;
List <RecommendedProductModel> get recommendedProductList => List <RecommendedProductModel> get recommendedProductList =>
_recommendedProductService.recommendedList; _recommendedProductService.recommendedList;
Future getBannerList() async { Future getBannerList() async {
setState(ViewState.BusyLocal); _pharmacyService.bannerItems.clear();
// setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog(
locator<NavigationService>().navigatorKey.currentContext);
await _pharmacyService.getBannerListList(); await _pharmacyService.getBannerListList();
if (_pharmacyService.hasError) GifLoaderDialogUtils.hideDialog(
//{ locator<NavigationService>().navigatorKey.currentContext);
error = _pharmacyService.error; // if (_pharmacyService.hasError)
// setState(ViewState.Error); // {
// }else // error = _pharmacyService.error;
// setState(ViewState.Error);
// } else
// setState(ViewState.Idle); // setState(ViewState.Idle);
} }
@ -90,17 +94,6 @@ class PharmacyModuleViewModel extends BaseViewModel {
return images; return images;
} }
getBestSellerProducts() async {
await _pharmacyService.getBestSellerProducts();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
}
}
getRecommendedProducts(productId) async { getRecommendedProducts(productId) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _recommendedProductService.getRecommendedProducts(productId); await _recommendedProductService.getRecommendedProducts(productId);
@ -126,19 +119,4 @@ class PharmacyModuleViewModel extends BaseViewModel {
} }
} }
///////////////////////or
// getPrescriptions() async {
// setState(ViewState.Busy);
// await _prescriptionsService.getPrescriptions();
// if (_prescriptionsService.hasError) {
// error = _prescriptionsService.error;
// setState(ViewState.Error);
// } else {
// _filterList();
// await _getPrescriptionsOrders();
// setState(ViewState.Idle);
// }
// }
} }

@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/services/robo_search/search_provider.dart';
import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart';
import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/LocalNotification.dart';
import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart';
import 'package:diplomaticquarterapp/uitl/navigation_service.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
@ -84,6 +85,7 @@ class _MyApp extends State<MyApp> {
navigatorObservers: [ navigatorObservers: [
GAnalytics.shared.navObserver() GAnalytics.shared.navObserver()
], ],
navigatorKey: locator<NavigationService>().navigatorKey,
showSemanticsDebugger: false, showSemanticsDebugger: false,
title: 'Diplomatic Quarter App', title: 'Diplomatic Quarter App',
locale: projectProvider.appLocal, locale: projectProvider.appLocal,

@ -1,4 +1,6 @@
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart';
@ -35,9 +37,10 @@ class PharmacyPage extends StatefulWidget {
class _PharmacyPageState extends State<PharmacyPage> { class _PharmacyPageState extends State<PharmacyPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PharmacyModuleViewModel>( return BaseView<PharmacyModuleViewModel>(
onModelReady: (model) async { onModelReady: (model) async {
// GifLoaderDialogUtils.showMyDialog(context); // GifLoaderDialogUtils.showMyDialog(context);
await model.getSavedLanguage(); await model.getSavedLanguage();
await model.getBannerList(); await model.getBannerList();
// GifLoaderDialogUtils.hideDialog(context); // GifLoaderDialogUtils.hideDialog(context);
@ -49,7 +52,7 @@ class _PharmacyPageState extends State<PharmacyPage> {
isShowDecPage: false, isShowDecPage: false,
baseViewModel: model, baseViewModel: model,
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Container( body: model.state != ViewState.BusyLocal ? Container(
width: double.infinity, width: double.infinity,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
@ -57,54 +60,16 @@ class _PharmacyPageState extends State<PharmacyPage> {
children: <Widget>[ children: <Widget>[
BannerPager(model), BannerPager(model),
GridViewButtons(model), GridViewButtons(model),
//PrescriptionsWidget(), PrescriptionsWidget(),
ShopByBrandWidget(), ShopByBrandWidget(),
RecentlyViewedWidget(), RecentlyViewedWidget(),
// TODO MOUSA BestSellerWidget(),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).bestSellers,
bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
borderColor: Colors.green,
textColor: Colors.green,
vPadding: 6,
hPadding: 4,
handler: () => {
Navigator.push(
context,
FadePage(
page: FinalProductsPage(
id: "",
//TODO Elham* handel this to understans form where the number comming
productType: 20,
),
),
),
},
),
],
),
),
Container(
height: MediaQuery.of(context).size.height / 4 + 20,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ProductTileItem(model.bestSellerProduct[i]),
scrollDirection: Axis.horizontal,
itemCount: model.bestSellerProduct.length,
),
),
], ],
), ),
), ),
) : Container(
height: 200,
color: Colors.red,
), ),
), ),
); );
@ -265,225 +230,233 @@ class PrescriptionsWidget extends StatelessWidget {
} }
}, },
allowAny: true, allowAny: true,
builder: (_, model, wi) => model.prescriptionsList.length != 0 builder: (_, model, wi) => model.prescriptionsList.length > 0
? Container( ? NetworkBaseView(
height: model.prescriptionsList.length > 0 isLocalLoader: true,
? MediaQuery.of(context).size.height * 0.28 baseViewModel: model,
: 0, child: Container(
child: Column( height: model.prescriptionsList.length > 0
children: [ ? MediaQuery.of(context).size.height * 0.28
Container( : 0,
margin: EdgeInsets.fromLTRB(10, 10, 10, 10), child: Column(
child: Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, Container(
children: [ margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
Texts( child: Row(
TranslationBase.of(context).myPrescription, mainAxisAlignment: MainAxisAlignment.spaceBetween,
bold: true, children: [
), Texts(
BorderedButton( TranslationBase.of(context).myPrescription,
TranslationBase.of(context).viewAll, bold: true,
hasBorder: true, ),
borderColor: Colors.green, BorderedButton(
textColor: Colors.green, TranslationBase.of(context).viewAll,
vPadding: 6, hasBorder: true,
hPadding: 4, borderColor: Colors.green,
handler: () { textColor: Colors.green,
Navigator.push( vPadding: 6,
context, hPadding: 4,
MaterialPageRoute( handler: () {
builder: (context) => Navigator.push(
HomePrescriptionsPage())); context,
}, MaterialPageRoute(
), builder: (context) =>
], HomePrescriptionsPage()));
},
),
],
),
), ),
), Container(
Container( padding: EdgeInsets.symmetric(
padding: horizontal: 18.0, vertical: 14.0),
EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), margin: EdgeInsets.only(left: 10),
margin: EdgeInsets.only(left: 10), child: ListView.builder(
child: ListView.builder( scrollDirection: Axis.horizontal,
scrollDirection: Axis.horizontal, shrinkWrap: true,
shrinkWrap: true, physics: ScrollPhysics(),
physics: ScrollPhysics(), // physics: NeverScrollableScrollPhysics(),
// physics: NeverScrollableScrollPhysics(), itemCount: model.prescriptionsList.length,
itemCount: model.prescriptionsList.length, itemBuilder: (context, index) {
itemBuilder: (context, index) { return Container(
return Container( height: MediaQuery.of(context).size.height * 0.3,
height: MediaQuery.of(context).size.height * 0.3, padding: EdgeInsets.only(
padding: EdgeInsets.only( bottom: 5.0, left: 5.0, right: 8.0),
bottom: 5.0, left: 5.0, right: 8.0), margin: EdgeInsets.only(right: 10.0),
margin: EdgeInsets.only(right: 10.0), decoration: BoxDecoration(
decoration: BoxDecoration( border: Border.all(
border: Border.all( color: Colors.grey,
color: Colors.grey, style: BorderStyle.solid,
style: BorderStyle.solid, width: 1.0,
width: 1.0, ),
), color: Colors.white,
color: Colors.white, borderRadius: BorderRadius.circular(10.0)),
borderRadius: BorderRadius.circular(10.0)), child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ Row(
Row( children: <Widget>[
children: <Widget>[ Column(children: [
Column(children: [ Container(
Container( padding: EdgeInsets.only(
padding: EdgeInsets.only( top: 10.0,
top: 10.0, left: 10.0,
left: 10.0, right: 10.0,
right: 10.0, bottom: 15.0,
bottom: 15.0, ),
), child: CircleAvatar(
child: CircleAvatar( radius: 30,
radius: 30, backgroundColor:
backgroundColor: Colors.transparent, Colors.transparent,
child: Image.network( child: Image.network(
model.prescriptionsList[index] model.prescriptionsList[index]
.doctorImageURL, .doctorImageURL,
width: 60, width: 60,
height: 60, height: 60,
),
), ),
), ),
), ]),
]), Column(
Column( children: [
children: [ Container(
Container( margin:
margin: EdgeInsets.only(left: 1), EdgeInsets.only(left: 1),
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: 15.0, right: 15.0), left: 15.0, right: 15.0),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: Colors.green,
style: BorderStyle.solid,
width: 4.0,
),
color: Colors.green, color: Colors.green,
style: BorderStyle.solid, borderRadius:
width: 4.0, BorderRadius.circular(
30.0)),
child: Text(
model.languageID == "ar"
? model
.prescriptionsList[
index]
.isInOutPatientDescriptionN
.toString()
: model
.prescriptionsList[
index]
.isInOutPatientDescription
.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 15.0,
), ),
color: Colors.green, )),
borderRadius: Row(children: <Widget>[
BorderRadius.circular( Image.asset(
30.0)), 'assets/images/Icon-awesome-calendar.png',
child: Text( width: 30,
model.languageID == "ar" height: 30,
? model ),
.prescriptionsList[ Text(
index] DateUtil.convertStringToDate(
.isInOutPatientDescriptionN model
.toString() .prescriptionsList[
: model index]
.prescriptionsList[ .appointmentDate
index] .toString())
.isInOutPatientDescription .toString()
.toString(), .substring(0, 10),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.black,
fontSize: 15.0, fontSize: 15.0,
), ),
)), )
Row(children: <Widget>[ ]),
Image.asset( ],
'assets/images/Icon-awesome-calendar.png', ),
width: 30, ],
height: 30, ),
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( Text(
DateUtil.convertStringToDate(model model.prescriptionsList[index]
.prescriptionsList[index] .doctorName
.appointmentDate .toString(),
.toString())
.toString()
.substring(0, 10),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 15.0, fontSize: 15.0,
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( ),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Text(
model.prescriptionsList[index] model.prescriptionsList[index]
.doctorName .clinicDescription
.toString(), .toString(),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.green,
fontSize: 15.0, 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, // fontWeight: FontWeight.bold,
),
), ),
), ),
), ],
], ),
), Row(
Row( crossAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ Container(
Container( margin: EdgeInsets.only(left: 5),
margin: EdgeInsets.only(left: 5), child: Align(
child: Align( alignment: Alignment.topLeft,
alignment: Alignment.topLeft, child: RatingBar.readOnly(
child: RatingBar.readOnly( initialRating: model
initialRating: model .prescriptionsList[index]
.prescriptionsList[index] .actualDoctorRate
.actualDoctorRate .toDouble(),
.toDouble(),
// initialRating: productRate, // initialRating: productRate,
size: 15.0, size: 15.0,
filledColor: Colors.yellow[700], filledColor: Colors.yellow[700],
emptyColor: Colors.grey[500], emptyColor: Colors.grey[500],
isHalfAllowed: true, isHalfAllowed: true,
halfFilledIcon: Icons.star_half, halfFilledIcon: Icons.star_half,
filledIcon: Icons.star, filledIcon: Icons.star,
emptyIcon: Icons.star, emptyIcon: Icons.star,
),
), ),
), )
) ]),
]), ]),
]), );
); }),
}), ),
), ],
], ),
), ),
) )
: Container(), : Container(),
@ -604,6 +577,65 @@ class RecentlyViewedWidget extends StatelessWidget {
} }
} }
class BestSellerWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BaseView<BestSellerViewModel>(
onModelReady: (model) => model.getBestSellerProducts(),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true,
baseViewModel: model,
child: Container(
child: Column(
children: [
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).bestSellers,
bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
borderColor: Colors.green,
textColor: Colors.green,
vPadding: 6,
hPadding: 4,
handler: () => {
Navigator.push(
context,
FadePage(
page: FinalProductsPage(
id: "",
productType: 20,
),
),
),
},
),
],
),
),
Container(
height: MediaQuery.of(context).size.height / 4 + 20,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ProductTileItem(model.bestSellerProduct[i]),
scrollDirection: Axis.horizontal,
itemCount: model.bestSellerProduct.length,
),
),
],
),
),
));
}
}
// Container( // Container(
// margin: EdgeInsets.fromLTRB(10, 10, 10, 10), // margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
// child: Row( // child: Row(

@ -50,7 +50,7 @@ class _NetworkBaseViewState extends State<NetworkBaseView>{
child:CircularProgressIndicator( child:CircularProgressIndicator(
backgroundColor: Colors.white, backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>( valueColor: AlwaysStoppedAnimation<Color>(
Colors.red, Colors.grey[500],
), ),
), ),
), ),

Loading…
Cancel
Save