Merge branch 'product_detail_page' into 'development'

add loader and cache on images

See merge request Cloud_Solution/diplomatic-quarter!415
merge-update-with-lab-changes
Mohammad Aljammal 4 years ago
commit 00a0e34347

@ -36,7 +36,7 @@ class ProductDetailViewModel extends BaseViewModel{
Future getProductLocationData() async { Future getProductLocationData() async {
hasError = false; hasError = false;
setState(ViewState.Busy); setState(ViewState.BusyLocal);
await _productDetailService.getProductAvailabiltyDetail(); await _productDetailService.getProductAvailabiltyDetail();
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;

@ -51,6 +51,9 @@ class _PickupLocationState extends State<PickupLocation> {
void initState() { void initState() {
super.initState(); super.initState();
_getCurrentLocation(); _getCurrentLocation();
setState(() {
});
} }
_getCurrentLocation() async { _getCurrentLocation() async {
@ -61,6 +64,7 @@ class _PickupLocationState extends State<PickupLocation> {
_longitude = 0; _longitude = 0;
_latitude = 0; _latitude = 0;
}); });
} }
@override @override
@ -89,8 +93,8 @@ class _PickupLocationState extends State<PickupLocation> {
context, context,
FadePage( FadePage(
page: PickupLocationFromMap( page: PickupLocationFromMap(
latitude: _latitude, latitude: _latitude??0,
longitude: _longitude, longitude: _longitude??0,
onPick: (value) { onPick: (value) {
setState(() { setState(() {
_result = value; _result = value;

@ -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(

@ -6,14 +6,12 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class AvailabilityInfo extends StatelessWidget { class AvailabilityInfo extends StatelessWidget {
final ProductDetailViewModel previousModel;
const AvailabilityInfo({Key key, this.previousModel}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<ProductDetailViewModel>( return previousModel.productLocationService.length == 0
onModelReady: (model) => model.getProductLocationData(),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
baseViewModel: model,
child: model.productLocationService.length == 0
? Container( ? Container(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
alignment: Alignment.center, alignment: Alignment.center,
@ -25,7 +23,7 @@ class AvailabilityInfo extends StatelessWidget {
physics: ScrollPhysics(), physics: ScrollPhysics(),
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
itemCount: model.productLocationService.length, itemCount: previousModel.productLocationService.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
@ -36,7 +34,7 @@ class AvailabilityInfo extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
flex: 1, flex: 1,
child: Image.network(model child: Image.network(previousModel
.productLocationService[index].projectImageUrl), .productLocationService[index].projectImageUrl),
), ),
SizedBox( SizedBox(
@ -45,11 +43,11 @@ class AvailabilityInfo extends StatelessWidget {
Expanded( Expanded(
flex: 4, flex: 4,
child: Text( child: Text(
model.productLocationService[index] previousModel.productLocationService[index]
.locationDescription + .locationDescription +
"\n" + "\n" +
convertCityName( convertCityName(
model.productLocationService[0].cityName previousModel.productLocationService[0].cityName
.toString(), .toString(),
), ),
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
@ -78,8 +76,15 @@ class AvailabilityInfo extends StatelessWidget {
), ),
); );
}, },
),
),
); );
} }
convertCityName(txt) {
String stringTxt;
String newTxt;
stringTxt = txt.toString();
newTxt = stringTxt.split('.')[1];
return newTxt;
}
} }

@ -1,5 +1,4 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class DiscountDescription extends StatelessWidget { class DiscountDescription extends StatelessWidget {

@ -1,8 +1,5 @@
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/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/pages/login/login.dart';
import 'package:diplomaticquarterapp/pages/login/welcome.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';
@ -22,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();
@ -100,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(
@ -114,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 {
@ -159,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),
), ),
), ),
@ -189,17 +186,18 @@ 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,
onTap: () { disableColor: Colors.green[400],
onTap: () async {
if (!authenticatedUserObject.isLogin) { if (!authenticatedUserObject.isLogin) {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
WELCOME_LOGIN, WELCOME_LOGIN,
); );
} else } else
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,
@ -212,20 +210,21 @@ 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: () { onTap: () async {
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()),
); );
}, },
borderRadius: 5, borderRadius: 5,
color: !widget.isAvailable && widget.price > 0 || disableColor: Colors.grey[700],
widget.price > widget.quantityLimit || color: !widget.isAvailable && widget.quantity > 0 ||
widget.quantity > widget.quantityLimit ||
widget.item.rxMessage != null widget.item.rxMessage != null
? Colors.grey ? Colors.grey
: Colors.grey[800], : Colors.grey[800],
@ -240,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 'ProductAppBar.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();
} }
@ -102,15 +89,21 @@ class __ProductDetailPageState extends State<ProductDetailPage>
} }
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); return BaseView<ProductDetailViewModel>(
final screenSize = MediaQuery.of(context).size; allowAny: true,
builder: (_, model, wi) => AppScaffold(
return AppScaffold(
appBarTitle: TranslationBase.of(context).productDetails, appBarTitle: TranslationBase.of(context).productDetails,
isShowAppBar: true, isShowAppBar: true,
isPharmacy: true, isPharmacy: true,
isShowDecPage: false, isShowDecPage: false,
customAppBar: ProductAppBar(product: widget.product,), customAppBar: ProductAppBar(
product: widget.product,
model: model,
addToWishlistFunction: (item) {
addToWishlistFunction(itemID:item,model:model);
setState(() {});
},
),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
@ -142,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,
), ),
@ -181,78 +174,6 @@ class __ProductDetailPageState extends State<ProductDetailPage>
SizedBox( SizedBox(
height: 6, height: 6,
), ),
// Container(
// height: 500,
// color: Colors.white,
// child: Scaffold(
// backgroundColor: Colors.white,
// extendBodyBehindAppBar: false,
// appBar: PreferredSize(
// preferredSize: Size.fromHeight(
// MediaQuery.of(context).size.height * 0.070),
// child: Container(
// height: MediaQuery.of(context).size.height * 0.070,
// decoration: BoxDecoration(
// border: Border(
// bottom: BorderSide(
// color: Theme.of(context).dividerColor,
// width: 0.5), //width: 0.7
// ),
// color: Colors.white),
// child: Center(
// child: TabBar(
// isScrollable: false,
// controller: _tabController,
// // indicatorColor: Colors.transparent,
// indicatorWeight: 1.0,
// indicatorSize: TabBarIndicatorSize.tab,
// indicatorColor:Colors.green,
// labelColor: Theme.of(context).primaryColor,
// labelPadding: EdgeInsets.only(
// top: 0, left: 0, right: 0, bottom: 0),
// unselectedLabelColor: Colors.grey[800],
// tabs: [
// tabWidget(screenSize, _activeTab == 0,
// TranslationBase.of(context).details,
// ),
// tabWidget(screenSize, _activeTab == 1,
// TranslationBase.of(context).review,
// ),
// tabWidget(screenSize, _activeTab == 2,
// TranslationBase.of(context).availability),
// ],
// ),
// ),
// ),
// ),
// body: Column(
// children: [
// Expanded(
// child: TabBarView(
// physics: BouncingScrollPhysics(),
// controller: _tabController,
// children: [
// DetailsInfo(
// product: widget.product,
// ),
// ReviewsInfo(
// product: widget.product,
// ),
// AvailabilityInfo()
// ],
// ),
// ),
//
// ],
// ),
// ),
// ),
SizedBox(
height: 6,
),
//TODO Elham* Remove this
Container( Container(
// width: 500, // width: 500,
margin: EdgeInsets.only(bottom: 6), margin: EdgeInsets.only(bottom: 6),
@ -294,7 +215,14 @@ class __ProductDetailPageState extends State<ProductDetailPage>
Column( Column(
children: [ children: [
FlatButton( FlatButton(
onPressed: () { onPressed: () async {
if(widget.product.approvedTotalReviews>0) {
GifLoaderDialogUtils.showMyDialog(
context);
await model.getProductReviewsData(
widget.product.id);
GifLoaderDialogUtils.hideDialog(context);
}
setState(() { setState(() {
isDetails = false; isDetails = false;
isReviews = true; isReviews = true;
@ -322,7 +250,12 @@ class __ProductDetailPageState extends State<ProductDetailPage>
Column( Column(
children: [ children: [
FlatButton( FlatButton(
onPressed: () { onPressed: () async {
GifLoaderDialogUtils.showMyDialog(
context);
await model.getProductLocationData();
GifLoaderDialogUtils.hideDialog(context);
setState(() { setState(() {
isDetails = false; isDetails = false;
isReviews = false; isReviews = false;
@ -356,32 +289,16 @@ class __ProductDetailPageState extends State<ProductDetailPage>
: isReviews : isReviews
? ReviewsInfo( ? ReviewsInfo(
product: widget.product, product: widget.product,
previousModel: model,
) )
: isAvailability : isAvailability
? AvailabilityInfo() ? AvailabilityInfo(
previousModel: model,
)
: Container(), : Container(),
], ],
), ),
), ),
///TODO Elham* check if we need recommanded
// Row(
// children: [
// customerId != null
// ? Container(
// width: 410,
// height: 50,
// color: Colors.white,
// child: Texts(
// TranslationBase.of(context).recommended,
// bold: true,
// ),
// )
// : Container(),
// ],
// ),
// RecommendedProducts(product: widget.product)
SizedBox( SizedBox(
height: 80, height: 80,
) )
@ -394,87 +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 { addToWishlistFunction({itemID, ProductDetailViewModel model}) async {
const CustomDivider({ isInWishList = true;
Key key, await model.addToWishlistData(itemID);
this.color, }
}) : super(key: key);
final Color color;
@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,ProductDetailViewModel model}) async {
}
addToCartFunction(quantity, itemID, BuildContext context) async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
ProductDetailViewModel x = new ProductDetailViewModel(); await model.addToCartData(quantity, itemID);
await x.addToCartData(quantity, itemID).then((value) {
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,
),
],
),
),
);
}

@ -10,7 +10,7 @@ import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart'; import 'package:rating_bar/rating_bar.dart';
import '../../../../locator.dart'; import '../../../../locator.dart';
import 'CustomIcon.dart'; import 'shared/icon_with_bg.dart';
class ProductNameAndPrice extends StatefulWidget { class ProductNameAndPrice extends StatefulWidget {
BuildContext context; BuildContext context;

@ -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,143 +55,124 @@ 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: margin: EdgeInsets.symmetric(
BorderRadius
.circular(10),
),
margin:
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]
.isinwishlist !=
true true
? Colors ? Colors.grey
.grey : Colors.red,
: Colors onPressed: () async {
.red, if (widget.customerId != null) {
onPressed: if (!widget.isInWishList &&
() async { model
if (customerId != .recommendedProductList[
null) { index]
if (!isInWishList && .isinwishlist !=
model.recommendedProductList[index].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();
}); });
}, },
@ -183,38 +180,34 @@ class _RecommendedProductsState extends State<RecommendedProducts> {
), ),
), ),
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
.center,
child: (model.recommendedProductList[index].images !=
null && null &&
model.recommendedProductList[index].images.length > model
.recommendedProductList[
index]
.images
.length >
0) 0)
? Image ? Image.network(
.network(
model model
.recommendedProductList[index] .recommendedProductList[
index]
.images[0] .images[0]
.src .src
.toString(), .toString(),
fit: BoxFit fit: BoxFit.cover,
.cover, height: 60,
height:
60,
) )
: Image : Image.asset(
.asset(
"assets/images/no_image.png", "assets/images/no_image.png",
fit: BoxFit fit: BoxFit.cover,
.cover, height: 60,
height:
60,
), ),
), ),
Container( Container(
@ -228,84 +221,69 @@ class _RecommendedProductsState extends State<RecommendedProducts> {
.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: child: model
BorderRadius .recommendedProductList[
.only( index]
topLeft: Radius
.circular(
6),
),
),
child: model.recommendedProductList[index]
.rxMessage != .rxMessage !=
null 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[
index]
.name, .name,
style: style: TextStyle(
TextStyle( color: Colors.black,
color: Colors fontSize: 13.0,
.black,
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,
), ),
]), ]),
], ],
@ -365,13 +331,11 @@ 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) TranslationBase.of(context).nonRecommended,
.nonRecommended,
color: Colors.black, color: Colors.black,
), ),
], ],

@ -1,28 +1,22 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rating_bar/rating_bar.dart'; import 'package:rating_bar/rating_bar.dart';
class ReviewsInfo extends StatelessWidget { class ReviewsInfo extends StatelessWidget {
final PharmacyProduct product; final PharmacyProduct product;
final ProductDetailViewModel previousModel;
const ReviewsInfo({Key key, this.product}) : super(key: key); const ReviewsInfo({Key key, this.product, this.previousModel}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<ProductDetailViewModel>( return previousModel.productDetailService.length != 0 &&
onModelReady: (model) => model.getProductReviewsData(product.id), previousModel.productDetailService[0].reviews.length != 0
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
baseViewModel:model ,
child: model.productDetailService.length != 0 &&
model.productDetailService[0].reviews.length != 0
? ListView.builder( ? ListView.builder(
physics: ScrollPhysics(), physics: ScrollPhysics(),
itemCount: model.productDetailService[0].reviews.length, itemCount: previousModel.productDetailService[0].reviews.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
@ -37,7 +31,7 @@ class ReviewsInfo extends StatelessWidget {
children: [ children: [
Container( Container(
child: Text( child: Text(
model.productDetailService[0].reviews[index] previousModel.productDetailService[0].reviews[index]
.customerId .customerId
.toString(), .toString(),
style: TextStyle( style: TextStyle(
@ -49,7 +43,7 @@ class ReviewsInfo extends StatelessWidget {
Container( Container(
margin: EdgeInsets.only(left: 210), margin: EdgeInsets.only(left: 210),
child: RatingBar.readOnly( child: RatingBar.readOnly(
initialRating: model.productDetailService[0] initialRating: previousModel.productDetailService[0]
.reviews[index].rating .reviews[index].rating
.toDouble(), .toDouble(),
size: 15.0, size: 15.0,
@ -69,7 +63,7 @@ class ReviewsInfo extends StatelessWidget {
), ),
Container( Container(
child: Text( child: Text(
model.productDetailService[0].reviews[index] previousModel.productDetailService[0].reviews[index]
.reviewText, .reviewText,
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
), ),
@ -90,8 +84,6 @@ class ReviewsInfo extends StatelessWidget {
TranslationBase.of(context).noReviewsAvailable, TranslationBase.of(context).noReviewsAvailable,
), ),
// Text('No Reviews Available'), // Text('No Reviews Available'),
),
),
); );
} }
} }

@ -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,
);
}
}

@ -11,7 +11,6 @@ class IconWithBg extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
// margin: EdgeInsets.only(left: 25),
width: 40, width: 40,
height: 40, height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(

@ -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';
@ -7,16 +8,20 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../../../locator.dart'; import '../../../../../locator.dart';
import '../../compare-list.dart'; import '../../../compare-list.dart';
import '../cart-order-page.dart'; import '../../cart-order-page.dart';
import 'CustomIcon.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>();
@ -25,7 +30,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
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,7 +51,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
), ),
], ],
), ),
if(authenticatedUserObject.isLogin) if (authenticatedUserObject.isLogin)
Row( Row(
children: [ children: [
IconWithBg( IconWithBg(
@ -60,7 +64,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
builder: (context) => CartOrderPage()), builder: (context) => CartOrderPage()),
); );
}), }),
SizedBox(width: 10,), SizedBox(
width: 10,
),
IconWithBg( IconWithBg(
icon: FontAwesomeIcons.ellipsisV, icon: FontAwesomeIcons.ellipsisV,
color: Colors.grey, color: Colors.grey,
@ -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,15 +95,21 @@ 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)} {
addToCartFunction(
quantity: quantity,
itemID: itemID,
context: context,
model: model)
}
else else
{ {
AppToast.showErrorToast( AppToast.showErrorToast(
@ -112,7 +121,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
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 {
}); });
} }
} }

@ -35,8 +35,14 @@ class _AddAddressPageState extends State<AddAddressPage> {
} else { } else {
_getCurrentLocation(); _getCurrentLocation();
} }
setState(() {
});
} }
_getCurrentLocation() async { _getCurrentLocation() async {
await Geolocator.getLastKnownPosition().then((value) { await Geolocator.getLastKnownPosition().then((value) {
_latitude = value.latitude; _latitude = value.latitude;
@ -44,9 +50,12 @@ class _AddAddressPageState extends State<AddAddressPage> {
}).catchError((e) { }).catchError((e) {
_longitude = 0; _longitude = 0;
_latitude = 0; _latitude = 0;
}); });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context); final mediaQuery = MediaQuery.of(context);
@ -63,8 +72,8 @@ class _AddAddressPageState extends State<AddAddressPage> {
body: Container( body: Container(
height: height * 1, height: height * 1,
child: PickupLocationFromMap( child: PickupLocationFromMap(
latitude: _latitude, latitude: _latitude??0,
longitude: _longitude, longitude: _longitude??0,
isWithAppBar: false, isWithAppBar: false,
buttonColor: Color(0xFF5AB145), buttonColor: Color(0xFF5AB145),
buttonLabel: TranslationBase.of(context).save, buttonLabel: TranslationBase.of(context).save,

@ -29,7 +29,7 @@ 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.noBorderRadius = false, this.borderRadius, this.disableColor})
: super(key: key); : super(key: key);
final String label; final String label;
@ -44,6 +44,7 @@ class SecondaryButton extends StatefulWidget {
final bool disabled; final bool disabled;
final bool noBorderRadius; final bool noBorderRadius;
final double borderRadius; final double borderRadius;
final Color disableColor;
@ -183,7 +184,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
height: 100, height: 100,
decoration: BoxDecoration( decoration: BoxDecoration(
color: widget.disabled color: widget.disabled
? Colors.grey ? widget.disableColor??Colors.grey
: widget.color ?? Theme.of(context).buttonColor), : widget.color ?? Theme.of(context).buttonColor),
), ),
), ),

@ -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