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

merge-requests/421/head
Mohammad Aljammal 4 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<Reviews> reviews;
List<PharmacyImageObject> images;
List<String> attributes;
List<dynamic> attributes;
List<Specifications> specifications;
List<String> associatedProductIds;
List<String> tags;
List<dynamic> associatedProductIds;
List<dynamic> tags;
int vendorId;
String seName;
@ -367,7 +367,7 @@ class PharmacyProduct {
});
}
if (json['attributes'] != null) {
attributes = new List<String>();
attributes = new List<dynamic>();
json['attributes'].forEach((v) {
attributes.add(v);
});

@ -785,7 +785,8 @@ class BaseAppClient {
final int statusCode = response.statusCode;
print("statusCode :$statusCode");
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 {
// var parsed = json.decode(response.body.toString());
var parsed = json.decode(utf8.decode(response.bodyBytes));

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

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

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

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

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

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

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

@ -24,6 +24,7 @@ class ProductTileItem extends StatelessWidget {
void _saveLastVisitProducts() async {
String lastVisited = "";
bool isIdExist = false;
List items = [];
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) !=
null) {
lastVisited =
@ -32,8 +33,27 @@ class ProductTileItem extends StatelessWidget {
if (id == item.id) {
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 (lastVisited == "") {
// 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
lastVisited += ",${item.id}";
}
sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited);
}
sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited);
}
@override

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

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -26,6 +27,7 @@ class BestSellerWidget extends StatelessWidget {
id: "",
productType: 20,
)),
if (model.state != ViewState.BusyLocal)
Container(
height: MediaQuery.of(context).size.height / 4 + 20,
child: ListView.builder(
@ -34,7 +36,18 @@ class BestSellerWidget extends StatelessWidget {
scrollDirection: Axis.horizontal,
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,
child: Padding(
padding: const EdgeInsets.all(6),
child: Texts(
text,
color: Colors.white,
fontSize: SizeConfig.textMultiplier * 1.5,
child: Column(
children: [
Texts(
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/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -15,31 +16,44 @@ class RecentlyViewedWidget extends StatelessWidget {
onModelReady: (model) => model.getLastVisitedProducts(),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true,
baseViewModel: model,
child: Container(
child: Column(
children: [
ViewAllHomeWidget(
TranslationBase.of(context).recentlyViewed,
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,
),
isLocalLoader: true,
baseViewModel: model,
child: model.lastVisitedProducts.isNotEmpty ? Container(
child: Column(
children: [
ViewAllHomeWidget(
TranslationBase.of(context).recentlyViewed,
FinalProductsPage(
id: "",
productType: 3,
)),
if (model.state != ViewState.BusyLocal)
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,
),
)
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/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -15,26 +16,38 @@ class ShopByBrandWidget extends StatelessWidget {
onModelReady: (model) => model.getTopManufacturerList(),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true,
baseViewModel: model,
child: Container(
child: Column(
children: [
ViewAllHomeWidget(
TranslationBase.of(context).shopByBrands,
ProductBrandsPage()),
Container(
height: 100,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ManufacturerItem(model.manufacturerList[i]),
scrollDirection: Axis.horizontal,
itemCount: model.manufacturerList.length,
),
isLocalLoader: true,
baseViewModel: model,
child: Container(
child: Column(
children: [
ViewAllHomeWidget(TranslationBase.of(context).shopByBrands,
ProductBrandsPage()),
if (model.state != ViewState.BusyLocal)
Container(
height: 100,
child: ListView.builder(
itemBuilder: (ctx, i) =>
ManufacturerItem(model.manufacturerList[i]),
scrollDirection: Axis.horizontal,
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
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
margin: EdgeInsets.fromLTRB(16, 10, 16, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
title,
bold: true,
fontSize: 16,
),
BorderedButton(
TranslationBase.of(context).viewAll,
hasBorder: true,
borderColor: Colors.green,
textColor: Colors.green,
fontWeight: FontWeight.bold,
vPadding: 6,
hPadding: 4,
hPadding: 14,
handler: () {
Navigator.push(
context,

@ -98,7 +98,7 @@ class ProductDetailService extends BaseService {
}, onFailure: (String error, int statusCode) {
hasError = true;
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);
}

@ -3,12 +3,12 @@ import 'package:flutter/material.dart';
class GestureIconButton extends StatefulWidget {
GestureIconButton(
this.label,
this.icon, {
Key key,
this.onTap,
this.backgroundColor,
}) : super(key: key);
this.label,
this.icon, {
Key key,
this.onTap,
this.backgroundColor,
}) : super(key: key);
final String label;
final Widget icon;
@ -29,41 +29,35 @@ class _GestureIconButtonState extends State<GestureIconButton> {
setState(() => _buttonLongPress = !_buttonLongPress),
onLongPressEnd: (_) =>
setState(() => _buttonLongPress = !_buttonLongPress),
child: Wrap(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: widget.backgroundColor != null
? widget.backgroundColor
: Colors.grey[200],
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: widget.backgroundColor != null
? 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
? widget.backgroundColor
: Colors.grey.shade200,
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,
),
],
),
Texts(
widget.label,
color: _buttonLongPress ? Colors.white : Colors.black,
),
),
],
),
),
],
),
),
);
}

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

Loading…
Cancel
Save