import ' package:auto_size_text/auto_size_text.dart ' ;
import ' package:badges/badges.dart ' as badge_import ;
import ' package:barcode_scan2/barcode_scan2.dart ' ;
import ' package:flutter_svg/flutter_svg.dart ' ;
import ' package:hmg_patient_app/config/config.dart ' ;
import ' package:hmg_patient_app/config/shared_pref_kay.dart ' ;
import ' package:hmg_patient_app/core/model/ImagesInfo.dart ' ;
import ' package:hmg_patient_app/core/model/pharmacies/PharmacyProduct.dart ' ;
import ' package:hmg_patient_app/core/service/AuthenticatedUserObject.dart ' ;
import ' package:hmg_patient_app/core/service/client/base_app_client.dart ' ;
import ' package:hmg_patient_app/core/viewModels/PharmacyPagesViewModel.dart ' ;
import ' package:hmg_patient_app/core/viewModels/base_view_model.dart ' ;
import ' package:hmg_patient_app/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart ' ;
import ' package:hmg_patient_app/core/viewModels/project_view_model.dart ' ;
import ' package:hmg_patient_app/pages/landing/landing_page.dart ' ;
import ' package:hmg_patient_app/pages/landing/landing_page_pharmcy.dart ' ;
import ' package:hmg_patient_app/pages/pharmacies/screens/product-details/product-detail.dart ' ;
import ' package:hmg_patient_app/pages/search_products_page.dart ' ;
import ' package:hmg_patient_app/services/robo_search/event_provider.dart ' ;
import ' package:hmg_patient_app/theme/colors.dart ' ;
import ' package:hmg_patient_app/uitl/app_shared_preferences.dart ' ;
import ' package:hmg_patient_app/uitl/app_toast.dart ' ;
import ' package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart ' ;
import ' package:hmg_patient_app/uitl/navigation_service.dart ' ;
import ' package:hmg_patient_app/uitl/translations_delegate_base.dart ' ;
import ' package:hmg_patient_app/uitl/utils.dart ' ;
import ' package:hmg_patient_app/uitl/utils_new.dart ' ;
import ' package:hmg_patient_app/widgets/data_display/text.dart ' ;
import ' package:hmg_patient_app/widgets/drawer/langauge_picker.dart ' ;
import ' package:hmg_patient_app/widgets/pharmacy/bottom_nav_pharmacy_bar.dart ' ;
import ' package:hmg_patient_app/widgets/progress_indicator/app_loader_widget.dart ' ;
import ' package:hmg_patient_app/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 ' ../../locator.dart ' ;
import ' ../progress_indicator/app_loader_widget.dart ' ;
import ' arrow_back.dart ' ;
import ' floating_button_search.dart ' ;
import ' network_base_view.dart ' ;
import ' not_auh_page.dart ' ;
VoidCallback ? _onCartClick ;
class AppScaffold extends StatefulWidget {
final String appBarTitle ;
final Widget body ;
final Widget ? bottomSheet ;
final Widget ? bottomNavigationBar ;
final bool isLoading ;
final bool isShowAppBar ;
final bool showNewAppBar ;
final bool showNewAppBarTitle ;
final bool ? hasAppBarParam ;
final BaseViewModel ? baseViewModel ;
final bool isBottomBar ;
final Widget ? floatingActionButton ;
final bool isPharmacy ;
final bool isOfferPackages ;
final bool showPharmacyCart ;
final bool showOfferPackagesCart ;
final String ? title ;
final String ? description ;
final bool isShowDecPage ;
final List < String > ? infoList ;
final Color ? backgroundColor ;
final double preferredSize ;
final bool showHomeAppBarIcon ;
final List < Widget > ? appBarIcons ;
final List < ImagesInfo > ? imagesInfo ;
final bool isHelp ;
final bool isLocalLoader ;
final VoidCallback ? backButtonTab ;
final String ? icon ;
final bool showDropDown ;
final int ? dropdownIndexValue ;
List < String > ? dropDownList ;
final void Function ( int ? ) ? dropDownIndexChange ;
final Function ? onTap ;
final bool isMainPharmacyPages ;
final bool extendBody ;
final ValueChanged < int > ? changeCurrentTab ;
final int ? currentTab ;
final bool isShowPharmacyAppbar ;
final bool isshowBackButton ;
final Widget ? customAppBar ;
final bool isShowLanguageChanger ;
final bool resizeToAvoidBottomInset ;
final bool showCenteredLogo ;
final bool showLastLoginScreenBar ;
AppScaffold setOnAppBarCartClick ( VoidCallback onClick ) {
_onCartClick = onClick ;
return this ;
}
AppScaffold ( {
required this . body ,
this . appBarTitle = ' ' ,
this . isLoading = false ,
this . isShowAppBar = false ,
this . showNewAppBar = false ,
this . showNewAppBarTitle = false ,
this . isMainPharmacyPages = false ,
this . extendBody = false ,
this . hasAppBarParam ,
this . bottomSheet ,
this . bottomNavigationBar ,
this . baseViewModel ,
this . floatingActionButton ,
this . isPharmacy = false ,
this . showPharmacyCart = true ,
this . isOfferPackages = false ,
this . showDropDown = false ,
this . showOfferPackagesCart = false ,
this . title ,
this . description ,
this . isShowDecPage = true ,
this . isBottomBar = false ,
this . backgroundColor ,
this . preferredSize = 0.0 ,
this . appBarIcons ,
this . infoList ,
this . isHelp = false ,
this . icon ,
this . showHomeAppBarIcon = true ,
this . imagesInfo ,
this . dropDownList ,
this . dropdownIndexValue ,
this . dropDownIndexChange ,
this . onTap ,
appBar ,
this . customAppBar ,
this . isLocalLoader = false ,
this . isshowBackButton = true ,
this . backButtonTab ,
this . changeCurrentTab ,
this . currentTab ,
this . isShowPharmacyAppbar = false ,
this . isShowLanguageChanger = false ,
this . resizeToAvoidBottomInset = false ,
this . showCenteredLogo = false ,
this . showLastLoginScreenBar = false ,
} ) ;
@ override
_AppScaffoldState createState ( ) = > _AppScaffoldState ( ) ;
}
class _AppScaffoldState extends State < AppScaffold > {
AuthenticatedUserObject authenticatedUserObject = locator < AuthenticatedUserObject > ( ) ;
late AppBarWidget appBar ;
@ override
void initState ( ) {
// TODO: implement initState
super . initState ( ) ;
}
AppBar pharmacyAppbar ( ) {
return AppBar (
backgroundColor: Color ( 0xff5AB145 ) ,
elevation: 0 ,
title: Container (
height: MediaQuery . of ( context ) . size . height * 0.056 ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 5.0 ) ,
color: Colors . white ,
) ,
child: InkWell (
child: Padding (
padding: EdgeInsets . all ( 5.0 ) ,
child: Row (
//crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
Icon ( Icons . search , size: 25.0 ) ,
SizedBox (
width: 15.0 ,
) ,
Texts (
TranslationBase . of ( context ) . searchProductHere ,
fontSize: 13 ,
)
] ,
) ,
) ,
onTap: ( ) {
Navigator . push (
context ,
FadePage ( page: SearchProductsPage ( ) ) ,
) ;
} ,
) ,
) ,
leading: Builder (
builder: ( BuildContext context ) {
return InkWell (
onTap: ( ) {
Provider . of < PharmacyPagesViewModel > ( context , listen: false ) . changeCurrentTab ( 0 ) ;
} ,
child: Container (
height: 2.0 ,
width: 10.0 ,
child: Image . asset (
' assets/images/pharmacy_logo.png ' ,
) ,
) ,
) ;
} ,
) ,
actions: [
IconButton (
// iconSize: 70,
icon: Image . asset (
' assets/images/new-design/qr-code.png ' ,
) ,
onPressed: _scanQrAndGetProduct //do something,
)
] ,
centerTitle: true ,
) ;
}
@ override
Widget build ( BuildContext context ) {
AppGlobal . context = context ;
PharmacyPagesViewModel pagesViewModel = Provider . of ( context ) ;
bool isUserNotLogin = ( ! Provider . of < ProjectViewModel > ( context , listen: false ) . isLogin & & widget . isShowDecPage ) ;
return Scaffold (
backgroundColor: widget . backgroundColor ? ? CustomColors . appBackgroudGrey2Color ,
resizeToAvoidBottomInset: widget . resizeToAvoidBottomInset ,
// appBar: widget.isShowPharmacyAppbar
// ? pharmacyAppbar()
// : widget.isShowAppBar
// ? widget.customAppBar != null
// ? widget.customAppBar
extendBodyBehindAppBar: true ,
appBar: isUserNotLogin
? null
: widget . isShowPharmacyAppbar
? PreferredSize ( preferredSize: Size . fromHeight ( 60 ) , child: pharmacyAppbar ( ) )
: ( widget . showNewAppBar
? PreferredSize (
preferredSize: Size . fromHeight ( 60 ) ,
child: NewAppBarWidget (
title: widget . appBarTitle ,
showTitle: widget . showNewAppBarTitle ,
showDropDown: widget . showDropDown ,
dropdownIndexValue: widget . dropdownIndexValue ,
dropDownList: widget . dropDownList ? ? [ ] ,
isShowBackButton: widget . isshowBackButton ,
dropDownIndexChange: widget . dropDownIndexChange ,
appBarIcons: widget . appBarIcons ,
showCenterLogo: widget . showCenteredLogo ,
isShowLanguageChanger: widget . isShowLanguageChanger ,
showSavedLoginBar: widget . showLastLoginScreenBar ,
onTap: ( ) {
widget . onTap ;
} ,
) )
: ( widget . isShowAppBar
? widget . customAppBar ! = null
? PreferredSize ( preferredSize: Size . fromHeight ( 60 ) , child: widget . customAppBar ! )
: appBar = AppBarWidget (
appBarTitle: widget . appBarTitle ,
appBarIcons: widget . appBarIcons ,
showHomeAppBarIcon: widget . showHomeAppBarIcon ,
isPharmacy: widget . isPharmacy ,
showPharmacyCart: widget . showPharmacyCart ,
isOfferPackages: widget . isOfferPackages ,
isshowBackButton: widget . isshowBackButton ,
showOfferPackagesCart: widget . showOfferPackagesCart ,
isShowDecPage: widget . isShowDecPage ,
backButtonTab: ( ) {
widget . backButtonTab ;
} ,
)
: null ) ) ,
bottomSheet: widget . bottomSheet ,
body: SafeArea (
top: true ,
bottom: true ,
child: isUserNotLogin
? NotAutPage (
title: widget . title ? ? widget . appBarTitle ,
description: widget . description ,
infoList: widget . infoList ,
imagesInfo: widget . imagesInfo ,
icon: widget . icon ,
)
: widget . baseViewModel ! = null
? NetworkBaseView (
child: buildBodyWidget ( context ) ,
baseViewModel: widget . baseViewModel ,
)
: buildBodyWidget ( context ) ,
) ,
bottomNavigationBar: widget . isBottomBar
? BottomNavPharmacyBar (
changeIndex: changeCurrentTab ,
index: widget . currentTab = = null ? 0 : widget . currentTab ! ,
)
: null ,
floatingActionButton: widget . floatingActionButton ,
) ;
}
@ override
Size get preferredSize = > const Size . fromHeight ( kToolbarHeight ) ;
void changeCurrentTab ( int value ) {
if ( widget . isMainPharmacyPages ) {
widget . changeCurrentTab ! ( value ) ;
} else {
Navigator . pushAndRemoveUntil (
locator < NavigationService > ( ) . navigatorKey . currentContext ! , MaterialPageRoute ( builder: ( context ) = > LandingPagePharmacy ( currentTab: value ) ) , ( Route < dynamic > r ) = > false ) ;
}
}
void _scanQrAndGetProduct ( ) async {
try {
String ? result = ( await BarcodeScanner . scan ( ) ) ? . rawContent ! ;
try {
String barcode = result ! ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
await BaseAppClient ( ) . getPharmacy ( " $ GET_PHARMACY_PRODUCTs_BY_SKU $ barcode " , onSuccess: ( dynamic response , int statusCode ) {
print ( response ) ;
var product = PharmacyProduct . fromJson ( response [ " products " ] [ 0 ] ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
Navigator . push ( context , FadePage ( page: ProductDetailPage ( product ) ) ) ;
} , onFailure: ( String error , int statusCode ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: " Product not found " ) ;
} ) ;
} catch ( apiEx ) {
AppToast . showErrorToast ( message: " Something went wrong, please try again " ) ;
}
} catch ( barcodeEx ) { }
}
buildAppLoaderWidget ( bool isLoading ) {
return isLoading ? AppLoaderWidget ( ) : Container ( ) ;
}
buildBodyWidget ( context ) {
return Stack ( children: < Widget > [ widget . body , widget . isHelp = = true ? RobotIcon ( ) : Container ( ) ] ) ;
}
}
class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget {
final bool showTitle ;
bool isShowBackButton ;
final String title ;
final bool ? showDropDown ;
final int ? dropdownIndexValue ;
List < String > ? dropDownList ;
final void Function ( int ? ) ? dropDownIndexChange ;
final List < Widget > ? appBarIcons ;
final bool isShowLanguageChanger ;
final bool showCenterLogo ;
final bool showSavedLoginBar ;
String currentLang = ' ar ' ;
VoidCallback ? onTap ;
NewAppBarWidget ( {
Key ? key ,
this . showTitle = false ,
this . showDropDown = false ,
this . title = " " ,
this . dropDownList ,
this . appBarIcons ,
this . dropdownIndexValue ,
this . dropDownIndexChange ,
this . onTap ,
this . isShowBackButton = true ,
this . isShowLanguageChanger = false ,
this . showCenterLogo = false ,
this . showSavedLoginBar = false ,
} ) : super ( key: key ) ;
@ override
Widget build ( BuildContext context ) {
ProjectViewModel projectViewModel = Provider . of ( context ) ;
return AppBar (
elevation: 0 ,
backgroundColor: showTitle ? Colors . white : Colors . transparent ,
// backgroundColor: Colors.red,
// automaticallyImplyLeading: false,
leading: isShowBackButton & & showSavedLoginBar
? ArrowBack (
onTap: onTap ,
) . withHorizontalPadding ( 24 )
: isShowBackButton
? ArrowBack (
onTap: onTap ,
)
: null ,
// centerTitle: showCenterLogo,
titleSpacing: - 8 ,
// centerTitle: showSavedLoginBar,
title: showSavedLoginBar
? Row (
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
// SvgPicture.asset(
// 'assets/images/svg/card_user.svg',
// height: 32,
// width: 32,
// ).withHorizontalPadding(24),
if ( showCenterLogo ) Expanded ( child: SvgPicture . asset ( ' assets/images/svg/habiblogo.svg ' , height: 32 , width: 32 ) ) ,
if ( showDropDown ! & & isShowLanguageChanger )
Directionality (
textDirection: TextDirection . ltr ,
child: LanguageSelector (
currentLanguage: projectViewModel . isArabic ? ' ar ' : ' en ' ,
showOnlyIcon: true ,
onLanguageChanged: ( String value ) {
dropDownIndexChange ! ( value = = ' ar ' ? 1 : 0 ) ;
} ,
languages: [
{ ' code ' : ' ar ' , ' name ' : ' ${ TranslationBase . of ( context ) . lanEnglish } ' } ,
{ ' code ' : ' en ' , ' name ' : ' ${ TranslationBase . of ( context ) . lanArabic } ' }
] ,
) ,
) . withHorizontalPadding ( 24 ) ,
] ,
)
: Row (
crossAxisAlignment: CrossAxisAlignment . end ,
mainAxisAlignment: MainAxisAlignment . end ,
children: [
if ( showTitle )
Expanded (
child: Text (
title ,
maxLines: 1 ,
style: TextStyle (
fontSize: 24 , fontFamily: ( projectViewModel . isArabic ? ' Cairo ' : ' Poppins ' ) , fontWeight: FontWeight . w700 , color: Color ( 0xff2B353E ) , letterSpacing: - 1.44 , height: 35 / 24 ) ,
) ,
) ,
if ( showDropDown ! & & ! isShowLanguageChanger )
Container (
decoration: containerRadius ( Color ( 0xFFF7F7F7 ) , 30 ) ,
height: 30 ,
child: DropdownButtonHideUnderline (
child: ButtonTheme (
alignedDropdown: true ,
child: DropdownButton < int > (
iconEnabledColor: CustomColors . grey2 ,
style: TextStyle ( color: CustomColors . lightGreyColor , fontSize: 12 ) ,
dropdownColor: CustomColors . lightGreyColor ,
value: dropdownIndexValue ,
items: [
for ( int i = 0 ; i < dropDownList ! . length ; i + + )
DropdownMenuItem < int > (
value: i ,
child: AutoSizeText (
dropDownList ! [ i ] ,
style: TextStyle (
fontSize: 12 ,
fontFamily: ( projectViewModel . isArabic ? ' Cairo ' : ' Poppins ' ) ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B2E31 ) ,
letterSpacing: - . 48 ,
// height: 12 / 18
) ,
) ,
)
] ,
onChanged: dropDownIndexChange ,
underline: Container (
height: 0 ,
) ,
) ,
) ,
) ,
) ,
if ( showDropDown ! & & isShowLanguageChanger )
Padding (
padding: EdgeInsets . symmetric ( horizontal: 20 ) ,
child: Directionality (
textDirection: TextDirection . ltr ,
child: LanguageSelector (
currentLanguage: projectViewModel . isArabic ? ' ar ' : ' en ' ,
showOnlyIcon: false ,
onLanguageChanged: ( String value ) {
dropDownIndexChange ! ( value = = ' ar ' ? 1 : 0 ) ;
} ,
languages: [
{ ' code ' : ' ar ' , ' name ' : ' ${ TranslationBase . of ( context ) . lanEnglish } ' } ,
{ ' code ' : ' en ' , ' name ' : ' ${ TranslationBase . of ( context ) . lanArabic } ' }
] ,
) ,
) ,
) ,
] ,
) ,
// Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// if (showTitle)
// Expanded(
// child: Text(
// title,
// maxLines: 1,
// style: TextStyle(
// fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24),
// ),
// ),
// if (showDropDown! && !isShowLanguageChanger)
// Container(
// decoration: containerRadius(Color(0xFFF7F7F7), 30),
// height: 30,
// child: DropdownButtonHideUnderline(
// child: ButtonTheme(
// alignedDropdown: true,
// child: DropdownButton<int>(
// iconEnabledColor: CustomColors.grey2,
// style: TextStyle(color: CustomColors.lightGreyColor, fontSize: 12),
// dropdownColor: CustomColors.lightGreyColor,
// value: dropdownIndexValue,
// items: [
// for (int i = 0; i < dropDownList!.length; i++)
// DropdownMenuItem<int>(
// value: i,
// child: AutoSizeText(
// dropDownList![i],
// style: TextStyle(
// fontSize: 12,
// fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'),
// fontWeight: FontWeight.w600,
// color: Color(0xff2B2E31),
// letterSpacing: -.48,
// // height: 12 / 18
// ),
// ),
// )
// ],
// onChanged: dropDownIndexChange,
// underline: Container(
// height: 0,
// ),
// ),
// ),
// ),
// ),
// if (showDropDown! && isShowLanguageChanger)
// Expanded(
// child: Padding(
// padding: EdgeInsets.symmetric(horizontal: 25),
// child: Directionality(
// textDirection: TextDirection.ltr,
// child: LanguageSelector(
// currentLanguage: projectViewModel.isArabic ? 'ar' : 'en',
// onLanguageChanged: (String value) {
// dropDownIndexChange!(value == 'ar' ? 1 : 0);
// },
// languages: [
// {'code': 'ar', 'name': '${TranslationBase.of(context).lanEnglish}'},
// {'code': 'en', 'name': '${TranslationBase.of(context).lanArabic}'}
// ],
// ),
// ),
// ),
// ),
// ],
// ),
actions: < Widget > [
if ( appBarIcons ! = null )
. . . appBarIcons !
else
IconButton (
onPressed: ( ) {
AppSharedPreferences ( ) . remove ( IS_LIVECARE_APPOINTMENT ) ;
Navigator . pushAndRemoveUntil (
context ,
MaterialPageRoute ( builder: ( context ) = > LandingPage ( ) ) ,
( Route < dynamic > route ) = > false ,
) ;
} ,
icon: Icon ( Icons . home ) ,
) ,
] ,
) ;
}
@ override
Size get preferredSize = > Size ( double . maxFinite , 60 ) ;
}
class AppBarWidget extends StatefulWidget implements PreferredSizeWidget {
final AuthenticatedUserObject authenticatedUserObject = locator < AuthenticatedUserObject > ( ) ;
final String ? appBarTitle ;
final bool ? showHomeAppBarIcon ;
final List < Widget > ? appBarIcons ;
final bool isPharmacy ;
final bool isOfferPackages ;
final bool showPharmacyCart ;
final bool showOfferPackagesCart ;
final bool isShowDecPage ;
final bool isshowBackButton ;
final VoidCallback ? backButtonTab ;
Function ( String ) ? badgeUpdater ;
AppBarWidget (
{ this . appBarTitle ,
this . showHomeAppBarIcon ,
this . appBarIcons ,
this . isPharmacy = true ,
this . isshowBackButton = true ,
this . showPharmacyCart = true ,
this . isOfferPackages = false ,
this . showOfferPackagesCart = false ,
this . backButtonTab ,
this . isShowDecPage = true } ) ;
@ override
State < StatefulWidget > createState ( ) = > AppBarWidgetState ( ) ;
@ override
Size get preferredSize = > Size ( double . maxFinite , 60 ) ;
}
String _badgeText = " 0 " ;
class AppBarWidgetState extends State < AppBarWidget > {
@ override
Widget build ( BuildContext context ) {
widget . badgeUpdater = badgeUpdateBlock ;
return buildAppBar ( context ) ;
}
badgeUpdateBlock ( String value ) {
setState ( ( ) {
_badgeText = value ;
} ) ;
}
Widget buildAppBar ( BuildContext context ) {
ProjectViewModel projectViewModel = Provider . of ( context ) ;
OrderPreviewViewModel orderPreviewViewModel = Provider . of ( context ) ;
return AppBar (
elevation: 0 ,
backgroundColor: widget . isPharmacy ? Colors . green : Theme . of ( context ) . appBarTheme . backgroundColor ,
// textTheme: TextTheme(
// headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold),
// ),
title: Text ( widget . authenticatedUserObject . isLogin | | ! widget . isShowDecPage ? widget . appBarTitle ! . toUpperCase ( ) : TranslationBase . of ( context ) . serviceInformationTitle ,
// style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1!.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')),
style: TextStyle ( fontWeight: FontWeight . bold , color: CustomColors . white , fontFamily: projectViewModel . isArabic ? ' Cairo ' : ' Poppins ' ) ) ,
leading: widget . isshowBackButton
? Builder (
builder: ( BuildContext context ) {
return ArrowBack (
onTap: widget . backButtonTab ,
) ;
} ,
)
: null ,
centerTitle: true ,
actions: < Widget > [
( widget . isPharmacy & & widget . showPharmacyCart )
? IconButton (
icon: badge_import . Badge (
badgeContent: Text (
orderPreviewViewModel . cartResponse . quantityCount ! = null ? orderPreviewViewModel . cartResponse . quantityCount . toString ( ) : " " ,
style: TextStyle ( color: Colors . white ) ,
) ,
child: Icon ( Icons . shopping_cart ) ) ,
color: Colors . white ,
onPressed: ( ) {
Utils . navigateToCartPage ( ) ;
} )
: Container ( ) ,
( widget . isOfferPackages & & widget . showOfferPackagesCart )
? IconButton (
icon: badge_import . Badge (
position: badge_import . BadgePosition . topStart ( top: - 15 , start: - 10 ) ,
badgeContent: Text (
_badgeText ,
style: TextStyle ( fontSize: 9 , color: Colors . white , fontWeight: FontWeight . normal ) ,
) ,
child: Icon ( Icons . shopping_cart ) ) ,
color: Colors . white ,
onPressed: ( ) {
// Cart Click Event
if ( _onCartClick ! = null ) _onCartClick ! ( ) ;
} )
: Container ( ) ,
if ( widget . showHomeAppBarIcon ! )
IconButton (
icon: Icon ( FontAwesomeIcons . home ) ,
color: Colors . white ,
onPressed: ( ) {
Navigator . pushAndRemoveUntil ( context , MaterialPageRoute ( builder: ( context ) = > LandingPage ( ) ) , ( Route < dynamic > r ) = > false ) ;
// Cart Click Event
if ( _onCartClick ! = null ) _onCartClick ! ( ) ;
} ,
) ,
if ( widget . appBarIcons ! = null ) . . . widget . appBarIcons !
] ,
) ;
}
@ override
Size get preferredSize = > Size ( double . maxFinite , 60 ) ;
}
class RobotIcon extends StatefulWidget {
@ override
_RobotIcon createState ( ) = > _RobotIcon ( ) ;
}
class _RobotIcon extends State < RobotIcon > {
var event = RobotProvider ( ) ;
bool isAnimation = false ;
@ override
void initState ( ) {
event . controller . stream . listen ( ( p ) {
if ( p [ ' animationEnable ' ] = = ' false ' ) {
if ( this . mounted ) {
setState ( ( ) {
this . isAnimation = false ;
} ) ;
}
} else if ( p [ ' animationEnable ' ] = = ' true ' ) {
if ( this . mounted ) {
setState ( ( ) {
this . isAnimation = true ;
} ) ;
}
}
if ( p [ ' isRobotVisible ' ] = = ' false ' ) {
if ( this . mounted ) {
setState ( ( ) {
if ( IS_VOICE_COMMAND_CLOSED = = true ) {
this . isAnimation = false ;
}
} ) ;
}
}
} ) ;
super . initState ( ) ;
}
@ override
Widget build ( BuildContext context ) {
return Positioned (
child: Column (
children: [
// isAnimation
// ? Container(
// height: 150,
// width: 200,
// padding: EdgeInsets.all(5),
// margin: EdgeInsets.only(right: 35.0, bottom: 0),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// color: Colors.white,
// boxShadow: [
// BoxShadow(color: Colors.black, spreadRadius: 1),
// ],
// ),
// child: TyperAnimatedTextKit(
// text: Provider.of<ProjectViewModel>(context, listen: false).isArabic == true
// ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي."
// : "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file.",
// textLength: Provider.of<ProjectViewModel>(context, listen: false).isArabic == true
// ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.".length
// : "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file."
// .length))
// : Container(),
Stack (
children: [
// isAnimation
// ? Positioned(
// top: 0,
// right: 40,
// child: Container(
// height: 0,
// width: 0,
// decoration: ShapeDecoration(
// color: Colors.grey,
// shape: MessageBorder(reverse: true),
// )))
// : Container(),
FloatingSearchButton ( )
] ,
)
] ,
) ,
right: - 30 ,
bottom: - 15 ) ;
}
// setAnimation() async {
// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) ||
// // var animation =
// // IS_TEXT_COMPLETED == ? true : false;
// }
}