fix bugs pharmacy home

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

@ -9,36 +9,15 @@ class PrescriptionService extends BaseService {
bool isFinished = true; bool isFinished = true;
bool hasError = false; bool hasError = false;
String errorMsg = ''; String errorMsg = '';
String url = "";
List<Prescriptions> _prescriptionsList = List(); List<Prescriptions> _prescriptionsList = List();
List<Prescriptions> get prescriptionsList => _prescriptionsList; List<Prescriptions> get prescriptionsList => _prescriptionsList;
// Future getPrescription() async {
// hasError = false;
// url = PRESCRIPTION;
// print("Print PRESCRIPTION url" + url);
// await baseAppClient.get(url,
// onSuccess: (dynamic response, int statusCode) {
// _prescriptionsList.clear();
// response['PatientPrescriptionList'].forEach((item) {
// _prescriptionsList.add(Prescriptions.fromJson(item));
// });
// print(_prescriptionsList.length);
// print(response);
// }, onFailure: (String error, int statusCode) {
// hasError = true;
// super.error = error;
// });
// }
Future getPrescription() async { Future getPrescription() async {
url = PRESCRIPTION;
print("Print PRESCRIPTION url" + url);
hasError = false; hasError = false;
Map<String, dynamic> body = Map(); Map<String, dynamic> body = Map();
body['isDentalAllowedBackend'] = false; body['isDentalAllowedBackend'] = false;
print("Print PRESCRIPTION url" + url); await baseAppClient.post(PRESCRIPTION,
await baseAppClient.post(url,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
_prescriptionsList.clear(); _prescriptionsList.clear();
response['PatientPrescriptionList'].forEach((prescriptions) { response['PatientPrescriptionList'].forEach((prescriptions) {

@ -15,6 +15,7 @@ class BaseViewModel extends ChangeNotifier {
ViewState get state => _state; ViewState get state => _state;
String error = ""; String error = "";
String languageID = "en";
AuthenticatedUser user; AuthenticatedUser user;
AppSharedPreferences sharedPref = AppSharedPreferences(); AppSharedPreferences sharedPref = AppSharedPreferences();
@ -51,6 +52,10 @@ class BaseViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future getSavedLanguage() async {
languageID = await sharedPref.getString(APP_LANGUAGE);
}
@override @override
void dispose() { void dispose() {
removeListener(() {}); removeListener(() {});

@ -0,0 +1,5 @@
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
class BestSellerViewModel extends BaseViewModel {
}

@ -0,0 +1,29 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Manufacturer.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import '../../../locator.dart';
class BrandViewModel extends BaseViewModel {
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
List<Manufacturer> get manufacturerList => _pharmacyService.manufacturerList;
Future getTopManufacturerList() async {
setState(ViewState.Busy);
await _pharmacyService.getTopManufacturerList();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
@override
void dispose() {
super.dispose();
}
}

@ -0,0 +1,25 @@
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 '../../../locator.dart';
class LastVisitedViewModel extends BaseViewModel {
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
List<PharmacyProduct> get lastVisitedProducts =>
_pharmacyService.lastVisitedProducts;
getLastVisitedProducts() async {
setState(ViewState.Busy);
await _pharmacyService.getLastVisitedProducts();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
}

@ -0,0 +1,30 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:provider/provider.dart';
import '../../../locator.dart';
import '../project_view_model.dart';
class PrescriptionViewModel extends BaseViewModel {
PrescriptionService _prescriptionService = locator<PrescriptionService>();
List<Prescriptions> get prescriptionsList =>
_prescriptionService.prescriptionsList;
getPrescription() async {
await getSavedLanguage();
/*
setState(ViewState.Busy);
await _prescriptionService.getPrescription();
if (_prescriptionService.hasError) {
error = _prescriptionService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}*/
}
}

@ -19,36 +19,26 @@ class PharmacyModuleViewModel extends BaseViewModel {
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>(); PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
PrescriptionService _prescriptionService = locator<PrescriptionService>();
dynamic languageID = "en";
RecommendedProductService _recommendedProductService = locator<RecommendedProductService>(); RecommendedProductService _recommendedProductService = locator<RecommendedProductService>();
List<PharmacyImageObject> get bannerList => _pharmacyService.bannerItems; List<PharmacyImageObject> get bannerList => _pharmacyService.bannerItems;
List<Manufacturer> get manufacturerList => _pharmacyService.manufacturerList;
List<PharmacyProduct> get bestSellerProduct => List<PharmacyProduct> get bestSellerProduct =>
_pharmacyService.bestSellerProducts; _pharmacyService.bestSellerProducts;
List<PharmacyProduct> get lastVisitedProducts =>
_pharmacyService.lastVisitedProducts;
List <RecommendedProductModel> get recommendedProductList => List <RecommendedProductModel> get recommendedProductList =>
_recommendedProductService.recommendedList; _recommendedProductService.recommendedList;
// List<Map<String, dynamic>> get recommendedProductList =>
// _recommendedProductService.recommendedList;
List<Prescriptions> get prescriptionsList =>
_prescriptionService.prescriptionsList;
bool hasError = false;
// List<PharmacyProduct> get pharmacyPrescriptionsList => PharmacyProduct.pharmacyPrescriptionsList ;
Future getLanguageID() async { Future getBannerList() async {
languageID = await sharedPref.getString(APP_LANGUAGE); setState(ViewState.BusyLocal);
await _pharmacyService.getBannerListList();
if (_pharmacyService.hasError)
//{
error = _pharmacyService.error;
// setState(ViewState.Error);
// }else
// setState(ViewState.Idle);
} }
Future getPharmacyHomeData() async { Future getPharmacyHomeData() async {
@ -64,11 +54,7 @@ class PharmacyModuleViewModel extends BaseViewModel {
if (_pharmacyService.hasError) { if (_pharmacyService.hasError) {
error = _pharmacyService.error; error = _pharmacyService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else {
await getBannerList();
} }
} else {
await getBannerList();
} }
} }
@ -82,7 +68,6 @@ class PharmacyModuleViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
Future generatePharmacyToken() async { Future generatePharmacyToken() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _pharmacyService.generatePharmacyToken(); await _pharmacyService.generatePharmacyToken();
@ -94,16 +79,6 @@ class PharmacyModuleViewModel extends BaseViewModel {
} }
} }
Future getBannerList() async {
setState(ViewState.Busy);
await _pharmacyService.getBannerListList();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
_getTopManufacturerList();
}
}
List<String> getBannerImagesUrl() { List<String> getBannerImagesUrl() {
List<String> images = List(); List<String> images = List();
@ -115,40 +90,18 @@ class PharmacyModuleViewModel extends BaseViewModel {
return images; return images;
} }
_getTopManufacturerList() async { getBestSellerProducts() async {
await _pharmacyService.getTopManufacturerList();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
_getBestSellerProducts();
}
}
_getBestSellerProducts() async {
await _pharmacyService.getBestSellerProducts(); await _pharmacyService.getBestSellerProducts();
if (_pharmacyService.hasError) { if (_pharmacyService.hasError) {
error = _pharmacyService.error; error = _pharmacyService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else { } else {
_getLastVisitedProducts();
} }
} }
_getLastVisitedProducts() async {
await _pharmacyService.getLastVisitedProducts();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
//////////////////////////////////////////RecommendedProducts
getRecommendedProducts(productId) async { getRecommendedProducts(productId) async {
hasError = false;
setState(ViewState.Busy); setState(ViewState.Busy);
await _recommendedProductService.getRecommendedProducts(productId); await _recommendedProductService.getRecommendedProducts(productId);
if (_recommendedProductService.hasError) { if (_recommendedProductService.hasError) {
@ -173,18 +126,6 @@ class PharmacyModuleViewModel extends BaseViewModel {
} }
} }
getPrescription() async {
print("Print PRESCRIPTION url");
setState(ViewState.Busy);
await _prescriptionService.getPrescription();
if (_prescriptionService.hasError) {
error = _prescriptionService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
///////////////////////or ///////////////////////or
// getPrescriptions() async { // getPrescriptions() async {

@ -120,6 +120,10 @@ import 'core/viewModels/pharmacies_view_model.dart';
import 'core/service/pharmacies_service.dart'; import 'core/service/pharmacies_service.dart';
import 'core/service/insurance_service.dart'; import 'core/service/insurance_service.dart';
import 'core/viewModels/insurance_card_View_model.dart'; import 'core/viewModels/insurance_card_View_model.dart';
import 'core/viewModels/pharmacyModule/BestSellerViewModel.dart';
import 'core/viewModels/pharmacyModule/BrandViewModel.dart';
import 'core/viewModels/pharmacyModule/LastVisitedViewModel.dart';
import 'core/viewModels/pharmacyModule/PrescriptionViewModel.dart';
import 'core/viewModels/pharmacyModule/brand_view_model.dart'; import 'core/viewModels/pharmacyModule/brand_view_model.dart';
import 'core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'core/viewModels/pharmacyModule/pharmacy_module_view_model.dart';
import 'core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'core/viewModels/pharmacyModule/product_detail_view_model.dart';
@ -302,6 +306,11 @@ void setupLocator() {
locator.registerFactory(() => OffersCategoriseViewModel()); locator.registerFactory(() => OffersCategoriseViewModel());
locator.registerFactory(() => BariatricsViewModel()); locator.registerFactory(() => BariatricsViewModel());
locator.registerFactory(() => PrescriptionViewModel());
locator.registerFactory(() => BrandViewModel());
locator.registerFactory(() => BestSellerViewModel());
locator.registerFactory(() => LastVisitedViewModel());
// Offer And Packages // Offer And Packages
//---------------------- //----------------------
locator.registerLazySingleton( locator.registerLazySingleton(

@ -172,7 +172,7 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode",
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
print(response); print(response);
product = PharmacyProduct.fromJson(response["products"][0]); var product = PharmacyProduct.fromJson(response["products"][0]);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: ProductDetailPage(product))); Navigator.push(context, FadePage(page: ProductDetailPage(product)));
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {

@ -1,50 +1,46 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; import 'package:diplomaticquarterapp/pages/landing/home_page.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart';
import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-activitaion-vida-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/BannerPager.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/BannerPager.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart'; import 'package:rating_bar/rating_bar.dart';
import '../../final_products_page.dart'; import '../../final_products_page.dart';
import 'lacum-activitaion-vida-page.dart';
var product;
class PharmacyPage extends StatefulWidget { class PharmacyPage extends StatefulWidget {
@override @override
_PharmacyPageState createState() => _PharmacyPageState(); _PharmacyPageState createState() => _PharmacyPageState();
} }
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 {
await getLanguageID(); // GifLoaderDialogUtils.showMyDialog(context);
await model.getPharmacyHomeData(); await model.getSavedLanguage();
await model.getBannerList();
// GifLoaderDialogUtils.hideDialog(context);
}, },
allowAny: true, allowAny: true,
builder: (_, model, wi) => AppScaffold( builder: (_, model, wi) => AppScaffold(
@ -57,17 +53,21 @@ class _PharmacyPageState extends State<PharmacyPage> {
width: double.infinity, width: double.infinity,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, //crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
BannerPager(model), BannerPager(model),
GridViewButtons(model), GridViewButtons(model),
//PrescriptionsWidget(),
ShopByBrandWidget(),
RecentlyViewedWidget(),
// TODO MOUSA
Container( Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10), margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Texts( Texts(
TranslationBase.of(context).myPrescription, TranslationBase.of(context).bestSellers,
bold: true, bold: true,
), ),
BorderedButton( BorderedButton(
@ -77,30 +77,233 @@ class _PharmacyPageState extends State<PharmacyPage> {
textColor: Colors.green, textColor: Colors.green,
vPadding: 6, vPadding: 6,
hPadding: 4, hPadding: 4,
handler: () { handler: () => {
Navigator.push( Navigator.push(
context, FadePage(page: HomePrescriptionsPage())); context,
FadePage(
page: FinalProductsPage(
id: "",
//TODO Elham* handel this to understans form where the number comming
productType: 20,
),
),
),
}, },
), ),
], ],
), ),
), ),
Container( 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,
),
),
],
),
),
),
),
);
}
}
class GridViewButtons extends StatelessWidget {
final PharmacyModuleViewModel model;
GridViewButtons(this.model);
@override
Widget build(BuildContext context) {
final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8;
return Container(
child: SizedBox(
height: gridHeight,
child: GridView.count(
childAspectRatio: 2.2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
controller: new ScrollController(keepScrollOffset: false),
shrinkWrap: true,
padding: const EdgeInsets.all(4.0),
crossAxisCount: 2,
children: [
DashboardItem(
imageName: 'pharmacy_module/bg_1.png',
hasColorFilter: false,
opacity: 0.8,
child: GridViewCard(
TranslationBase.of(context).offersAndPromotions,
'assets/images/pharmacy_module/offer_icon.png', () {
Navigator.push(context, FadePage(page: OffersCategorisePage()));
}),
),
DashboardItem(
imageName: 'pharmacy_module/bg_2.png',
opacity: 0,
hasColorFilter: false,
child: GridViewCard(TranslationBase.of(context).medicationRefill,
'assets/images/pharmacy_module/medication_icon.png', () {
// model.checkUserIsActivated().then((isActivated) {
// if (isActivated) {
// Navigator.push(context, FadePage(page: LakumMainPage()));
// } else {
// Navigator.push(
// context, FadePage(page: LakumActivationVidaPage()));
// }
// });
}),
),
DashboardItem(
imageName: 'pharmacy_module/bg_3.png',
opacity: 0,
hasColorFilter: false,
child: GridViewCard(TranslationBase.of(context).myPrescriptions,
'assets/images/pharmacy_module/prescription_icon.png', () {
Navigator.push(
context, FadePage(page: HomePrescriptionsPage()));
}),
),
DashboardItem(
imageName: 'pharmacy_module/bg_4.png',
opacity: 0,
hasColorFilter: false,
child: GridViewCard(
TranslationBase.of(context).searchAndScanMedication,
'assets/images/pharmacy_module/search_scan_icon.png',
() {}),
),
],
),
),
);
}
}
class GridViewCard extends StatelessWidget {
final String text;
final String cardImage;
final Function handler;
GridViewCard(this.text, this.cardImage, this.handler);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(4.0),
child: Container(
child: Row(
children: [
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.all(6),
child: Texts(
text,
color: Colors.white,
fontSize: SizeConfig.textMultiplier * 1.5,
),
),
),
Row(
children: [
BorderedButton(
TranslationBase.of(context).viewAll,
handler: handler,
tPadding: 0,
bPadding: 0,
),
Expanded(child: Container()),
],
),
],
),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Image.asset(
cardImage,
fit: BoxFit.cover,
),
),
),
],
),
),
);
}
String getDate(String date) {
DateTime dateObj = DateUtil.convertStringToDate(date);
return DateUtil.getWeekDay(dateObj.weekday) +
", " +
dateObj.day.toString() +
" " +
DateUtil.getMonth(dateObj.month) +
" " +
dateObj.year.toString();
}
}
class PrescriptionsWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BaseView<PrescriptionViewModel>(
onModelReady: (model) async {
if (Provider.of<ProjectViewModel>(context, listen: false).isLogin) {
model.getPrescription();
}
},
allowAny: true,
builder: (_, model, wi) => model.prescriptionsList.length != 0
? Container(
height: model.prescriptionsList.length > 0 height: model.prescriptionsList.length > 0
? MediaQuery.of(context).size.height * 0.28 ? MediaQuery.of(context).size.height * 0.28
: 0, : 0,
child: Column(
children: [
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).myPrescription,
bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
borderColor: Colors.green,
textColor: Colors.green,
vPadding: 6,
hPadding: 4,
handler: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
HomePrescriptionsPage()));
},
),
],
),
),
Container(
padding: padding:
EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0),
// height: MediaQuery.of(context).size.height * 0.28,
// width: 200.0,
// height: MediaQuery.of(context).size.height / 4 + 20,
margin: EdgeInsets.only(left: 10), margin: EdgeInsets.only(left: 10),
child: BaseView<PharmacyModuleViewModel>( child: ListView.builder(
onModelReady: (model) => model.getPrescription(),
builder: (_, model, wi) => model.prescriptionsList.length !=
0
// model.getPrescription();
? ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
shrinkWrap: true, shrinkWrap: true,
physics: ScrollPhysics(), physics: ScrollPhysics(),
@ -108,9 +311,7 @@ class _PharmacyPageState extends State<PharmacyPage> {
itemCount: model.prescriptionsList.length, itemCount: model.prescriptionsList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Container( return Container(
// width: 160.0, 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),
@ -123,8 +324,7 @@ class _PharmacyPageState extends State<PharmacyPage> {
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(10.0)), borderRadius: BorderRadius.circular(10.0)),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Row( Row(
children: <Widget>[ children: <Widget>[
@ -138,8 +338,7 @@ class _PharmacyPageState extends State<PharmacyPage> {
), ),
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,
@ -149,38 +348,16 @@ class _PharmacyPageState extends State<PharmacyPage> {
), ),
), ),
]), ]),
// Column(
// // crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Container(
// margin: EdgeInsets.only(left: 1),
// padding: EdgeInsets.only(
// top: 10.0,
// left: 10.0,
// right: 3.0,
// bottom: 15.0,
// ),
// child: Image.network(
// model.prescriptionsList[index]
// .doctorImageURL,
// width: 60,
// height: 60,
// ),
// ),
// ]),
Column( Column(
// crossAxisAlignment: CrossAxisAlignment.center,
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, color: Colors.green,
style: style: BorderStyle.solid,
BorderStyle.solid,
width: 4.0, width: 4.0,
), ),
color: Colors.green, color: Colors.green,
@ -189,12 +366,19 @@ class _PharmacyPageState extends State<PharmacyPage> {
30.0)), 30.0)),
child: Text( child: Text(
model.languageID == "ar" model.languageID == "ar"
? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() ? model
: model.prescriptionsList[index].isInOutPatientDescription.toString(), .prescriptionsList[
index]
.isInOutPatientDescriptionN
.toString()
: model
.prescriptionsList[
index]
.isInOutPatientDescription
.toString(),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 15.0, fontSize: 15.0,
// fontWeight: FontWeight.bold,
), ),
)), )),
Row(children: <Widget>[ Row(children: <Widget>[
@ -204,10 +388,8 @@ class _PharmacyPageState extends State<PharmacyPage> {
height: 30, height: 30,
), ),
Text( Text(
DateUtil.convertStringToDate( DateUtil.convertStringToDate(model
model .prescriptionsList[index]
.prescriptionsList[
index]
.appointmentDate .appointmentDate
.toString()) .toString())
.toString() .toString()
@ -215,7 +397,6 @@ class _PharmacyPageState extends State<PharmacyPage> {
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 15.0, fontSize: 15.0,
// fontWeight: FontWeight.bold,
), ),
) )
]), ]),
@ -288,12 +469,10 @@ class _PharmacyPageState extends State<PharmacyPage> {
.toDouble(), .toDouble(),
// initialRating: productRate, // initialRating: productRate,
size: 15.0, size: 15.0,
filledColor: filledColor: Colors.yellow[700],
Colors.yellow[700],
emptyColor: Colors.grey[500], emptyColor: Colors.grey[500],
isHalfAllowed: true, isHalfAllowed: true,
halfFilledIcon: halfFilledIcon: Icons.star_half,
Icons.star_half,
filledIcon: Icons.star, filledIcon: Icons.star,
emptyIcon: Icons.star, emptyIcon: Icons.star,
), ),
@ -302,36 +481,155 @@ class _PharmacyPageState extends State<PharmacyPage> {
]), ]),
]), ]),
); );
}) }),
: Container(),
), ),
],
), ),
// Container( )
// margin: EdgeInsets.fromLTRB(10, 10, 10, 10), : Container(),
// child: Row( );
// mainAxisAlignment: MainAxisAlignment.spaceBetween, }
// children: [ }
// Texts(
// TranslationBase.of(context).recommended, class ShopByBrandWidget extends StatelessWidget {
// bold: true, @override
// ), Widget build(BuildContext context) {
// BorderedButton( return BaseView<BrandViewModel>(
// TranslationBase.of(context).viewAll, onModelReady: (model) => model.getTopManufacturerList(),
// hasBorder: true, allowAny: true,
// borderColor: Colors.green, builder: (_, model, wi) => NetworkBaseView(
// textColor: Colors.green, isLocalLoader: true,
// vPadding: 6, baseViewModel: model,
// hPadding: 4, child: Container(
// handler: () { child: Column(
// Navigator.push( children: [
// context, Container(
// MaterialPageRoute( margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
// builder: (context) => child: Row(
// RecommendedProductPage(productId : "2316"))); mainAxisAlignment: MainAxisAlignment.spaceBetween,
// }, children: [
// ), Texts(
// ], TranslationBase.of(context).shopByBrands,
// ), bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
vPadding: 6,
hPadding: 4,
borderColor: Colors.green,
textColor: Colors.green,
handler: () => {
Navigator.push(
context, FadePage(page: ProductBrandsPage())),
},
),
],
),
),
Container(
height: 100,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ManufacturerItem(model.manufacturerList[i]),
scrollDirection: Axis.horizontal,
itemCount: model.manufacturerList.length,
),
),
],
),
),
));
}
}
class RecentlyViewedWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BaseView<LastVisitedViewModel>(
onModelReady: (model) => model.getLastVisitedProducts(),
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).recentlyViewed,
bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
vPadding: 6,
hPadding: 4,
borderColor: Colors.green,
textColor: Colors.green,
handler: () {
Navigator.push(
context,
FadePage(
page: FinalProductsPage(
id: "",
productType: 3,
),
),
);
},
),
],
),
),
Container(
height: model.lastVisitedProducts.length > 0
? MediaQuery.of(context).size.height / 4 + 20
: 0,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ProductTileItem(model.lastVisitedProducts[i]),
scrollDirection: Axis.horizontal,
itemCount: model.lastVisitedProducts.length,
),
),
],
),
),
));
}
}
// Container(
// margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Texts(
// TranslationBase.of(context).recommended,
// bold: true,
// ),
// BorderedButton(
// TranslationBase.of(context).viewAll,
// hasBorder: true,
// borderColor: Colors.green,
// textColor: Colors.green,
// vPadding: 6,
// hPadding: 4,
// handler: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// RecommendedProductPage(productId : "2316")));
// },
// ),
// ],
// ),
// ), // ),
// Container( // Container(
// height: model.recommendedProductList.length > 0 // height: model.recommendedProductList.length > 0
@ -538,284 +836,3 @@ class _PharmacyPageState extends State<PharmacyPage> {
// ), // ),
// ), // ),
// ), // ),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).shopByBrands,
bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
vPadding: 6,
hPadding: 4,
borderColor: Colors.green,
textColor: Colors.green,
handler: () => {
Navigator.push(
context, FadePage(page: ProductBrandsPage())),
},
),
],
),
),
Container(
height: 100,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ManufacturerItem(model.manufacturerList[i]),
scrollDirection: Axis.horizontal,
itemCount: model.manufacturerList.length,
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
TranslationBase.of(context).recentlyViewed,
bold: true,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
vPadding: 6,
hPadding: 4,
borderColor: Colors.green,
textColor: Colors.green,
handler: () {
Navigator.push(
context,
FadePage(
page: FinalProductsPage(
id: "",
productType: 3,
),
),
);
},
),
],
),
),
Container(
height: model.lastVisitedProducts.length > 0
? MediaQuery.of(context).size.height / 4 + 20
: 0,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ProductTileItem(model.lastVisitedProducts[i]),
scrollDirection: Axis.horizontal,
itemCount: model.lastVisitedProducts.length,
),
),
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,
),
),
],
),
),
),
),
);
}
addToWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
isInWishlist = true;
await x.addToWishlistData(itemID);
}
deleteFromWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
isInWishlist = false;
await x.addToWishlistData(itemID);
}
}
class GridViewButtons extends StatelessWidget {
final PharmacyModuleViewModel model;
GridViewButtons(this.model);
@override
Widget build(BuildContext context) {
final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8;
return Container(
child: SizedBox(
height: gridHeight,
child: GridView.count(
childAspectRatio: 2.2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
controller: new ScrollController(keepScrollOffset: false),
shrinkWrap: true,
padding: const EdgeInsets.all(4.0),
crossAxisCount: 2,
children: [
DashboardItem(
imageName: 'pharmacy_module/bg_1.png',
hasColorFilter: false,
opacity: 0.8,
child: GridViewCard(
TranslationBase.of(context).offersAndPromotions,
'assets/images/pharmacy_module/offer_icon.png', () {
Navigator.push(context, FadePage(page: OffersCategorisePage()));
}),
),
DashboardItem(
imageName: 'pharmacy_module/bg_2.png',
opacity: 0,
hasColorFilter: false,
child: GridViewCard(TranslationBase.of(context).medicationRefill,
'assets/images/pharmacy_module/medication_icon.png', () {
model.checkUserIsActivated().then((isActivated) {
if (isActivated) {
Navigator.push(context, FadePage(page: LakumMainPage()));
} else {
Navigator.push(
context, FadePage(page: LakumActivationVidaPage()));
}
});
}),
),
DashboardItem(
imageName: 'pharmacy_module/bg_3.png',
opacity: 0,
hasColorFilter: false,
child: GridViewCard(TranslationBase.of(context).myPrescriptions,
'assets/images/pharmacy_module/prescription_icon.png', () {
Navigator.push(
context, FadePage(page: PharmacyAddressesPage()));
}),
),
DashboardItem(
imageName: 'pharmacy_module/bg_4.png',
opacity: 0,
hasColorFilter: false,
child: GridViewCard(
TranslationBase.of(context).searchAndScanMedication,
'assets/images/pharmacy_module/search_scan_icon.png',
() {}),
),
],
),
),
);
}
}
class GridViewCard extends StatelessWidget {
final String text;
final String cardImage;
final Function handler;
GridViewCard(this.text, this.cardImage, this.handler);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(4.0),
child: Container(
child: Row(
children: [
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.all(6),
child: Texts(
text,
color: Colors.white,
fontSize: SizeConfig.textMultiplier * 1.5,
),
),
),
Row(
children: [
BorderedButton(
TranslationBase.of(context).viewAll,
handler: handler,
tPadding: 0,
bPadding: 0,
),
Expanded(child: Container()),
],
),
],
),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Image.asset(
cardImage,
fit: BoxFit.cover,
),
),
),
],
),
),
);
}
String getDate(String date) {
DateTime dateObj = DateUtil.convertStringToDate(date);
return DateUtil.getWeekDay(dateObj.weekday) +
", " +
dateObj.day.toString() +
" " +
DateUtil.getMonth(dateObj.month) +
" " +
dateObj.year.toString();
}
}

@ -9,8 +9,9 @@ import 'package:flutter_gifimage/flutter_gifimage.dart';
class NetworkBaseView extends StatefulWidget { class NetworkBaseView extends StatefulWidget {
final BaseViewModel baseViewModel; final BaseViewModel baseViewModel;
final Widget child; final Widget child;
final bool isLocalLoader;
NetworkBaseView({Key key, this.baseViewModel, this.child}); NetworkBaseView({Key key, this.baseViewModel, this.child, this.isLocalLoader = false});
@override @override
_NetworkBaseViewState createState() => _NetworkBaseViewState(); _NetworkBaseViewState createState() => _NetworkBaseViewState();
@ -42,7 +43,19 @@ class _NetworkBaseViewState extends State<NetworkBaseView>{
return widget.child; return widget.child;
break; break;
case ViewState.Busy: case ViewState.Busy:
if(widget.isLocalLoader)
return Container( return Container(
height: 100,
child: Center(
child:CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.red,
),
),
),
);
else return Container(
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
child: Stack( child: Stack(

Loading…
Cancel
Save