Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into fix_product_tile

merge-update-with-lab-changes
Mohammad Aljammal 5 years ago
commit b175fb7ce0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -108,10 +108,10 @@ class PharmacyProduct {
List<int> manufacturerIds; List<int> manufacturerIds;
List<Reviews> reviews; List<Reviews> reviews;
List<PharmacyImageObject> images; List<PharmacyImageObject> images;
List<String> attributes; List<dynamic> attributes;
List<Specifications> specifications; List<Specifications> specifications;
List<String> associatedProductIds; List<dynamic> associatedProductIds;
List<String> tags; List<dynamic> tags;
int vendorId; int vendorId;
String seName; String seName;
@ -367,7 +367,7 @@ class PharmacyProduct {
}); });
} }
if (json['attributes'] != null) { if (json['attributes'] != null) {
attributes = new List<String>(); attributes = new List<dynamic>();
json['attributes'].forEach((v) { json['attributes'].forEach((v) {
attributes.add(v); attributes.add(v);
}); });

@ -785,7 +785,8 @@ class BaseAppClient {
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
print("statusCode :$statusCode"); print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure('Error While Fetching data', statusCode); var parsed = json.decode(utf8.decode(response.bodyBytes));
onFailure(parsed['error']['ErrorEndUserMsg'] ??'Error While Fetching data', statusCode);
} else { } else {
// var parsed = json.decode(response.body.toString()); // var parsed = json.decode(response.body.toString());
var parsed = json.decode(utf8.decode(response.bodyBytes)); var parsed = json.decode(utf8.decode(response.bodyBytes));

@ -113,7 +113,6 @@ class PharmacyModuleService extends BaseService {
} }
Future getTopManufacturerList() async { Future getTopManufacturerList() async {
hasError = false;
Map<String, String> queryParams = {'page': '1', 'limit': '8'}; Map<String, String> queryParams = {'page': '1', 'limit': '8'};
try { try {
await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER, await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER,
@ -125,6 +124,7 @@ class PharmacyModuleService extends BaseService {
manufacturerList.add(Manufacturer.fromJson(item)); manufacturerList.add(Manufacturer.fromJson(item));
// } // }
}); });
hasError = false;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
@ -146,6 +146,7 @@ class PharmacyModuleService extends BaseService {
response['products'].forEach((item) { response['products'].forEach((item) {
bestSellerProducts.add(PharmacyProduct.fromJson(item)); bestSellerProducts.add(PharmacyProduct.fromJson(item));
}); });
hasError = false;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
@ -161,6 +162,7 @@ class PharmacyModuleService extends BaseService {
null) { null) {
lastVisited = lastVisited =
await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
// lastVisited = "2458,4561";
try { try {
await baseAppClient await baseAppClient
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited",
@ -169,8 +171,9 @@ class PharmacyModuleService extends BaseService {
response['products'].forEach((item) { response['products'].forEach((item) {
lastVisitedProducts.add(PharmacyProduct.fromJson(item)); lastVisitedProducts.add(PharmacyProduct.fromJson(item));
}); });
hasError = false;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, "");
super.error = error; super.error = error;
}); });
} catch (error) { } catch (error) {

@ -13,14 +13,14 @@ class BestSellerViewModel extends BaseViewModel {
_pharmacyService.bestSellerProducts; _pharmacyService.bestSellerProducts;
getBestSellerProducts() async { getBestSellerProducts() async {
setState(ViewState.Busy); setState(ViewState.BusyLocal);
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 {
setState(ViewState.Idle); setState(ViewState.Idle);
} // }
} }
} }

@ -11,14 +11,14 @@ class BrandViewModel extends BaseViewModel {
List<Manufacturer> get manufacturerList => _pharmacyService.manufacturerList; List<Manufacturer> get manufacturerList => _pharmacyService.manufacturerList;
Future getTopManufacturerList() async { Future getTopManufacturerList() async {
setState(ViewState.Busy); setState(ViewState.BusyLocal);
await _pharmacyService.getTopManufacturerList(); await _pharmacyService.getTopManufacturerList();
if (_pharmacyService.hasError) { // if (_pharmacyService.hasError) {
error = _pharmacyService.error; // error = _pharmacyService.error;
setState(ViewState.Error); // setState(ViewState.Error);
} else { // } else {
setState(ViewState.Idle); setState(ViewState.Idle);
} // }
} }
@override @override

@ -13,13 +13,13 @@ class LastVisitedViewModel extends BaseViewModel {
_pharmacyService.lastVisitedProducts; _pharmacyService.lastVisitedProducts;
getLastVisitedProducts() async { getLastVisitedProducts() async {
setState(ViewState.Busy); setState(ViewState.BusyLocal);
await _pharmacyService.getLastVisitedProducts(); await _pharmacyService.getLastVisitedProducts();
if (_pharmacyService.hasError) { // if (_pharmacyService.hasError) {
error = _pharmacyService.error; // error = _pharmacyService.error;
setState(ViewState.Error); // setState(ViewState.Error);
} else { // } else {
setState(ViewState.Idle); setState(ViewState.Idle);
} // }
} }
} }

@ -40,7 +40,7 @@ class PharmacyModuleViewModel extends BaseViewModel {
} }
Future verifyCustomer() async { Future verifyCustomer() async {
if (authenticatedUserObject.isLogin) await generatePharmacyToken(); // if (authenticatedUserObject.isLogin) await generatePharmacyToken();
var data = await sharedPref.getObject(USER_PROFILE); var data = await sharedPref.getObject(USER_PROFILE);
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);

@ -825,15 +825,11 @@ class _HomePageState extends State<HomePage> {
} else { } else {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { await pharmacyModuleViewModel.generatePharmacyToken().then((value) async {
if (pharmacyModuleViewModel.error.isNotEmpty) {
await pharmacyModuleViewModel.verifyCustomer().then((value) { await pharmacyModuleViewModel.verifyCustomer().then((value) {
GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: LandingPagePharmacy()));
});
} else {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: LandingPagePharmacy())); Navigator.push(context, FadePage(page: LandingPagePharmacy()));
} });
}); });
} }
} }

