Merge branch 'product_detail_page' into 'development'

fix bottom sheet functions

See merge request Cloud_Solution/diplomatic-quarter!424
merge-update-with-lab-changes
Mohammad Aljammal 4 years ago
commit 29d0afdea4

@ -49,7 +49,7 @@ class ProductDetailViewModel extends BaseViewModel{
Future notifyMe(customerId, itemID) async { Future notifyMe(customerId, itemID) async {
hasError = false; hasError = false;
setState(ViewState.Busy); setState(ViewState.BusyLocal);
await _productDetailService.notifyMe(customerId, itemID); await _productDetailService.notifyMe(customerId, itemID);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;
@ -60,7 +60,7 @@ class ProductDetailViewModel extends BaseViewModel{
Future addToCartData(quantity, itemID) async { Future addToCartData(quantity, itemID) async {
hasError = false; hasError = false;
setState(ViewState.Busy); setState(ViewState.BusyLocal);
await _productDetailService.addToCart(quantity, itemID); await _productDetailService.addToCart(quantity, itemID);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;

@ -1,5 +1,6 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
@ -10,6 +11,7 @@ import 'package:hexcolor/hexcolor.dart';
import '../../../../../locator.dart'; import '../../../../../locator.dart';
import '../../../../../routes.dart'; import '../../../../../routes.dart';
import '../../cart-order-page.dart'; import '../../cart-order-page.dart';
import '../product-detail.dart';
class FooterWidget extends StatefulWidget { class FooterWidget extends StatefulWidget {
final bool isAvailable; final bool isAvailable;
@ -18,13 +20,17 @@ class FooterWidget extends StatefulWidget {
final int quantityLimit; final int quantityLimit;
final PharmacyProduct item; final PharmacyProduct item;
final Function addToCartFunction; final Function addToCartFunction;
final ProductDetailViewModel model;
int quantity; int quantity;
bool isOverQuantity; bool isOverQuantity;
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity,
this.quantityLimit, this.item, this.quantityLimit, this.item,
{this.quantity, this.isOverQuantity = false, this.addToCartFunction}); {this.quantity,
this.isOverQuantity = false,
this.addToCartFunction,
this.model});
@override @override
_FooterWidgetState createState() => _FooterWidgetState(); _FooterWidgetState createState() => _FooterWidgetState();
@ -98,38 +104,31 @@ class _FooterWidgetState extends State<FooterWidget> {
label: i, label: i,
onTapFunc: onChangeValue, onTapFunc: onChangeValue,
isSelected: widget.quantity == i), isSelected: widget.quantity == i),
Column( Container(
children: [ width: 100,
Container( decoration: BoxDecoration(
width: 100, border: Border.all(color: Colors.grey[300]),
decoration: BoxDecoration( color: Colors.white,
border: ),
Border.all(color: Colors.grey[300]), child: TextField(
color: Colors.white, decoration: InputDecoration(
), labelText: ' Quantity # '),
child: TextField( onChanged: (text) {
decoration: InputDecoration( if (int.tryParse(text) == null) {
labelText: 'quantity #'), text = '';
onChanged: (text) { } else {
print(widget.quantity); setState(() {
print(widget.quantityLimit); widget.quantity = int.parse(text);
if (int.tryParse(text) == null) { if (widget.quantity >=
text = ''; widget.quantityLimit) {
widget.isOverQuantity = true;
} else { } else {
setState(() { widget.isOverQuantity = false;
widget.quantity = int.parse(text);
if (widget.quantity >=
widget.quantityLimit) {
widget.isOverQuantity = true;
} else {
widget.isOverQuantity = false;
}
});
} }
}, });
), }
), },
], ),
), ),
], ],
), ),
@ -175,7 +174,7 @@ class _FooterWidgetState extends State<FooterWidget> {
quantityUI = 80; quantityUI = 80;
showUI = false; showUI = false;
} else { } else {
quantityUI = 150; quantityUI = 160;
showUI = true; showUI = true;
} }
}); });
@ -197,10 +196,13 @@ class _FooterWidgetState extends State<FooterWidget> {
); );
} else } else
await widget.addToCartFunction( await widget.addToCartFunction(
widget.quantity, widget.item.id, context); quantity: widget.quantity,
itemID: widget.item.id,
model: widget.model);
}, },
fontWeight: FontWeight.w600,
borderColor: Color(0xFF4CAF50), borderColor: Color(0xFF4CAF50),
borderRadius: 5, borderRadius: 3,
color: Color(0xFF4CAF50), color: Color(0xFF4CAF50),
), ),
), ),
@ -215,14 +217,18 @@ class _FooterWidgetState extends State<FooterWidget> {
widget.quantity > widget.quantityLimit || widget.quantity > widget.quantityLimit ||
widget.item.rxMessage != null, widget.item.rxMessage != null,
onTap: () async { onTap: () async {
await widget.addToCartFunction( await widget.addToCartFunction(
widget.quantity, widget.item.id, context); quantity: widget.quantity,
itemID: widget.item.id,
model: widget.model);
Navigator.push( Navigator.push(
context, context,
FadePage(page: CartOrderPage()), FadePage(page: CartOrderPage()),
); );
}, },
borderRadius: 5, fontWeight: FontWeight.w600,
borderColor: Colors.grey[800],
borderRadius: 3,
disableColor: Colors.grey[700], disableColor: Colors.grey[700],
color: !widget.isAvailable && widget.quantity > 0 || color: !widget.isAvailable && widget.quantity > 0 ||
widget.quantity > widget.quantityLimit || widget.quantity > widget.quantityLimit ||

@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
@ -103,7 +104,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
deleteFromWishlistFunction: () async { deleteFromWishlistFunction: () async {
await deleteFromWishlistFunction(itemID: itemID, model: model); await deleteFromWishlistFunction(itemID: itemID, model: model);
}, },
isInWishList:isInWishList isInWishList:isInWishList,
addToCartFunction:addToCartFunction ,
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
@ -309,8 +311,9 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
), ),
), ),
SizedBox( SizedBox(
height: 80, height: 10,
) ),
RecommendedProducts(product: widget.product)
], ],
), ),
), ),
@ -323,6 +326,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
quantity: quantity, quantity: quantity,
isOverQuantity: isOverQuantity, isOverQuantity: isOverQuantity,
addToCartFunction: addToCartFunction, addToCartFunction: addToCartFunction,
model: model,
), ),
)); ));
} }
@ -338,17 +342,17 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
await model.deleteWishlistData(itemID); await model.deleteWishlistData(itemID);
setState(() {}); setState(() {});
} }
addToCartFunction(
{quantity,
itemID,
ProductDetailViewModel model}) async {
GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID);
GifLoaderDialogUtils.hideDialog(context);
}
} }
addToCartFunction(
{quantity,
itemID,
BuildContext context,
ProductDetailViewModel model}) async {
GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID);
GifLoaderDialogUtils.hideDialog(context);
}
notifyMeWhenAvailable( notifyMeWhenAvailable(
{itemId, customerId, ProductDetailViewModel model}) async { {itemId, customerId, ProductDetailViewModel model}) async {

@ -0,0 +1,377 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_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/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart';
class RecommendedProducts extends StatefulWidget {
final PharmacyProduct product;
final String customerId;
final ProductDetailViewModel productDetailViewModel;
final bool isOverQuantity;
final bool isInWishList;
final Function addToWishlistFunction;
final Function deleteFromWishlistFunction;
RecommendedProducts(
{Key key,
this.product,
this.productDetailViewModel,
this.customerId,
this.isOverQuantity = false,
this.isInWishList = false,
this.addToWishlistFunction,
this.deleteFromWishlistFunction})
: super(key: key);
@override
_RecommendedProductsState createState() => _RecommendedProductsState();
}
class _RecommendedProductsState extends State<RecommendedProducts> {
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return SingleChildScrollView(
child: Container(
width: 410,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(top: 9),
width: 410,
color: Colors.white,
child: Texts(
TranslationBase.of(context).recommended,
fontWeight: FontWeight.bold, fontSize: 16
),
),
Container(
color: Colors.white,
height: 210,
margin: EdgeInsets.only(bottom: 75),
padding: EdgeInsets.only(bottom: 5),
// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4),
child: BaseView<PharmacyModuleViewModel>(
onModelReady: (model) =>
model.getRecommendedProducts(widget.product.id),
builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true,
baseViewModel: model,
child: Container(
child: model.state== ViewState.BusyLocal?Container(
height: 80,
child: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
),
):model.recommendedProductList.length != null
? ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
physics: ScrollPhysics(),
// physics: NeverScrollableScrollPhysics(),
itemCount: model.recommendedProductList.length,
itemBuilder: (context, index) {
return InkWell(
onTap: () async {
GifLoaderDialogUtils.showMyDialog(context);
RecommendedProductModel data =
model.recommendedProductList[index];
var json = data.toJson();
PharmacyProduct product =
new PharmacyProduct.fromJson(json);
await Navigator.pushReplacement(
context,
FadePage(
page: ProductDetailPage(product),
),
);
GifLoaderDialogUtils.hideDialog(context);
},
child: Card(
elevation: 2,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.grey[300], width: 2),
borderRadius: BorderRadius.circular(10),
),
margin: EdgeInsets.symmetric(
horizontal: 8,
vertical: 0,
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(15),
),
),
padding: EdgeInsets.symmetric(horizontal: 4),
width: MediaQuery.of(context).size.width / 3,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Stack(children: [
Container(
child: Align(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(model
.recommendedProductList[
index]
.isinwishlist !=
true
? Icons.favorite_border
: Icons.favorite),
color: model
.recommendedProductList[
index]
.isinwishlist !=
true
? Colors.grey
: Colors.red,
onPressed: () async {
if (widget.customerId != null) {
if (!widget.isInWishList &&
model
.recommendedProductList[
index]
.isinwishlist !=
true) {
GifLoaderDialogUtils
.showMyDialog(context);
await widget.addToWishlistFunction(
itemID: model
.recommendedProductList[
index]
.id,
model: widget
.productDetailViewModel);
// checkWishlist();
GifLoaderDialogUtils
.hideDialog(context);
setState(() {
model
.recommendedProductList[
index]
.isinwishlist = true;
});
} else {
GifLoaderDialogUtils
.showMyDialog(context);
await widget.deleteFromWishlistFunction(
itemID: model
.recommendedProductList[
index]
.id,
model: widget
.productDetailViewModel);
GifLoaderDialogUtils
.hideDialog(context);
setState(() {
model
.recommendedProductList[
index]
.isinwishlist = false;
});
}
} else {
return;
}
setState(() {
// checkWishlist();
});
},
),
),
),
Container(
margin: EdgeInsets.fromLTRB(
0, 16, 10, 16),
alignment: Alignment.center,
child: (model
.recommendedProductList[
index]
.images !=
null &&
model
.recommendedProductList[
index]
.images
.length >
0)
? Image.network(
model
.recommendedProductList[
index]
.images[0]
.src
.toString(),
fit: BoxFit.cover,
height: 60,
)
: Image.asset(
"assets/images/no_image.png",
fit: BoxFit.cover,
height: 60,
),
),
Container(
width: model
.recommendedProductList[
index]
.rxMessage !=
null
? MediaQuery.of(context)
.size
.width /
5
: 0,
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: Color(0xffb23838),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(6),
),
),
child: model
.recommendedProductList[
index]
.rxMessage !=
null
? Texts(
projectViewModel.isArabic
? model
.recommendedProductList[
index]
.rxMessagen
: model
.recommendedProductList[
index]
.rxMessage,
color: Colors.white,
regular: true,
fontSize: 10,
fontWeight: FontWeight.w400,
)
: Texts(""),
),
]),
Container(
margin: EdgeInsets.symmetric(
horizontal: 6,
vertical: 0,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
projectViewModel.isArabic
? model
.recommendedProductList[
index]
.namen
: model
.recommendedProductList[
index]
.name,
style: TextStyle(
color: Colors.black,
fontSize: 13.0,
// fontWeight: FontWeight.bold,
),
),
Padding(
// padding: const EdgeInsets.only(top: 15, bottom: 10),
padding: const EdgeInsets.only(
top: 10, bottom: 5),
child: Texts(
"SAR ${model.recommendedProductList[index].price}",
bold: true,
fontSize: 14,
),
),
],
),
),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
padding:
EdgeInsets.only(right: 10),
child: Align(
alignment: Alignment.topLeft,
child: RatingBar.readOnly(
initialRating: model
.recommendedProductList[
index]
.approvedRatingSum
.toDouble(),
size: 13.0,
filledColor:
Colors.yellow[700],
emptyColor: Colors.grey[500],
isHalfAllowed: true,
halfFilledIcon:
Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star,
),
),
),
Texts(
"(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})",
// bold: true,
fontSize: 12,
),
]),
],
),
),
),
);
})
: Container(
// color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Texts(
TranslationBase.of(context).nonRecommended,
color: Colors.black,
),
],
),
),
),
),
),
),
],
),
),
);
}
}

