@ -1,23 +1,22 @@
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
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/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/pharmacyModule/product_detail_view_model.dart ' ;
import ' package:diplomaticquarterapp/pages/base/base_view.dart ' ;
import ' package:diplomaticquarterapp/pages/base/base_view.dart ' ;
import ' package:diplomaticquarterapp/pages/login/welcome.dart ' ;
import ' package:diplomaticquarterapp/pages/pharmacies/compare-list.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.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/transitions/fade_page.dart ' ;
import ' package:diplomaticquarterapp/widgets/transitions/fade_page.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.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 ' package:rating_bar/rating_bar.dart ' ;
import ' package:rating_bar/rating_bar.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' screens/cart-order-page.dart ' ;
import ' screens/cart-order-page.dart ' ;
import ' package:diplomaticquarterapp/pages/pharmacies/compare-list.dart ' ;
int price = 0 ;
int price = 0 ;
var languageID ;
var languageID ;
@ -30,7 +29,9 @@ PharmacyProduct specificationData;
class ProductDetailPage extends StatefulWidget {
class ProductDetailPage extends StatefulWidget {
final PharmacyProduct product ;
final PharmacyProduct product ;
ProductDetailPage ( this . product ) ;
ProductDetailPage ( this . product ) ;
@ override
@ override
__ProductDetailPageState createState ( ) = > __ProductDetailPageState ( ) ;
__ProductDetailPageState createState ( ) = > __ProductDetailPageState ( ) ;
}
}
@ -42,8 +43,10 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
bool isAvailabilty = false ;
bool isAvailabilty = false ;
dynamic wishlistItems ;
dynamic wishlistItems ;
var model ;
var model ;
/ / String ProductId = " 4561 " ;
/ / String ProductId = " 4561 " ;
String productId = " " ;
String productId = " " ;
checkWishlist ( ) async {
checkWishlist ( ) async {
GifLoaderDialogUtils . showMyDialog ( context ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
ProductDetailViewModel x = new ProductDetailViewModel ( ) ;
ProductDetailViewModel x = new ProductDetailViewModel ( ) ;
@ -62,6 +65,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
}
}
void initState ( ) {
void initState ( ) {
price = 1 ;
price = 1 ;
specificationData = widget . product ;
specificationData = widget . product ;
@ -613,21 +617,20 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
Container (
Container (
width: 410 ,
width: 410 ,
height: 50 ,
height: 50 ,
/ / margin: EdgeInsets . only ( bottom: 5 ) ,
/ / margin: EdgeInsets . only ( bottom: 5 ) ,
color: Colors . white ,
color: Colors . white ,
child: Texts (
child: Texts (
TranslationBase . of ( context ) . recommended ,
TranslationBase . of ( context ) . recommended ,
bold: true ,
bold: true ,
) ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
SingleChildScrollView (
SingleChildScrollView (
child: Container (
child: Container (
color: Colors . white ,
color: Colors . white ,
child: Column (
child: Column (
/ / crossAxisAlignment: CrossAxisAlignment . start ,
/ / crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisAlignment: MainAxisAlignment . start ,
mainAxisAlignment: MainAxisAlignment . start ,
/ / mainAxisSize: MainAxisSize . min ,
/ / mainAxisSize: MainAxisSize . min ,
children: [
children: [
@ -636,208 +639,252 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
height: 210 ,
height: 210 ,
margin: EdgeInsets . only ( bottom: 75 ) ,
margin: EdgeInsets . only ( bottom: 75 ) ,
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 ) = >
onModelReady: ( model ) = >
model . getRecommendedProducts ( widget . product . id . toString ( ) ) ,
model . getRecommendedProducts (
builder: ( _ , model , wi ) = >
widget . product . id . toString ( ) ) ,
Container (
builder: ( _ , model , wi ) = > Container (
child:
child:
/ / Text ( model . recommendedProductList [ 0 ] . id ) ,
/ / Text ( model . recommendedProductList [ 0 ] . id ) ,
model . recommendedProductList . length ! = null
model . recommendedProductList . length ! =
? Expanded (
null
child: ListView . builder (
? Expanded (
scrollDirection: Axis . horizontal ,
child: ListView . builder (
shrinkWrap: true ,
scrollDirection:
physics: ScrollPhysics ( ) ,
Axis . horizontal ,
/ / physics: NeverScrollableScrollPhysics ( ) ,
shrinkWrap: true ,
itemCount: model . recommendedProductList . length ,
physics: ScrollPhysics ( ) ,
itemBuilder: ( context , index ) {
/ / physics: NeverScrollableScrollPhysics ( ) ,
return Card (
itemCount: model
elevation: 2 ,
. recommendedProductList
shape: RoundedRectangleBorder (
. length ,
side: BorderSide (
itemBuilder:
color: Colors . grey [ 300 ] , width: 2 ) ,
( context , index ) {
borderRadius: BorderRadius . circular ( 10 ) ) ,
return Card (
margin: EdgeInsets . symmetric (
elevation: 2 ,
horizontal: 8 ,
shape: RoundedRectangleBorder (
vertical: 0 ,
side: BorderSide (
) ,
color: Colors
child: Container (
. grey [
decoration: BoxDecoration (
300 ] ,
borderRadius: BorderRadius . all (
width: 2 ) ,
Radius . circular ( 15 ) ,
borderRadius:
) ,
BorderRadius
) ,
. circular (
padding: EdgeInsets . symmetric ( horizontal: 4 ) ,
10 ) ) ,
width: MediaQuery . of ( context ) . size . width / 3 ,
margin: EdgeInsets
child: Column (
. symmetric (
crossAxisAlignment:
horizontal: 8 ,
CrossAxisAlignment . start ,
vertical: 0 ,
children: [
Stack ( children: [
Container (
child: Align (
alignment: Alignment . topRight ,
child: / / true
itemID . contains ( model . recommendedProductList [ index ] . id )
/ / ! isInWishlist
? IconButton (
icon: Icon ( Icons
. favorite_border ) ,
color: Colors . grey ,
iconSize: 30 ,
onPressed: ( ) {
setState ( ( ) {
addToWishlistFunction ( itemID ) ;
} ) ;
} ,
)
: IconButton (
icon: Icon (
Icons . favorite ) ,
color: Colors . red ,
iconSize: 30 ,
onPressed: ( ) {
setState ( ( ) {
deleteFromWishlistFunction ( itemID ) ;
} ) ;
} ,
)
/ /
) ,
) ,
) ,
child: Container (
Container (
decoration:
margin: EdgeInsets . fromLTRB (
BoxDecoration (
0 , 16 , 10 , 16 ) ,
borderRadius:
alignment: Alignment . center ,
BorderRadius
. all (
Radius . circular (
15 ) ,
) ,
) ,
padding: EdgeInsets
. symmetric (
horizontal:
4 ) ,
width: MediaQuery . of (
context )
. size
. width /
3 ,
child: Column (
crossAxisAlignment:
CrossAxisAlignment
. start ,
children: [
Stack (
children: [
Container (
child: Align (
alignment: Alignment . topRight ,
child: / / true
itemID . contains ( model . recommendedProductList [ index ] . id )
/ / ! isInWishlist
? IconButton (
icon: Icon ( Icons . favorite_border ) ,
color: Colors . grey ,
iconSize: 30 ,
onPressed: ( ) {
setState ( ( ) {
addToWishlistFunction ( itemID ) ;
} ) ;
} ,
)
: IconButton (
icon: Icon ( Icons . favorite ) ,
color: Colors . red ,
iconSize: 30 ,
onPressed: ( ) {
setState ( ( ) {
deleteFromWishlistFunction ( itemID ) ;
} ) ;
} ,
)
/ /
) ,
) ,
Container (
margin: EdgeInsets . fromLTRB (
0 ,
16 ,
10 ,
16 ) ,
alignment:
Alignment . center ,
/ / padding: EdgeInsets . only ( left: 25 , bottom: 20 ) ,
/ / padding: EdgeInsets . only ( left: 25 , bottom: 20 ) ,
child: ( model . recommendedProductList [ index ] . images ! = null & &
child: ( model . recommendedProductList [ index ] . images ! = null & &
model . recommendedProductList [ index ] . images . length > 0 )
model . recommendedProductList [ index ] . images . length > 0 )
? Image . network (
? Image . network (
model . recommendedProductList [ index ] . images [ 0 ] . src . toString ( ) ,
model . recommendedProductList [ index ] . images [ 0 ] . src . toString ( ) ,
/ / item . images [ 0 ] . src ,
/ / item . images [ 0 ] . src ,
fit: BoxFit . cover ,
fit: BoxFit . cover ,
height: 60 ,
height: 60 ,
)
)
: Image . asset (
: Image . asset (
" assets/images/no_image.png " ,
" assets/images/no_image.png " ,
fit: BoxFit . cover ,
fit: BoxFit . cover ,
height: 60 ,
height: 60 ,
) ,
) ,
) ,
) ,
Container (
Container (
width: model
width: model . recommendedProductList [ index ] . rxMessage ! =
. recommendedProductList [
null
index ]
? MediaQuery . of ( context ) . size . width /
. rxMessage ! =
5
null
: 0 ,
? MediaQuery . of ( context )
padding:
. size
EdgeInsets . all ( 4 ) ,
. width /
decoration:
5
BoxDecoration (
: 0 ,
color:
padding: EdgeInsets . all ( 4 ) ,
Color ( 0xffb23838 ) ,
decoration: BoxDecoration (
borderRadius:
color: Color ( 0xffb23838 ) ,
BorderRadius . only ( topLeft: Radius . circular ( 6 ) ) ,
borderRadius: BorderRadius . only (
) ,
topLeft: Radius . circular ( 6 ) ) ,
child:
) ,
Texts (
child: Texts (
model . recommendedProductList [ index ] . rxMessage ! = null
model . recommendedProductList [ index ]
? model . recommendedProductList [ index ] . rxMessage
. rxMessage ! =
: " " ,
null
color:
? model
Colors . white ,
. recommendedProductList [
regular:
index ]
true ,
. rxMessage
fontSize:
: " " ,
10 ,
color: Colors . white ,
fontWeight:
regular: true ,
FontWeight . w400 ,
fontSize: 10 ,
) ,
fontWeight: FontWeight . w400 ,
) ,
) ,
] ) ,
) ,
Container (
] ) ,
margin: EdgeInsets
Container (
. symmetric (
margin: EdgeInsets . symmetric (
horizontal:
horizontal: 6 ,
6 ,
vertical: 0 ,
vertical: 0 ,
) ,
) ,
child: Column (
child: Column (
crossAxisAlignment:
crossAxisAlignment:
CrossAxisAlignment . start ,
CrossAxisAlignment
children: [
. start ,
Text (
children: [
languageID = = " ar "
Text (
? model . recommendedProductList [ index ] . namen
languageID = =
: model . recommendedProductList [ index ] . name ,
" ar "
style: TextStyle (
? model . recommendedProductList [ index ] . namen
color: Colors . black ,
: model . recommendedProductList [ index ] . name ,
fontSize: 13.0 ,
style:
TextStyle (
color:
Colors . 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 . only (
padding: const EdgeInsets . only (
top: 10 , bottom: 5 ) ,
top:
child: Texts (
10 ,
" SAR ${ model . recommendedProductList [ index ] . price } " ,
bottom:
bold: true ,
5 ) ,
fontSize: 14 ,
child:
) ,
Texts (
) ,
" SAR ${ model . recommendedProductList [ index ] . price } " ,
] ,
bold:
) ,
true ,
) ,
fontSize:
Row (
14 ,
crossAxisAlignment:
) ,
CrossAxisAlignment . start ,
) ,
children: < Widget > [
] ,
Container (
) ,
padding:
) ,
EdgeInsets . only ( right: 10 ) ,
Row (
crossAxisAlignment:
CrossAxisAlignment
. start ,
children: <
Widget > [
Container (
padding:
EdgeInsets . only ( right: 10 ) ,
/ / margin: EdgeInsets . only ( left: 5 ) ,
/ / margin: EdgeInsets . only ( left: 5 ) ,
child: Align (
child:
alignment: Alignment . topLeft ,
Align (
child: RatingBar . readOnly (
alignment:
initialRating: model
Alignment . topLeft ,
. recommendedProductList [
child:
index ]
RatingBar . readOnly (
. approvedRatingSum
initialRating:
. toDouble ( ) ,
model . recommendedProductList [ index ] . approvedRatingSum . toDouble ( ) ,
/ / initialRating: productRate ,
/ / initialRating: productRate ,
size: 13.0 ,
size:
filledColor:
13.0 ,
Colors . yellow [ 700 ] ,
filledColor:
emptyColor: Colors . grey [ 500 ] ,
Colors . yellow [ 700 ] ,
isHalfAllowed: true ,
emptyColor:
halfFilledIcon:
Colors . grey [ 500 ] ,
Icons . star_half ,
isHalfAllowed:
filledIcon: Icons . star ,
true ,
emptyIcon: Icons . star ,
halfFilledIcon:
) ,
Icons . star_half ,
) ,
filledIcon:
) ,
Icons . star ,
Texts (
emptyIcon:
" ( ${ model . recommendedProductList [ index ] . approvedTotalReviews . toString ( ) } ) " ,
Icons . star ,
) ,
) ,
) ,
Texts (
" ( ${ model . recommendedProductList [ index ] . approvedTotalReviews . toString ( ) } ) " ,
/ / bold: true ,
/ / bold: true ,
fontSize: 12 ,
fontSize:
12 ,
) ,
] ) ,
] ,
) ,
) ,
] ) ,
) ,
] ,
) ;
) ,
} ) ,
) ,
)
) ;
: Container (
} ) ,
)
: Container (
/ / child: Text ( " NO DATA " ) ,
/ / child: Text ( " NO DATA " ) ,
) ,
) ,
)
) ) ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
@ -1341,8 +1388,10 @@ class footerWidget extends StatefulWidget {
final int minQuantity ;
final int minQuantity ;
final int quantityLimit ;
final int quantityLimit ;
final PharmacyProduct item ;
final PharmacyProduct item ;
footerWidget ( this . isAvailble , this . maxQuantity , this . minQuantity ,
footerWidget ( this . isAvailble , this . maxQuantity , this . minQuantity ,
this . quantityLimit , this . item ) ;
this . quantityLimit , this . item ) ;
@ override
@ override
_footerWidgetState createState ( ) = > _footerWidgetState ( ) ;
_footerWidgetState createState ( ) = > _footerWidgetState ( ) ;
}
}
@ -1350,6 +1399,7 @@ class footerWidget extends StatefulWidget {
class _footerWidgetState extends State < footerWidget > {
class _footerWidgetState extends State < footerWidget > {
double quantityUI = 70 ;
double quantityUI = 70 ;
bool showUI = false ;
bool showUI = false ;
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
return Container (
return Container (
@ -1752,7 +1802,7 @@ class _footerWidgetState extends State<footerWidget> {
)
)
: InkWell (
: InkWell (
onTap: ( ) {
onTap: ( ) {
addToCartFunction ( price , widget . item . id );
addToCartFunction ( price , widget . item . id , context );
} ,
} ,
child: Container (
child: Container (
alignment: Alignment . center ,
alignment: Alignment . center ,
@ -1792,11 +1842,10 @@ class _footerWidgetState extends State<footerWidget> {
: InkWell (
: InkWell (
onTap: ( ) {
onTap: ( ) {
print ( ' buy now ' ) ;
print ( ' buy now ' ) ;
addToCartFunction ( price , widget . item . id );
addToCartFunction ( price , widget . item . id , context );
Navigator . push (
Navigator . push (
context ,
context ,
FadePage ( page:
FadePage ( page: CartOrderPage ( ) ) ,
CartOrderPage ( ) ) ,
) ;
) ;
} ,
} ,
child: Container (
child: Container (
@ -1824,7 +1873,9 @@ class _footerWidgetState extends State<footerWidget> {
class productNameAndPrice extends StatefulWidget {
class productNameAndPrice extends StatefulWidget {
BuildContext context ;
BuildContext context ;
PharmacyProduct item ;
PharmacyProduct item ;
productNameAndPrice ( this . context , this . item ) ;
productNameAndPrice ( this . context , this . item ) ;
@ override
@ override
_productNameAndPriceState createState ( ) = > _productNameAndPriceState ( ) ;
_productNameAndPriceState createState ( ) = > _productNameAndPriceState ( ) ;
}
}
@ -2014,9 +2065,12 @@ getSpecificationData(itemID) async {
specificationData = await x . productSpecificationData ( itemID ) ;
specificationData = await x . productSpecificationData ( itemID ) ;
}
}
addToCartFunction ( quantity , itemID ) async {
addToCartFunction ( quantity , itemID , BuildContext context ) async {
GifLoaderDialogUtils . showMyDialog ( context ) ;
ProductDetailViewModel x = new ProductDetailViewModel ( ) ;
ProductDetailViewModel x = new ProductDetailViewModel ( ) ;
await x . addToCartData ( quantity , itemID ) ;
await x . addToCartData ( quantity , itemID ) . then ( ( value ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
} ) ;
}
}
notifyMeWhenAvailable ( context , itemId ) async {
notifyMeWhenAvailable ( context , itemId ) async {
@ -2071,7 +2125,7 @@ settingModalBottomSheet(context) {
title: Text ( ' Add to cart ' ) ,
title: Text ( ' Add to cart ' ) ,
onTap: ( ) = > {
onTap: ( ) = > {
if ( price > 0 )
if ( price > 0 )
{ addToCartFunction ( price , itemID )}
{ addToCartFunction ( price , itemID , context )}
else
else
{
{
AppToast . showErrorToast (
AppToast . showErrorToast (