fix public card issues

merge-requests/415/head
Elham Rababh 3 years ago
parent 7dfc700d26
commit 2981eb3236

@ -49,7 +49,6 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PharmacyCategoriseViewModel>( return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) { onModelReady: (model) {
//TODO Elham* fix all services in order handel errors in better way in the service
if (widget.productType == 1) { if (widget.productType == 1) {
model.getFinalProducts(i: id); model.getFinalProducts(i: id);
appBarTitle = TranslationBase.of(context).products; appBarTitle = TranslationBase.of(context).products;

@ -137,7 +137,7 @@ reviewDetails(data, rate, myRate) {
: Alignment.topLeft, : Alignment.topLeft,
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
text: data.product.price.toString() + text: data.product.quantity.toString() +
" " + " " +
data.product.currency, data.product.currency,
style: TextStyle( style: TextStyle(

@ -78,4 +78,13 @@ class AvailabilityInfo extends StatelessWidget {
}, },
); );
} }
convertCityName(txt) {
String stringTxt;
String newTxt;
stringTxt = txt.toString();
newTxt = stringTxt.split('.')[1];
return newTxt;
}
} }

@ -19,12 +19,12 @@ class FooterWidget extends StatefulWidget {
final PharmacyProduct item; final PharmacyProduct item;
final Function addToCartFunction; final Function addToCartFunction;
int price; 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.price, this.isOverQuantity = false, this.addToCartFunction}); {this.quantity, this.isOverQuantity = false, this.addToCartFunction});
@override @override
_FooterWidgetState createState() => _FooterWidgetState(); _FooterWidgetState createState() => _FooterWidgetState();
@ -97,7 +97,7 @@ class _FooterWidgetState extends State<FooterWidget> {
QuantityBox( QuantityBox(
label: i, label: i,
onTapFunc: onChangeValue, onTapFunc: onChangeValue,
isSelected: widget.price == i), isSelected: widget.quantity == i),
Column( Column(
children: [ children: [
Container( Container(
@ -111,14 +111,14 @@ class _FooterWidgetState extends State<FooterWidget> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'quantity #'), labelText: 'quantity #'),
onChanged: (text) { onChanged: (text) {
print(widget.price); print(widget.quantity);
print(widget.quantityLimit); print(widget.quantityLimit);
if (int.tryParse(text) == null) { if (int.tryParse(text) == null) {
text = ''; text = '';
} else { } else {
setState(() { setState(() {
widget.price = int.parse(text); widget.quantity = int.parse(text);
if (widget.price >= if (widget.quantity >=
widget.quantityLimit) { widget.quantityLimit) {
widget.isOverQuantity = true; widget.isOverQuantity = true;
} else { } else {
@ -156,7 +156,7 @@ class _FooterWidgetState extends State<FooterWidget> {
Expanded( Expanded(
flex: 4, flex: 4,
child: Text( child: Text(
widget.price.toString(), widget.quantity.toString(),
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
), ),
), ),
@ -186,8 +186,8 @@ class _FooterWidgetState extends State<FooterWidget> {
width: MediaQuery.of(context).size.width * 0.45, width: MediaQuery.of(context).size.width * 0.45,
child: SecondaryButton( child: SecondaryButton(
label: TranslationBase.of(context).addToCart.toUpperCase(), label: TranslationBase.of(context).addToCart.toUpperCase(),
disabled: !widget.isAvailable && widget.price > 0 || disabled: !widget.isAvailable && widget.quantity > 0 ||
widget.price > widget.quantityLimit || widget.quantity > widget.quantityLimit ||
widget.item.rxMessage != null, widget.item.rxMessage != null,
disableColor: Colors.green[400], disableColor: Colors.green[400],
onTap: () async { onTap: () async {
@ -197,7 +197,7 @@ class _FooterWidgetState extends State<FooterWidget> {
); );
} else } else
await widget.addToCartFunction( await widget.addToCartFunction(
widget.price, widget.item.id, context); widget.quantity, widget.item.id, context);
}, },
borderRadius: 5, borderRadius: 5,
color: Colors.green, color: Colors.green,
@ -210,12 +210,12 @@ class _FooterWidgetState extends State<FooterWidget> {
width: MediaQuery.of(context).size.width * 0.35, width: MediaQuery.of(context).size.width * 0.35,
child: SecondaryButton( child: SecondaryButton(
label: TranslationBase.of(context).buyNow.toUpperCase(), label: TranslationBase.of(context).buyNow.toUpperCase(),
disabled: !widget.isAvailable && widget.price > 0 || disabled: !widget.isAvailable && widget.quantity > 0 ||
widget.price > 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.price, widget.item.id, context); widget.quantity, widget.item.id, context);
Navigator.push( Navigator.push(
context, context,
FadePage(page: CartOrderPage()), FadePage(page: CartOrderPage()),
@ -223,8 +223,8 @@ class _FooterWidgetState extends State<FooterWidget> {
}, },
borderRadius: 5, borderRadius: 5,
disableColor: Colors.grey[700], disableColor: Colors.grey[700],
color: !widget.isAvailable && widget.price > 0 || color: !widget.isAvailable && widget.quantity > 0 ||
widget.price > widget.quantityLimit || widget.quantity > widget.quantityLimit ||
widget.item.rxMessage != null widget.item.rxMessage != null
? Colors.grey ? Colors.grey
: Colors.grey[800], : Colors.grey[800],
@ -239,13 +239,12 @@ class _FooterWidgetState extends State<FooterWidget> {
onChangeValue(int i) { onChangeValue(int i) {
setState(() { setState(() {
///TODO Elham* Check this if its good widget.quantity = i;
widget.price = i; if (widget.quantity >= widget.quantityLimit) {
if (widget.price >= widget.quantityLimit) {
widget.isOverQuantity = true; widget.isOverQuantity = true;
} else { } else {
widget.isOverQuantity = false; widget.isOverQuantity = false;
return widget.price; return widget.quantity;
} }
}); });
} }

@ -1,43 +1,28 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; 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/model/pharmacies/PharmacyProduct.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/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/uitl/app_toast.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/gif_loader_dialog_utils.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/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/app_scafold_detail_page.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
import '../cart-order-page.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'shared/product_details_app_bar.dart';
import 'availability_info.dart'; import 'availability_info.dart';
import 'details_info.dart'; import 'details_info.dart';
import 'discount_description.dart'; import 'discount_description.dart';
import 'footor/footer-widget.dart'; import 'footor/footer-widget.dart';
import 'shared/product_details_app_bar.dart';
int price = 0;
bool isOverQuantity = false;
bool isInWishList = false;
bool isSelected = true;
String itemID; String itemID;
var customerId;
CompareList compareItems = new CompareList();
PharmacyProduct specificationData; PharmacyProduct specificationData;
class ProductDetailPage extends StatefulWidget { class ProductDetailPage extends StatefulWidget {
@ -49,23 +34,27 @@ class ProductDetailPage extends StatefulWidget {
__ProductDetailPageState createState() => __ProductDetailPageState(); __ProductDetailPageState createState() => __ProductDetailPageState();
} }
class __ProductDetailPageState extends State<ProductDetailPage> class __ProductDetailPageState extends State<ProductDetailPage>{
with SingleTickerProviderStateMixin {
TabController _tabController;
AppSharedPreferences sharedPref = AppSharedPreferences(); AppSharedPreferences sharedPref = AppSharedPreferences();
bool isTrue = true; bool isTrue = true;
bool isDetails = true; bool isDetails = true;
bool isReviews = false; bool isReviews = false;
bool isAvailability = false; bool isAvailability = false;
String customerId;
bool isSelected = true;
bool isOverQuantity = false;
bool isInWishList = false;
int quantity = 0;
checkWishlist() async { checkWishlist() async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel model = new ProductDetailViewModel();
await x.checkWishlistData(); await model.checkWishlistData();
for (int i = 0; i < x.wishListItems.length; i++) { for (int i = 0; i < model.wishListItems.length; i++) {
if (itemID == x.wishListItems[i].product.id) { if (itemID == model.wishListItems[i].product.id) {
isInWishList = true; isInWishList = true;
break; break;
} else { } else {
@ -77,9 +66,8 @@ class __ProductDetailPageState extends State<ProductDetailPage>
} }
void initState() { void initState() {
price = 1; quantity = 1;
specificationData = widget.product; specificationData = widget.product;
_tabController = TabController(length: 3, vsync: this);
userInfo(); userInfo();
super.initState(); super.initState();
@ -87,7 +75,6 @@ class __ProductDetailPageState extends State<ProductDetailPage>
@override @override
void dispose() { void dispose() {
_tabController.dispose();
super.dispose(); super.dispose();
} }
@ -111,6 +98,11 @@ class __ProductDetailPageState extends State<ProductDetailPage>
isShowDecPage: false, isShowDecPage: false,
customAppBar: ProductAppBar( customAppBar: ProductAppBar(
product: widget.product, product: widget.product,
model: model,
addToWishlistFunction: (item) {
addToWishlistFunction(itemID:item,model:model);
setState(() {});
},
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
@ -143,15 +135,15 @@ class __ProductDetailPageState extends State<ProductDetailPage>
widget.product, widget.product,
customerId: customerId, customerId: customerId,
addToWishlistFunction: (item) { addToWishlistFunction: (item) {
addToWishlistFunction(item); addToWishlistFunction(itemID:item,model:model);
setState(() {}); setState(() {});
}, },
deleteFromWishlistFunction: (item) { deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(item); deleteFromWishlistFunction(itemID: item, model: model);
setState(() {}); setState(() {});
}, },
notifyMeWhenAvailable: (context, itemId) { notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(context, itemId); notifyMeWhenAvailable(itemId:itemId, customerId: customerId, model: model);
}, },
isInWishList: isInWishList, isInWishList: isInWishList,
), ),
@ -319,85 +311,33 @@ class __ProductDetailPageState extends State<ProductDetailPage>
widget.product.orderMinimumQuantity, widget.product.orderMinimumQuantity,
widget.product.stockQuantity, widget.product.stockQuantity,
widget.product, widget.product,
price: price, quantity: quantity,
isOverQuantity: isOverQuantity, isOverQuantity: isOverQuantity,
addToCartFunction: addToCartFunction, addToCartFunction: addToCartFunction,
), ),
)); ));
} }
}
class CustomDivider extends StatelessWidget {
const CustomDivider({
Key key,
this.color,
}) : super(key: key);
final Color color; addToWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = true;
await model.addToWishlistData(itemID);
}
@override deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async {
Widget build(BuildContext context) { isInWishList = false;
return Container( await model.deletWishlistData(itemID);
width: 120,
height: 2,
color: color,
);
} }
} }
convertCityName(txt) {
String stringTxt;
String newTxt;
stringTxt = txt.toString();
newTxt = stringTxt.split('.')[1];
return newTxt;
}
addToCartFunction(quantity, itemID, BuildContext context) async { addToCartFunction({quantity, itemID, BuildContext context,ProductDetailViewModel model}) async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
ProductDetailViewModel x = new ProductDetailViewModel(); await model.addToCartData(quantity, itemID);
await x.addToCartData(quantity, itemID);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
notifyMeWhenAvailable(context, itemId) async { notifyMeWhenAvailable({itemId, customerId,ProductDetailViewModel model }) async {
ProductDetailViewModel x = new ProductDetailViewModel(); await model.notifyMe(customerId, itemId);
await x.notifyMe(customerId, itemId);
} }
addToWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
isInWishList = true;
await x.addToWishlistData(itemID);
}
deleteFromWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
isInWishList = false;
await x.deletWishlistData(itemID);
}
//TODO Elham* move to file
Widget tabWidget(
Size screenSize,
bool isActive,
String title,
) {
return Center(
child: Container(
height: screenSize.height * 0.070,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(
title,
fontSize: SizeConfig.textMultiplier * 1.5,
// color: Color(0xFF2B353E),
fontWeight: FontWeight.w700,
),
],
),
),
);
}

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

@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
class CustomDivider extends StatelessWidget {
const CustomDivider({
Key key,
this.color,
}) : super(key: key);
final Color color;
@override
Widget build(BuildContext context) {
return Container(
width: 120,
height: 2,
color: color,
);
}
}

@ -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/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -13,19 +14,22 @@ import '../../cart-order-page.dart';
import 'icon_with_bg.dart'; import 'icon_with_bg.dart';
class ProductAppBar extends StatelessWidget with PreferredSizeWidget { class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
final PharmacyProduct product; final PharmacyProduct product;
ProductAppBar({Key key, this.product}) : super(key: key); final ProductDetailViewModel model;
final Function addToWishlistFunction;
final int quantity;
ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity})
: super(key: key);
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>(); locator<AuthenticatedUserObject>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
color: Colors.white, color: Colors.white,
child: FractionallySizedBox( child: FractionallySizedBox(
widthFactor: 0.95, widthFactor: 0.95,
child: Column( child: Column(
@ -47,29 +51,31 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
), ),
], ],
), ),
if(authenticatedUserObject.isLogin) if (authenticatedUserObject.isLogin)
Row( Row(
children: [ children: [
IconWithBg( IconWithBg(
icon: Icons.shopping_cart, icon: Icons.shopping_cart,
color: Colors.grey,
onPress: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CartOrderPage()),
);
}),
SizedBox(
width: 10,
),
IconWithBg(
icon: FontAwesomeIcons.ellipsisV,
color: Colors.grey, color: Colors.grey,
onPress: () { onPress: () {
Navigator.push( settingModalBottomSheet(context);
context, },
MaterialPageRoute( ),
builder: (context) => CartOrderPage()), ],
); )
}),
SizedBox(width: 10,),
IconWithBg(
icon: FontAwesomeIcons.ellipsisV,
color: Colors.grey,
onPress: () {
settingModalBottomSheet(context);
},
),
],
)
], ],
), ),
], ],
@ -78,10 +84,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
); );
} }
@override @override
// TODO: implement preferredSize
@override @override
Size get preferredSize => Size(double.maxFinite, 50); Size get preferredSize => Size(double.maxFinite, 50);
@ -92,27 +95,34 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
return Container( return Container(
child: new Wrap( child: new Wrap(
children: <Widget>[ children: <Widget>[
if( product.stockAvailability != 'Out of stock') if (product.stockAvailability != 'Out of stock')
new ListTile( new ListTile(
leading: Icon(Icons.shopping_cart), leading: Icon(Icons.shopping_cart),
title: Text( title: Text(
TranslationBase.of(context).addToCart, TranslationBase.of(context).addToCart,
), ),
onTap: () => { onTap: () => {
if (price > 0) if (quantity > 0)
{addToCartFunction(price, itemID, context)} {
else addToCartFunction(
{ quantity: quantity,
AppToast.showErrorToast( itemID: itemID,
message: "you should add quantity") context: context,
} model: model)
}), }
else
{
AppToast.showErrorToast(
message: "you should add quantity")
}
}),
ListTile( ListTile(
leading: Icon(Icons.favorite_border), leading: Icon(Icons.favorite_border),
title: Text( title: Text(
TranslationBase.of(context).addToWishlist, TranslationBase.of(context).addToWishlist,
), ),
onTap: () => {addToWishlistFunction(itemID)}, onTap: () =>
{addToWishlistFunction(itemID: itemID, model: model)},
), ),
ListTile( ListTile(
leading: Icon(Icons.compare), leading: Icon(Icons.compare),
@ -130,5 +140,3 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
}); });
} }
} }