@ -48,10 +48,8 @@ class _PharmacyPageState extends State<PharmacyPage> {
return BaseView<PharmacyModuleViewModel>( return BaseView<PharmacyModuleViewModel>(
onModelReady: (model) async { onModelReady: (model) async {
// GifLoaderDialogUtils.showMyDialog(context);
await model.getSavedLanguage(); await model.getSavedLanguage();
await model.getBannerList(); await model.getBannerList();
// GifLoaderDialogUtils.hideDialog(context);
}, },
allowAny: true, allowAny: true,
builder: (_, model, wi) => AppScaffold( builder: (_, model, wi) => AppScaffold(

@ -24,6 +24,7 @@ class ProductTileItem extends StatelessWidget {
void _saveLastVisitProducts() async { void _saveLastVisitProducts() async {
String lastVisited = ""; String lastVisited = "";
bool isIdExist = false; bool isIdExist = false;
List items = [];
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) !=
null) { null) {
lastVisited = lastVisited =
@ -32,8 +33,27 @@ class ProductTileItem extends StatelessWidget {
if (id == item.id) { if (id == item.id) {
isIdExist = true; isIdExist = true;
} }
items.add(id);
}); });
} }
if(items.length >= 15){
items.removeAt(0);
// lastVisited = lastVisited.replaceFirst(RegExp('$itemToRemove'), '');
}
lastVisited = "";
for(int i = items.length - 1; i >= 0; i--){
if (lastVisited == "") {
// it means there is no lastVisited yet
lastVisited = "${items[i]}";
} else {
// there is lastVisited id's and this product id is not found
lastVisited += ",${items[i]}";
}
}
if (!isIdExist) { if (!isIdExist) {
if (lastVisited == "") { if (lastVisited == "") {
// it means there is no lastVisited yet // it means there is no lastVisited yet
@ -42,8 +62,8 @@ class ProductTileItem extends StatelessWidget {
// there is lastVisited id's and this product id is not found // there is lastVisited id's and this product id is not found
lastVisited += ",${item.id}"; lastVisited += ",${item.id}";
} }
sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited);
} }
sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited);
} }
@override @override

@ -59,7 +59,7 @@ class _BannerPagerState extends State<BannerPager> {
) )
: CachedNetworkImage( : CachedNetworkImage(
imageUrl: item, imageUrl: item,
fit: BoxFit.cover, fit: BoxFit.fitWidth,
errorWidget: (context, url, error) => errorWidget: (context, url, error) =>
SizedBox()), SizedBox()),
), ),

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -26,6 +27,7 @@ class BestSellerWidget extends StatelessWidget {
id: "", id: "",
productType: 20, productType: 20,
)), )),
if (model.state != ViewState.BusyLocal)
Container( Container(
height: MediaQuery.of(context).size.height / 4 + 20, height: MediaQuery.of(context).size.height / 4 + 20,
child: ListView.builder( child: ListView.builder(
@ -34,7 +36,18 @@ class BestSellerWidget extends StatelessWidget {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: model.bestSellerProduct.length, itemCount: model.bestSellerProduct.length,
), ),
), ) else
Container(
height: 80,
child: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
),
),
], ],
), ),
), ),

