make pharmacy home page load data even without login, and some mini changes

merge-update-with-lab-changes
mosazaid 5 years ago
parent 257dc3d76d
commit 4c9a1862d2

@ -268,6 +268,7 @@ class BaseAppClient {
logout() async {
await sharedPref.remove(LOGIN_TOKEN_ID);
await sharedPref.remove(PHARMACY_CUSTOMER_ID);
await authenticatedUserObject.getUser();
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin =
false;

@ -17,8 +17,7 @@ class PharmacyModuleService extends BaseService {
List<PharmacyProduct> bestSellerProducts = List();
List<PharmacyProduct> lastVisitedProducts = List();
Future makeVerifyCustomer() async {
var data = await sharedPref.getObject(USER_PROFILE);
Future makeVerifyCustomer(dynamic data) async {
Map<String, String> queryParams = {'FileNumber': data['PatientID'].toString()};
hasError = false;
try {

@ -23,19 +23,31 @@ class PharmacyModuleViewModel extends BaseViewModel {
Future getPharmacyHomeData() async {
setState(ViewState.Busy);
await _pharmacyService.makeVerifyCustomer();
// here must call getShoppingCard()
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
await _pharmacyService.getBannerListList();
var data = await sharedPref.getObject(USER_PROFILE);
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
if (authenticatedUserObject.isLogin && data != null && customerId == null) {
await _pharmacyService.makeVerifyCustomer(data);
// here must call getShoppingCard()
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
_getTopManufacturerList();
await getBannerList();
}
} else {
await getBannerList();
}
}
Future getBannerList() async {
setState(ViewState.Busy);
await _pharmacyService.getBannerListList();
if (_pharmacyService.hasError) {
error = _pharmacyService.error;
setState(ViewState.Error);
} else {
_getTopManufacturerList();
}
}

@ -17,8 +17,9 @@ class CartOrderPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
PreferredSizeWidget appBarWidget =
AppBarWidget("Shopping Cart", null, true);
AppBarWidget(TranslationBase.of(context).shoppingCart, null, true);
final height = mediaQuery.size.height -
appBarWidget.preferredSize.height -
mediaQuery.padding.top;

@ -28,7 +28,7 @@ class LakumTermsConditions extends StatelessWidget {
return BaseView<LacumRegistrationViewModel>(
onModelReady: (model) => model.getUserTermsAndConditionsForEPharmcy(),
builder: (_, model, wi) => AppScaffold(
title: "Register Lakum",
appBarTitle: "Register Lakum",
isShowAppBar: true,
isShowDecPage: false,
backgroundColor: Colors.white,

@ -16,7 +16,7 @@ class PharmacyTermsConditions extends StatelessWidget {
return BaseView<TermsConditionViewModel>(
onModelReady: (model) => model.getUserTermsAndConditionsForEPharmcy(),
builder: (_, model, wi) => AppScaffold(
title: TranslationBase.of(context).termOfService,
appBarTitle: TranslationBase.of(context).termOfService,
isShowAppBar: true,
isShowDecPage: false,
isPharmacy: true,

@ -21,6 +21,7 @@ class PharmacyPage extends StatelessWidget {
Widget build(BuildContext context) {
return BaseView<PharmacyModuleViewModel>(
onModelReady: (model) => model.getPharmacyHomeData(),
allowAny: true,
builder: (_, model, wi) => AppScaffold(
title: "",
isShowAppBar: true,

@ -1022,7 +1022,7 @@ class TranslationBase {
String get point => localizedValues['point'][locale.languageCode];
String get riyal => localizedValues['riyal'][locale.languageCode];
String get termOfService => localizedValues['termOfService'][locale.languageCode];
String get shoppingCart => localizedValues['ShoppingCart'][locale.languageCode];
String get shoppingCart => localizedValues['shoppingCart'][locale.languageCode];
String get referralStatus =>
localizedValues['referralStatus'][locale.languageCode];

Loading…
Cancel
Save