@ -30,8 +30,13 @@ class FooterWidget extends StatefulWidget {
int quantity ;
bool isOverQuantity ;
FooterWidget ( this . isAvailable , this . maxQuantity , this . minQuantity , this . quantityLimit , this . item ,
{ this . quantity , this . isOverQuantity = false , this . addToCartFunction , this . addToShoppingCartFunction , this . model } ) ;
FooterWidget ( this . isAvailable , this . maxQuantity , this . minQuantity ,
this . quantityLimit , this . item ,
{ this . quantity ,
this . isOverQuantity = false ,
this . addToCartFunction ,
this . addToShoppingCartFunction ,
this . model } ) ;
@ override
_FooterWidgetState createState ( ) = > _FooterWidgetState ( ) ;
@ -42,7 +47,8 @@ class _FooterWidgetState extends State<FooterWidget> {
bool showUI = false ;
static final GlobalKey < FormState > _key = GlobalKey < FormState > ( ) ;
AuthenticatedUserObject authenticatedUserObject = locator < AuthenticatedUserObject > ( ) ;
AuthenticatedUserObject authenticatedUserObject =
locator < AuthenticatedUserObject > ( ) ;
AppSharedPreferences sharedPref = new AppSharedPreferences ( ) ;
@ override
@ -96,7 +102,11 @@ class _FooterWidgetState extends State<FooterWidget> {
children: [
Padding (
padding: const EdgeInsets . all ( 8.0 ) ,
child: Texts ( TranslationBase . of ( context ) . productQuantity , fontSize: 15 , fontWeight: FontWeight . bold , color: Color ( 0xFF575757 ) ) ,
child: Texts (
TranslationBase . of ( context ) . productQuantity ,
fontSize: 15 ,
fontWeight: FontWeight . bold ,
color: Color ( 0xFF575757 ) ) ,
) ,
InkWell (
child: Icon ( Icons . close , color: Colors . black ) ,
@ -118,7 +128,11 @@ class _FooterWidgetState extends State<FooterWidget> {
SizedBox (
width: 5 ,
) ,
for ( int i = 1 ; i < = 10 ; i + + ) QuantityBox ( label: i , onTapFunc: onChangeValue , isSelected: widget . quantity = = i ) ,
for ( int i = 1 ; i < = 10 ; i + + )
QuantityBox (
label: i ,
onTapFunc: onChangeValue ,
isSelected: widget . quantity = = i ) ,
Container (
width: 100 ,
decoration: BoxDecoration (
@ -129,14 +143,16 @@ class _FooterWidgetState extends State<FooterWidget> {
key: _key ,
keyboardType: TextInputType . number ,
textAlign: TextAlign . center ,
decoration: InputDecoration ( hintText: ' Quantity # ' ) ,
decoration:
InputDecoration ( hintText: ' Quantity # ' ) ,
onChanged: ( text ) {
if ( int . tryParse ( text ) = = null ) {
text = ' ' ;
} else {
setState ( ( ) {
widget . quantity = int . parse ( text ) ;
if ( widget . quantity > = widget . quantityLimit ) {
if ( widget . quantity > =
widget . quantityLimit ) {
widget . isOverQuantity = true ;
} else {
widget . isOverQuantity = false ;
@ -224,7 +240,7 @@ class _FooterWidgetState extends State<FooterWidget> {
) ,
Container (
width: MediaQuery . of ( context ) . size . width * 0.35 ,
margin: EdgeInsets . symmetric ( vertical: 5 .0) ,
margin: EdgeInsets . symmetric ( vertical: 4 .0) ,
child: SecondaryButton (
label: TranslationBase . of ( context ) . addToCart ,
disabled: isAddToCartDisable ( ) ,
@ -233,12 +249,16 @@ class _FooterWidgetState extends State<FooterWidget> {
if ( ! authenticatedUserObject . isLogin ) {
login ( ) ;
} else
await widget . addToCartFunction ( quantity: widget . quantity , itemID: widget . item . id , model: widget . model ) ;
await widget . addToCartFunction (
quantity: widget . quantity ,
itemID: widget . item . id ,
model: widget . model ) ;
} ,
fontWeight: FontWeight . w600 ,
borderRadius: 6 ,
disableColor: Color ( 0xFFD6D6D6 ) ,
textColor: isAddToCartDisable ( ) ? Color ( 0xFFACACAC ) : Colors . white ,
textColor:
isAddToCartDisable ( ) ? Color ( 0xFFACACAC ) : Colors . white ,
color: Color ( 0xFF535353 ) ,
) ,
) ,
@ -247,7 +267,7 @@ class _FooterWidgetState extends State<FooterWidget> {
) ,
Container (
width: MediaQuery . of ( context ) . size . width * 0.35 ,
margin: EdgeInsets . symmetric ( vertical: 5 .0) ,
margin: EdgeInsets . symmetric ( vertical: 4 .0) ,
child: SecondaryButton (
label: TranslationBase . of ( context ) . buyNow ,
fontSize: 15 ,
@ -256,10 +276,14 @@ class _FooterWidgetState extends State<FooterWidget> {
if ( ! authenticatedUserObject . isLogin ) {
login ( ) ;
} else {
await widget . addToShoppingCartFunction ( quantity: widget . quantity , itemID: widget . item . id , model: widget . model ) ;
await widget . addToShoppingCartFunction (
quantity: widget . quantity ,
itemID: widget . item . id ,
model: widget . model ) ;
}
} ,
textColor: isBuyNowDisable ( ) ? Color ( 0xFFACACAC ) : Colors . white ,
textColor:
isBuyNowDisable ( ) ? Color ( 0xFFACACAC ) : Colors . white ,
fontWeight: FontWeight . w600 ,
borderRadius: 6 ,
disableColor: Color ( 0xFFD6D6D6 ) ,
@ -275,11 +299,15 @@ class _FooterWidgetState extends State<FooterWidget> {
}
bool isBuyNowDisable ( ) {
return ( ! widget . isAvailable & & widget . quantity > 0 ) | | ( widget . quantity > widget . quantityLimit ) | | widget . item . isRx ;
return ( ! widget . isAvailable & & widget . quantity > 0 ) | |
( widget . quantity > widget . quantityLimit ) | |
widget . item . isRx ;
}
bool isAddToCartDisable ( ) {
return ( ! widget . isAvailable & & widget . quantity > 0 ) | | widget . quantity > widget . quantityLimit | | widget . item . isRx ;
return ( ! widget . isAvailable & & widget . quantity > 0 ) | |
widget . quantity > widget . quantityLimit | |
widget . item . isRx ;
}
void setUserValues ( value ) async {
@ -294,7 +322,9 @@ class _FooterWidgetState extends State<FooterWidget> {
Navigator . of ( context ) . pushNamed ( CONFIRM_LOGIN ) ;
} else {
GifLoaderDialogUtils . showMyDialog ( context ) ;
authService . selectDeviceImei ( DEVICE_TOKEN ) . then ( ( SelectDeviceIMEIRES value ) {
authService
. selectDeviceImei ( DEVICE_TOKEN )
. then ( ( SelectDeviceIMEIRES value ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( value ! = null ) {
setUserValues ( value ) ;