@ -29,10 +29,15 @@ class GridViewCard extends StatelessWidget {
flex: 2, flex: 2,
child: Padding( child: Padding(
padding: const EdgeInsets.all(6), padding: const EdgeInsets.all(6),
child: Texts( child: Column(
text, children: [
color: Colors.white, Texts(
fontSize: SizeConfig.textMultiplier * 1.5, text,
color: Colors.white,
bold: true,
fontSize: SizeConfig.textMultiplier * 1.5,
),
],
), ),
), ),
), ),

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -15,31 +16,44 @@ class RecentlyViewedWidget extends StatelessWidget {
onModelReady: (model) => model.getLastVisitedProducts(), onModelReady: (model) => model.getLastVisitedProducts(),
allowAny: true, allowAny: true,
builder: (_, model, wi) => NetworkBaseView( builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true, isLocalLoader: true,
baseViewModel: model, baseViewModel: model,
child: Container( child: model.lastVisitedProducts.isNotEmpty ? Container(
child: Column( child: Column(
children: [ children: [
ViewAllHomeWidget( ViewAllHomeWidget(
TranslationBase.of(context).recentlyViewed, TranslationBase.of(context).recentlyViewed,
FinalProductsPage( FinalProductsPage(
id: "", id: "",
productType: 3, productType: 3,
)), )),
Container( if (model.state != ViewState.BusyLocal)
height: model.lastVisitedProducts.length > 0 Container(
? MediaQuery.of(context).size.height / 4 + 20 height: model.lastVisitedProducts.length > 0
: 0, ? MediaQuery.of(context).size.height / 4 + 20
child: ListView.builder( : 0,
itemBuilder: (ctx, i) => child: ListView.builder(
ProductTileItem(model.lastVisitedProducts[i]), itemBuilder: (ctx, i) =>
scrollDirection: Axis.horizontal, ProductTileItem(model.lastVisitedProducts[i]),
itemCount: model.lastVisitedProducts.length, scrollDirection: Axis.horizontal,
), itemCount: model.lastVisitedProducts.length,
),
)
else
Container(
height: 80,
child: Center(
child:CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
),
),
],
), ),
], ) : Container(),
), ));
),
));
} }
} }

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -15,26 +16,38 @@ class ShopByBrandWidget extends StatelessWidget {
onModelReady: (model) => model.getTopManufacturerList(), onModelReady: (model) => model.getTopManufacturerList(),
allowAny: true, allowAny: true,
builder: (_, model, wi) => NetworkBaseView( builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true, isLocalLoader: true,
baseViewModel: model, baseViewModel: model,
child: Container( child: Container(
child: Column( child: Column(
children: [ children: [
ViewAllHomeWidget( ViewAllHomeWidget(TranslationBase.of(context).shopByBrands,
TranslationBase.of(context).shopByBrands, ProductBrandsPage()),
ProductBrandsPage()), if (model.state != ViewState.BusyLocal)
Container( Container(
height: 100, height: 100,
child: ListView.builder( child: ListView.builder(
itemBuilder: (ctx, i) => itemBuilder: (ctx, i) =>
ManufacturerItem(model.manufacturerList[i]), ManufacturerItem(model.manufacturerList[i]),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: model.manufacturerList.length, itemCount: model.manufacturerList.length,
), ),
)
else
Container(
height: 80,
child: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
),
),
],
), ),
], ),
), ));
),
));
} }
} }