@ -23,6 +23,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
final Function deleteFromWishlistFunction; final Function deleteFromWishlistFunction;
final int quantity; final int quantity;
final bool isInWishList; final bool isInWishList;
final Function addToCartFunction;
ProductAppBar( ProductAppBar(
{Key key, {Key key,
@ -31,7 +33,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
this.addToWishlistFunction, this.addToWishlistFunction,
this.quantity, this.quantity,
this.deleteFromWishlistFunction, this.deleteFromWishlistFunction,
this.isInWishList}) this.isInWishList, this.addToCartFunction})
: super(key: key); : super(key: key);
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject =
@ -83,7 +85,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
top:0, right: -1.0, top:0, right: -1.0,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.red, color: Colors.red[800],
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
), ),
@ -136,7 +138,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
await addToCartFunction( await addToCartFunction(
quantity: quantity, quantity: quantity,
itemID: itemID, itemID: itemID,
context: context,
model: model); model: model);
Navigator.of(context).pop(); Navigator.of(context).pop();

@ -89,6 +89,9 @@ class ProductDetailService extends BaseService {
"language_id": 1 "language_id": 1
} }
}; };
await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
_addToCartModel.clear(); _addToCartModel.clear();

@ -29,7 +29,10 @@ class SecondaryButton extends StatefulWidget {
this.small = false, this.small = false,
this.disabled = false, this.disabled = false,
this.borderColor, this.borderColor,
this.noBorderRadius = false, this.borderRadius, this.disableColor}) this.noBorderRadius = false,
this.borderRadius,
this.disableColor,
this.fontWeight})
: super(key: key); : super(key: key);
final String label; final String label;
@ -45,7 +48,7 @@ class SecondaryButton extends StatefulWidget {
final bool noBorderRadius; final bool noBorderRadius;
final double borderRadius; final double borderRadius;
final Color disableColor; final Color disableColor;
final FontWeight fontWeight;
@override @override
@ -173,7 +176,8 @@ class _SecondaryButtonState extends State<SecondaryButton>
child: ClipRRect( child: ClipRRect(
borderRadius: widget.noBorderRadius borderRadius: widget.noBorderRadius
? BorderRadius.all(Radius.circular(0.0)) ? BorderRadius.all(Radius.circular(0.0))
: BorderRadius.all(Radius.circular(widget.borderRadius??10.0)), : BorderRadius.all(
Radius.circular(widget.borderRadius ?? 10.0), ),
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
Positioned( Positioned(
@ -184,7 +188,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
height: 100, height: 100,
decoration: BoxDecoration( decoration: BoxDecoration(
color: widget.disabled color: widget.disabled
? widget.disableColor??Colors.grey ? widget.disableColor ?? Colors.grey
: widget.color ?? Theme.of(context).buttonColor), : widget.color ?? Theme.of(context).buttonColor),
), ),
), ),
@ -246,7 +250,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
style: TextStyle( style: TextStyle(
color: widget.textColor, color: widget.textColor,
fontSize: widget.small ? 12.0 : 14.0, fontSize: widget.small ? 12.0 : 14.0,
// fontWeight: FontWeight.w800, fontWeight: widget.fontWeight,
fontFamily: projectViewModel.isArabic fontFamily: projectViewModel.isArabic
? 'Cairo' ? 'Cairo'
: 'WorkSans'), : 'WorkSans'),

Loading…
Cancel
Save