@ -17,9 +17,10 @@ import 'package:provider/provider.dart';
import ' package:rating_bar/rating_bar.dart ' ;
import ' package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart ' ;
import ' screens/cart-order-page.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_shared_preferences.dart ' ;
int price = 0 ;
var languageID ;
dynamic languageID ;
bool isOverQuantity = false ;
bool isInWishlit = false ;
/ / int isSelected = 1 ;
@ -35,7 +36,7 @@ class ProductDetailPage extends StatefulWidget {
/ / final Products recommendedProducts ;
ProductDetailPage ( this . product , ) ;
ProductDetailPage ( this . product ) ;
@ override
@ -43,15 +44,20 @@ class ProductDetailPage extends StatefulWidget {
}
class __ProductDetailPageState extends State < ProductDetailPage > {
AppSharedPreferences sharedPref = AppSharedPreferences ( ) ;
bool isTrue = true ;
bool isDetails = true ;
bool isReviews = false ;
bool isAvailabilty = false ;
dynamic wishlistItems ;
var model ;
/ / var model ;
/ / String ProductId = " 4561 " ;
String productId = " " ;
/ / String productId = " " ;
getLanguageID ( ) async {
languageID = await sharedPref . getString ( APP_LANGUAGE ) ;
}
checkWishlist ( ) async {
GifLoaderDialogUtils . showMyDialog ( context ) ;
@ -72,11 +78,12 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
setState ( ( ) { } ) ;
}
void initState ( ) {
getLanguageID ( ) ;
price = 1 ;
specificationData = widget . product ;
userInfo ( ) ;
/ / recommendedData = widget . recommendedProducts ;
super . initState ( ) ;
}
@ -97,7 +104,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
Widget build ( BuildContext context ) {
return customerId ! = null
? DetailPageScafold (
appBarTitle: ' product detail page ' ,
appBarTitle: TranslationBase . of ( context ) . productDetails ,
isShowAppBar: true ,
isPharmacy: true ,
isShowDecPage: false ,
@ -125,7 +132,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
flex: 1 ,
child: Container (
alignment: Alignment . centerRight ,
child: languageID = = ' ar '
child: languageID = = " ar "
? Text (
widget . product
. discountDescriptionn ,
@ -166,7 +173,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
) ,
Container (
width: 500 ,
height: 15 0,
height: 22 0,
color: Colors . white ,
child: productNameAndPrice ( context , widget . product ) ,
) ,
@ -175,7 +182,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
) ,
Container (
width: 500 ,
height: 1 2 0,
height: 1 0 0,
color: Colors . white ,
child: Column (
mainAxisAlignment: MainAxisAlignment . start ,
@ -195,7 +202,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
padding: const EdgeInsets . all ( 8.0 ) ,
child: Container (
child: Text (
" there is no data " ,
TranslationBase . of ( context ) . noData ,
/ / " there is no data " ,
) ,
) ,
) ,
@ -335,10 +343,9 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
) ,
Container (
child: Text (
languageID = = ' ar '
languageID = = " ar "
? widget . product . fullDescriptionn
: widget . product
. fullDescription ? ?
: widget . product . fullDescription ? ?
" " ,
style: TextStyle (
fontSize: 16 ,
@ -507,7 +514,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
: Container (
padding: EdgeInsets . all ( 15 ) ,
alignment: Alignment . center ,
child: Text ( ' No Reviews Available ' ) ,
child: Text ( TranslationBase . of ( context ) . noReviewsAvailable , ) ,
/ / Text ( ' No Reviews Available ' ) ,
) ,
)
: isAvailabilty
@ -521,8 +529,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
? Container (
padding: EdgeInsets . all ( 15 ) ,
alignment: Alignment . center ,
child: Text (
' No location Available ' ) ,
child: Text ( TranslationBase . of ( context ) . noLocationAvailable , ) ,
/ / Text ( ' No location Available ' ) ,
)
: ListView . builder (
physics: ScrollPhysics ( ) ,
@ -614,14 +622,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
) ,
Row (
children: [
/ / Container (
/ / width: 500 ,
/ / height: 100 ,
/ / margin: EdgeInsets . only ( bottom: 100 ) ,
/ / color: Colors . white ,
/ / child: Text ( " ENAD TEST " ) ,
/ / ) ,
Container (
customerId ! = null ? Container (
width: 410 ,
height: 50 ,
/ / margin: EdgeInsets . only ( bottom: 5 ) ,
@ -630,7 +631,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
TranslationBase . of ( context ) . recommended ,
bold: true ,
) ,
) ,
)
: Container ( ) ,
] ,
) ,
SingleChildScrollView (
@ -653,7 +655,6 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
onModelReady: ( model ) = > model . getRecommendedProducts ( widget . product . id ) ,
builder: ( _ , model , wi ) = > Container (
child:
/ / Text ( model . recommendedProductList [ 0 ] . id ) ,
model . recommendedProductList . length ! = null
? Expanded (
child: ListView . builder (
@ -666,12 +667,17 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
itemBuilder: ( context , index ) {
return InkWell (
onTap: ( )
{
Navigator . push (
async {
GifLoaderDialogUtils . showMyDialog ( context ) ;
RecommendedProductModel data = model . recommendedProductList [ index ] ;
var json = data . toJson ( ) ;
PharmacyProduct product = new PharmacyProduct . fromJson ( json ) ;
await Navigator . pushReplacement (
context ,
FadePage (
page: ProductDetailPage ( widget . product . id ) ,
page: ProductDetailPage ( product) ,
) ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
} ,
child: Card (
elevation: 2 ,
@ -700,26 +706,26 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
child: Align (
alignment: Alignment . topRight ,
child: IconButton (
icon: Icon ( model . recommendedProductList [ index ] [' isinwishlist ' ] ! = true ? Icons . favorite_border : Icons . favorite ) ,
color: model . recommendedProductList [ index ] [' isinwishlist ' ] ! = true ? Colors . grey : Colors . red ,
icon: Icon ( model . recommendedProductList [ index ] .isinwishlist ! = true ? Icons . favorite_border : Icons . favorite ) ,
color: model . recommendedProductList [ index ] .isinwishlist ! = true ? Colors . grey : Colors . red ,
onPressed: ( ) async {
if ( customerId ! = null ) {
if ( ! isInWishlit & & model . recommendedProductList [ index ] [' isinwishlist ' ] ! = true ) {
if ( ! isInWishlit & & model . recommendedProductList [ index ] .isinwishlist ! = true ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
await addToWishlistFunction ( model . recommendedProductList [ index ] [' id ' ] ) ;
await addToWishlistFunction ( model . recommendedProductList [ index ] .id ) ;
/ / checkWishlist ( ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
setState ( ( ) {
model . recommendedProductList [ index ] [' isinwishlist ' ] = true ;
model . recommendedProductList [ index ] .isinwishlist = true ;
} ) ;
} else {
GifLoaderDialogUtils . showMyDialog ( context ) ;
await deleteFromWishlistFunction ( model . recommendedProductList [ index ] [' id ' ] ) ;
await deleteFromWishlistFunction ( model . recommendedProductList [ index ] .id ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
setState ( ( ) {
model . recommendedProductList [ index ] [' isinwishlist ' ] = false ;
model . recommendedProductList [ index ] .isinwishlist = false ;
} ) ;
}
} else {
@ -771,10 +777,10 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
alignment:
Alignment . center ,
/ / padding: EdgeInsets . only ( left: 25 , bottom: 20 ) ,
child: ( model . recommendedProductList [ index ] [' images ' ] ! = null & &
model . recommendedProductList [ index ] [' images ' ] . length > 0 )
child: ( model . recommendedProductList [ index ] .images ! = null & &
model . recommendedProductList [ index ] .images . length > 0 )
? Image . network (
model . recommendedProductList [ index ] [' images ' ] [ 0 ] [ ' src ' ] . toString ( ) ,
model . recommendedProductList [ index ] .images [ 0 ] . src . toString ( ) ,
/ / item . images [ 0 ] . src ,
fit: BoxFit . cover ,
height: 60 ,
@ -786,7 +792,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
) ,
) ,
Container (
width: model . recommendedProductList [ index ] [' rx_message ' ] ! =
width: model . recommendedProductList [ index ] .rxMessage ! =
null
? MediaQuery . of ( context ) . size . width /
5
@ -800,20 +806,16 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
borderRadius:
BorderRadius . only ( topLeft: Radius . circular ( 6 ) ) ,
) ,
child:
Texts (
model . recommendedProductList [ index ] [ ' rx_message ' ] ! = null
? model . recommendedProductList [ index ] [ ' rx_message ' ]
: " " ,
color:
Colors . white ,
regular:
true ,
fontSize:
10 ,
fontWeight:
FontWeight . w400 ,
) ,
child: model . recommendedProductList [ index ] . rxMessage ! = null
? Texts (
languageID = = " ar "
? model . recommendedProductList [ index ] . rxMessagen
: model . recommendedProductList [ index ] . rxMessage ,
color: Colors . white ,
regular: true ,
fontSize: 10 ,
fontWeight: FontWeight . w400 ,
) : Texts ( " " ) ,
) ,
] ) ,
Container (
@ -829,10 +831,9 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
. start ,
children: [
Text (
languageID = =
" ar "
? model . recommendedProductList [ index ] [ ' namen ' ]
: model . recommendedProductList [ index ] [ ' name ' ] ,
languageID = = " ar "
? model . recommendedProductList [ index ] . namen
: model . recommendedProductList [ index ] . name ,
style:
TextStyle (
color:
@ -851,7 +852,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
5 ) ,
child:
Texts (
" SAR ${ model . recommendedProductList [ index ] [' price ' ] } " ,
" SAR ${ model . recommendedProductList [ index ] .price } " ,
bold:
true ,
fontSize:
@ -877,8 +878,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
Alignment . topLeft ,
child:
RatingBar . readOnly (
initialRating:
model . recommendedProductList [ index ] [ ' approved_rating_sum ' ] . toDouble ( ) ,
initialRating: model . recommendedProductList [ index ] . approvedRatingSum . toDouble ( ) ,
/ / initialRating: productRate ,
size:
13.0 ,
@ -898,7 +898,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
) ,
) ,
Texts (
" ( ${ model . recommendedProductList [ index ] [' approved_total_reviews ' ] . toString ( ) } ) " ,
" ( ${ model . recommendedProductList [ index ] .notApprovedTotalReviews . toString ( ) } ) " ,
/ / bold: true ,
fontSize:
12 ,
@ -939,7 +939,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
widget . product ) ,
)
: AppScaffold (
appBarTitle: ' product detail page ' ,
appBarTitle: TranslationBase . of ( context ) . productDetails ,
isShowAppBar: true ,
isPharmacy: true ,
isShowDecPage: false ,
@ -1319,7 +1319,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
: Container (
padding: EdgeInsets . all ( 15 ) ,
alignment: Alignment . center ,
child: Text ( ' No Reviews Available ' ) ,
child: Text ( TranslationBase . of ( context ) . noReviewsAvailable ) ,
/ / Text ( ' No Reviews Available ' ) ,
) ,
)
: isAvailabilty
@ -1936,7 +1937,8 @@ class _productNameAndPriceState extends State<productNameAndPrice> {
width: 40 ,
) ,
Text (
widget . item . stockAvailability ,
languageID = = ' ar ' ?
widget . item . stockAvailabilityn : widget . item . stockAvailability ,
style: widget . item . stockAvailability = = ' Out of stock '
? TextStyle ( fontWeight: FontWeight . bold , color: Colors . red )
: TextStyle (
@ -1982,7 +1984,9 @@ class _productNameAndPriceState extends State<productNameAndPrice> {
onPressed: ( ) async {
if ( customerId ! = null ) {
if ( ! isInWishlit ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
await addToWishlistFunction ( widget . item . id ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
} else {
await deleteFromWishlistFunction ( widget . item . id ) ;
}
@ -2094,9 +2098,9 @@ fixingString(txt) {
return newTxt ;
}
getLanguageID ( ) async {
languageID = await sharedPref . getString ( APP_LANGUAGE ) ;
}
/ / getLanguageID ( ) async {
/ / languageID = await sharedPref . getString ( APP_LANGUAGE ) ;
/ / }
getSpecificationData ( itemID ) async {
ProductDetailViewModel x = new ProductDetailViewModel ( ) ;
@ -2161,7 +2165,8 @@ settingModalBottomSheet(context) {
children: < Widget > [
new ListTile (
leading: Icon ( Icons . shopping_cart ) ,
title: Text ( ' Add to cart ' ) ,
title: Text ( TranslationBase . of ( context )
. addToCart , ) ,
onTap: ( ) = > {
if ( price > 0 )
{ addToCartFunction ( price , itemID , context ) }
@ -2173,12 +2178,14 @@ settingModalBottomSheet(context) {
} ) ,
ListTile (
leading: Icon ( Icons . favorite_border ) ,
title: Text ( ' Add to wishlist ' ) ,
title: Text ( TranslationBase . of ( context )
. addToWishlist , ) ,
onTap: ( ) = > { addToWishlistFunction ( itemID ) } ,
) ,
ListTile (
leading: Icon ( Icons . compare ) ,
title: Text ( ' Compare ' ) ,
title: Text ( TranslationBase . of ( context )
. compare , ) ,
onTap: ( ) = > {
Provider . of < CompareList > ( context , listen: false )
. addItem ( specificationData ) ,