@ -14,21 +14,23 @@ class ViewAllHomeWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10), margin: EdgeInsets.fromLTRB(16, 10, 16, 10),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Texts( Texts(
title, title,
bold: true, bold: true,
fontSize: 16,
), ),
BorderedButton( BorderedButton(
TranslationBase.of(context).viewAll, TranslationBase.of(context).viewAll,
hasBorder: true, hasBorder: true,
borderColor: Colors.green, borderColor: Colors.green,
textColor: Colors.green, textColor: Colors.green,
fontWeight: FontWeight.bold,
vPadding: 6, vPadding: 6,
hPadding: 4, hPadding: 14,
handler: () { handler: () {
Navigator.push( Navigator.push(
context, context,

@ -98,7 +98,7 @@ class ProductDetailService extends BaseService {
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
AppToast.showErrorToast(message: 'something went wrong please try again'); AppToast.showErrorToast(message: super.error??'something went wrong please try again');
}, body: request); }, body: request);
} }

@ -3,12 +3,12 @@ import 'package:flutter/material.dart';
class GestureIconButton extends StatefulWidget { class GestureIconButton extends StatefulWidget {
GestureIconButton( GestureIconButton(
this.label, this.label,
this.icon, { this.icon, {
Key key, Key key,
this.onTap, this.onTap,
this.backgroundColor, this.backgroundColor,
}) : super(key: key); }) : super(key: key);
final String label; final String label;
final Widget icon; final Widget icon;
@ -29,41 +29,35 @@ class _GestureIconButtonState extends State<GestureIconButton> {
setState(() => _buttonLongPress = !_buttonLongPress), setState(() => _buttonLongPress = !_buttonLongPress),
onLongPressEnd: (_) => onLongPressEnd: (_) =>
setState(() => _buttonLongPress = !_buttonLongPress), setState(() => _buttonLongPress = !_buttonLongPress),
child: Wrap( child: Container(
children: [ decoration: BoxDecoration(
Container( border: Border.all(
decoration: BoxDecoration( color: widget.backgroundColor != null
border: Border.all( ? widget.backgroundColor
color: widget.backgroundColor != null : Colors.grey[200],
? widget.backgroundColor ),
: Colors.grey[200], color: widget.backgroundColor != null
? widget.backgroundColor
: Colors.grey.shade200,
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: widget.icon,
), ),
color: widget.backgroundColor != null Texts(
? widget.backgroundColor widget.label,
: Colors.grey.shade200, color: _buttonLongPress ? Colors.white : Colors.black,
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Expanded(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: widget.icon,
),
Texts(
widget.label,
color: _buttonLongPress ? Colors.white : Colors.black,
),
],
),
), ),
), ],
), ),
), ),
], ),
), ),
); );
} }

@ -224,37 +224,36 @@ class AppBarWidgetState extends State<AppBarWidget> {
), ),
centerTitle: true, centerTitle: true,
actions: <Widget>[ actions: <Widget>[
(widget.isPharmacy && widget.showPharmacyCart) // (widget.isPharmacy && widget.showPharmacyCart)
? Container() // ? Container()
// ? IconButton( // // ? IconButton(
// icon: Badge( // // icon: Badge(
// shape: BadgeShape.circle, // // shape: BadgeShape.circle,
// badgeContent: // // badgeContent:
Text(_badgeText, style: TextStyle(color: Colors.white)), // // Text(_badgeText, style: TextStyle(color: Colors.white)),
// child: Icon(Icons.shopping_cart)), // // child: Icon(Icons.shopping_cart)),
// color: Colors.white, // // color: Colors.white,
// onPressed: () { // // onPressed: () {
// Navigator.of(context).popUntil(ModalRoute.withName('/')); // // Navigator.of(context).popUntil(ModalRoute.withName('/'));
// }) // // })
: Container(), // : Container(),
(widget.isOfferPackages && widget.showOfferPackagesCart) (widget.isOfferPackages && widget.showOfferPackagesCart)
? Container() ? IconButton(
// ? IconButton( icon: Badge(
// icon: Badge( position: BadgePosition.topStart(top: -15, start: -10),
// position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text(
// badgeContent: Text( _badgeText,
// _badgeText, style: TextStyle(
// style: TextStyle( fontSize: 9,
// fontSize: 9, color: Colors.white,
// color: Colors.white, fontWeight: FontWeight.normal),
// fontWeight: FontWeight.normal), ),
// ), child: Icon(Icons.shopping_cart)),
// child: Icon(Icons.shopping_cart)), color: Colors.white,
// color: Colors.white, onPressed: () {
// onPressed: () { // Cart Click Event
// // Cart Click Event if (_onCartClick != null) _onCartClick();
// if (_onCartClick != null) _onCartClick(); })
// })
: Container(), : Container(),
if (widget.showHomeAppBarIcon) if (widget.showHomeAppBarIcon)
IconButton( IconButton(
@ -375,10 +374,10 @@ class _RobotIcon extends State<RobotIcon> {
bottom: -15); bottom: -15);
} }
// setAnimation() async { // setAnimation() async {
// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) ||
// // var animation = // // var animation =
// // IS_TEXT_COMPLETED == ? true : false; // // IS_TEXT_COMPLETED == ? true : false;
// } // }
} }

Loading…
Cancel
Save