@ -1,281 +0,0 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart';
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../../locator.dart';
import 'floating_button_search.dart';
import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart';
import 'network_base_view.dart';
import 'not_auh_page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart';
class DetailPageScafold extends StatefulWidget {
final String appBarTitle;
final Widget body;
final Widget bottomSheet;
final bool isLoading;
final bool isShowAppBar;
final bool hasAppBarParam;
final BaseViewModel baseViewModel;
final bool isBottomBar;
final Widget floatingActionButton;
final bool isPharmacy;
final String title;
final String description;
final String image;
final bool isShowDecPage;
final List<String> infoList;
final Color backgroundColor;
final double preferredSize;
final List<Widget> appBarIcons;
final PreferredSizeWidget appBarWidget;
DetailPageScafold(
{@required this.body,
this.appBarTitle = '',
this.isLoading = false,
this.isShowAppBar = false,
this.hasAppBarParam,
this.bottomSheet,
this.baseViewModel,
this.floatingActionButton,
this.isPharmacy = false,
this.title,
this.description,
this.isShowDecPage = true,
this.isBottomBar,
this.backgroundColor,
this.preferredSize = 0.0,
this.appBarIcons,
this.appBarWidget,
this.image,
this.infoList});
@override
_DetailPageScafoldState createState() => _DetailPageScafoldState();
}
class _DetailPageScafoldState extends State<DetailPageScafold> {
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
@override
Widget build(BuildContext context) {
AppGlobal.context = context;
PreferredSizeWidget appBar;
if (this.widget.appBarWidget == null) {
PreferredSizeWidget appBarWidget = AppBarWidget(
widget.appBarTitle,
widget.appBarIcons,
widget.isShowAppBar,
isPharmacy: widget.isPharmacy,
isShowDecPage: widget.isShowDecPage,
image: widget.image,
);
appBar = widget.preferredSize == 0
? appBarWidget
: PreferredSize(
child: appBarWidget,
preferredSize: Size.fromHeight(widget.preferredSize));
} else {
appBar = this.widget.appBarWidget;
}
return Scaffold(
backgroundColor:
widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor,
appBar: appBar,
body: (!Provider.of<ProjectViewModel>(context, listen: false).isLogin &&
widget.isShowDecPage)
? NotAutPage(
title: widget.appBarTitle,
description: widget.description,
infoList: widget.infoList,
)
: widget.baseViewModel != null
? NetworkBaseView(
child: buildBodyWidget(),
baseViewModel: widget.baseViewModel,
)
: buildBodyWidget(),
bottomSheet: widget.bottomSheet,
//floatingActionButton: floatingActionButton ?? floatingActionButton,
// bottomNavigationBar:
// this.isBottomBar == true ? BottomBarSearch() : SizedBox()
// floatingActionButton: FloatingSearchButton(),
);
}
buildAppLoaderWidget(bool isLoading) {
return isLoading ? AppLoaderWidget() : Container();
}
buildBodyWidget() {
// return body; //Stack(children: <Widget>[body, buildAppLoaderWidget(isLoading)]);
return Stack(children: <Widget>[
widget.body, /*FloatingSearchButton()*/
]);
}
}
class AppBarWidget extends StatelessWidget with PreferredSizeWidget {
final AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
final String appBarTitle;
final List<Widget> appBarIcons;
final bool isShowAppBar;
final bool isPharmacy;
final bool isShowDecPage;
final String image;
AppBarWidget(this.appBarTitle, this.appBarIcons, this.isShowAppBar,
{this.isPharmacy = true, this.isShowDecPage = true, this.image});
@override
Widget build(BuildContext context) {
return buildAppBar(context);
}
Widget buildAppBar(BuildContext context) {
return isShowAppBar
? AppBar(
elevation: 0,
backgroundColor: Colors.white,
// isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color,
textTheme: TextTheme(
headline6:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
title: Texts(
authenticatedUserObject.isLogin || !isShowDecPage
? appBarTitle.toUpperCase()
: TranslationBase.of(context).serviceInformationTitle,
color: Colors.white,
bold: true,
),
leading: Builder(
builder: (BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => Navigator.pop(context),
child: Icon(Icons.arrow_back_ios, color: Colors.grey),
);
},
),
centerTitle: true,
actions: <Widget>[
/// TODO Elham* fix this
if(isPharmacy)
IconButton(
icon: Icon(Icons.shopping_cart),
color: Colors.grey,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CartOrderPage()),
);
}),
image != null
? InkWell(
onTap: () => Navigator.push(
context,
FadePage(
page: InsuranceUpdate(),
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
image,
height: SizeConfig.heightMultiplier * 5,
width: SizeConfig.heightMultiplier * 5,
color: Colors.grey,
),
),
)
: IconButton(
icon: Icon(FontAwesomeIcons.ellipsisV),
color: Colors.grey,
onPressed: () {
settingModalBottomSheet(context);
},
),
if (appBarIcons != null) ...appBarIcons
],
)
: Container(
height: 0,
width: 0,
);
}
@override
Size get preferredSize => Size(double.maxFinite, 60);
settingModalBottomSheet(context) {
showModalBottomSheet(
context: context,
builder: (BuildContext bc) {
return Container(
child: new Wrap(
children: <Widget>[
new ListTile(
leading: Icon(Icons.shopping_cart),
title: Text(
TranslationBase.of(context).addToCart,
),
onTap: () => {
if (price > 0)
{addToCartFunction(price, itemID, context)}
else
{
AppToast.showErrorToast(
message: "you should add quantity")
}
}),
ListTile(
leading: Icon(Icons.favorite_border),
title: Text(
TranslationBase.of(context).addToWishlist,
),
onTap: () => {addToWishlistFunction(itemID)},
),
ListTile(
leading: Icon(Icons.compare),
title: Text(
TranslationBase.of(context).compare,
),
onTap: () => {
Provider.of<CompareList>(context, listen: false)
.addItem(specificationData),
},
),
],
),
);
});
}
}
Loading…
Cancel
Save