@ -60,10 +60,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
void initState ( ) {
WidgetsBinding . instance . addObserver ( this ) ;
super . initState ( ) ;
cProvider = Provider . of < ChatProviderModel > ( context , listen: false ) ;
scheduleMicrotask ( ( ) {
data = Provider . of < DashboardProviderModel > ( context , listen: false ) ;
marathonProvider = Provider . of < MarathonProvider > ( context , listen: false ) ;
cProvider = Provider . of < ChatProviderModel > ( context , listen: false ) ;
if ( checkIfPrivilegedForChat ( ) ) {
_bHubCon ( ) ;
}
@ -117,6 +117,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
}
Future < void > checkHubCon ( ) async {
/ / chatHubConnection = await context . read < ChatProviderModel > ( ) . getHubConnection ( ) ;
if ( chatHubConnection . state = = HubConnectionState . Connected ) {
await chatHubConnection . stop ( ) ;
await chatHubConnection . start ( ) ;
@ -151,7 +152,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
data . fetchLeaveTicketBalance ( context , DateTime . now ( ) ) ;
data . fetchMenuEntries ( ) ;
data . fetchEventActivity ( ) ;
data . getCategoryOffersListAPI ( context ) ;
/ / data . getCategoryOffersListAPI ( context ) ;
marathonProvider . getMarathonDetailsFromApi ( ) ;
marathonProvider . getMarathonTutorial ( ) ;
if ( isFromInit ) {
@ -175,10 +176,11 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
if ( list [ ermIndex ] . notificationType = = " Survey " ) {
await Navigator . pushNamed ( context , AppRoutes . survey , arguments: response . mohemmItgResponseItem ! . result ! . data ! . first ) ;
} else {
await Navigator . pushNamed ( context , AppRoutes . advertisement , arguments: {
" masterId " : list [ ermIndex ] . notificationMasterId ,
" advertisement " : response . mohemmItgResponseItem ! . result ! . data ! . first . advertisement ,
} ) ;
await Navigator . pushNamed (
context ,
AppRoutes . advertisement ,
arguments: { " masterId " : list [ ermIndex ] . notificationMasterId , " advertisement " : response . mohemmItgResponseItem ! . result ! . data ! . first . advertisement } ,
) ;
}
}
ermIndex + + ;
@ -235,26 +237,24 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
@ override
Widget build ( BuildContext context ) {
return Scaffold (
return SafeArea (
bottom: Platform . isAndroid ? true : false ,
top: false ,
child: Scaffold (
key: _scaffoldState ,
body: Column (
children: [
Row (
children: [
Builder ( builder: ( BuildContext context ) {
Builder (
builder: ( BuildContext context ) {
return Row (
mainAxisSize: MainAxisSize . min ,
children: [
Image . memory (
Utils . dataFromBase64String (
AppState ( ) . memberInformationList ! . eMPLOYEEIMAGE ? ? " " ,
) ,
Utils . dataFromBase64String ( AppState ( ) . memberInformationList ! . eMPLOYEEIMAGE ? ? " " ) ,
errorBuilder: ( BuildContext context , Object error , StackTrace ? stackTrace ) {
return SvgPicture . asset (
" assets/images/user.svg " ,
height: 34 ,
width: 34 ,
) ;
return SvgPicture . asset ( " assets/images/user.svg " , height: 34 , width: 34 ) ;
} ,
width: 34 ,
height: 34 ,
@ -271,23 +271,19 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
) . onPress ( ( ) {
_scaffoldState . currentState ! . openDrawer ( ) ;
} ) ;
} ) ,
} ,
) ,
Image . asset ( " assets/images/logos/main_mohemm_logo.png " , width: 134 , height: 28 ) . expanded ,
SvgPicture . asset (
" assets/images/announcements.svg " ,
matchTextDirection: true ,
) . onPress ( ( ) async {
SvgPicture . asset ( " assets/images/announcements.svg " , matchTextDirection: true ) . onPress ( ( ) async {
await Navigator . pushNamed ( context , AppRoutes . announcements ) ;
} )
} ) ,
] ,
) . paddingOnly ( left: 21 , right: 21 , top: 48 , bottom: 7 ) ,
Expanded (
child: SmartRefresher (
enablePullDown: true ,
enablePullUp: false ,
header: const MaterialClassicHeader (
color: MyColors . gradiantEndColor ,
) ,
header: const MaterialClassicHeader ( color: MyColors . gradiantEndColor ) ,
controller: _refreshController ,
onRefresh: ( ) {
_onRefresh ( false ) ;
@ -313,10 +309,12 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
: Container (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 15 ) ,
gradient: const LinearGradient ( transform: GradientRotation ( . 46 ) , begin: Alignment . topRight , end: Alignment . bottomLeft , colors: [
MyColors . gradiantEndColor ,
MyColors . gradiantStartColor ,
] ) ,
gradient: const LinearGradient (
transform: GradientRotation ( . 46 ) ,
begin: Alignment . topRight ,
end: Alignment . bottomLeft ,
colors: [ MyColors . gradiantEndColor , MyColors . gradiantStartColor ] ,
) ,
) ,
child: Stack (
alignment: Alignment . center ,
@ -371,9 +369,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
LocaleKeys . checkIn . tr ( ) . toText12 ( color: Colors . white ) ,
( model . attendanceTracking ! . pSwipeIn = = null ? " --:-- " : model . attendanceTracking ! . pSwipeIn )
. toString ( )
. toText14 ( color: Colors . white , isBold: true ) ,
( model . attendanceTracking ! . pSwipeIn = = null ? " --:-- " : model . attendanceTracking ! . pSwipeIn ) . toString ( ) . toText14 (
color: Colors . white ,
isBold: true ,
) ,
4. height ,
] ,
) . paddingOnly ( left: 12 , right: 12 ) ,
@ -384,19 +383,15 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
height: 45 ,
padding: const EdgeInsets . only ( left: 10 , right: 10 ) ,
decoration: BoxDecoration (
color: Color ( 0xff259EA4 ) ,
color: const Color ( 0xff259EA4 ) ,
borderRadius: BorderRadius . only (
bottomRight: AppState ( ) . isArabic ( context ) ? Radius . circular ( 0 ) : Radius . circular ( 15 ) ,
bottomLeft: AppState ( ) . isArabic ( context ) ? Radius . circular ( 15 ) : Radius . circular ( 0 ) ,
bottomRight: AppState ( ) . isArabic ( context ) ? const Radius . circular ( 0 ) : const Radius . circular ( 15 ) ,
bottomLeft: AppState ( ) . isArabic ( context ) ? const Radius . circular ( 15 ) : const Radius . circular ( 0 ) ,
) ,
) ,
child: SvgPicture . asset ( model . isTimeRemainingInSeconds = = 0 ? " assets/images/biometrics.svg " : " assets/images/biometrics.svg " ) ,
) . onPress ( ( ) {
showMyBottomSheet (
context ,
callBackFunc: ( ) { } ,
child: MarkAttendanceWidget ( model , isFromDashboard: true ) ,
) ;
showMyBottomSheet ( context , callBackFunc: ( ) { } , child: MarkAttendanceWidget ( model , isFromDashboard: true ) ) ;
} ) ,
] ,
) ,
@ -404,127 +399,131 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
) ,
] ,
) ,
) . onPress (
( ) {
) . onPress ( ( ) {
Navigator . pushNamed ( context , AppRoutes . todayAttendance ) ;
} ,
) )
} ) )
. animatedSwither ( ) ;
} ,
) ,
) ,
) ,
9. width ,
Expanded (
child: MenusWidget ( ) ,
) ,
Expanded ( child: MenusWidget ( ) ) ,
] ,
) ,
] ,
) . paddingOnly ( left: 21 , right: 21 , top: 7 , bottom: 21 ) ,
eventActivityWidget ( context ) ,
Consumer < DashboardProviderModel > ( builder: ( BuildContext context , DashboardProviderModel model , Widget ? child ) {
if ( ! model . isOffersLoading & & model . getOffersList . isEmpty ) {
return const SizedBox ( ) ;
}
return Column (
Column (
mainAxisSize: MainAxisSize . min ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
crossAxisAlignment: CrossAxisAlignment . center ,
Directionality (
textDirection: AppState ( ) . isArabic ( context ) ? ui . TextDirection . rtl : ui . TextDirection . ltr ,
child: Container (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 20 ) ,
gradient: const LinearGradient ( colors: [ Color ( 0xFF91C481 ) , Color ( 0xFF7CCED7 ) ] , begin: Alignment . centerLeft , end: Alignment . centerRight ) ,
) ,
child: Padding (
padding: const EdgeInsets . all ( 3.0 ) , / / This creates the border width
child: Container (
decoration: BoxDecoration (
color: Colors . white ,
borderRadius: BorderRadius . circular ( 17 ) , / / Slightly less than outer radius
) ,
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Expanded (
flex: 4 ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . min ,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
LocaleKeys . offers . tr ( ) . toText12 ( ) ,
Row (
children: [
LocaleKeys . discounts . tr ( ) . toText24 ( isBold: true ) ,
6. width ,
Container (
padding: const EdgeInsets . only ( left: 8 , right: 8 ) ,
decoration: BoxDecoration (
color: MyColors . yellowColor ,
borderRadius: BorderRadius . circular ( 10 ) ,
Expanded (
flex: 2 ,
child: RichText (
text:
AppState ( ) . isArabic ( context )
? TextSpan (
children: [
TextSpan (
text: ' اطلع على مميزات ' ,
style: TextStyle ( fontSize: 16 , letterSpacing: - 0.2 , fontFamily: AppState ( ) . isArabic ( context ) ? ' Cairo ' : ' Poppins ' , fontWeight: FontWeight . w700 , height: 24 / 16 , color: Color ( 0xFF5D5E5E ) ) ,
) ,
child: LocaleKeys . newString . tr ( ) . toText10 ( isBold: true ) ) ,
] ,
TextSpan (
text: ' مزايا ' ,
style: TextStyle (
fontSize: 16 ,
fontFamily: AppState ( ) . isArabic ( context ) ? ' Cairo ' : ' Poppins ' ,
fontWeight: FontWeight . w700 ,
letterSpacing: - 0.2 ,
height: 24 / 16 ,
color: MyColors . mazayaRedColor , / / Use your MAZAYA red color here if defined , e . g . MyColors . mazayaRed
) ,
] ,
) ,
) ,
LocaleKeys . viewAllOffers . tr ( ) . toText12 ( isUnderLine: true ) . onPress ( ( ) {
Navigator . pushNamed ( context , AppRoutes . offersAndDiscounts ) ;
} )
] ,
) . paddingOnly ( left: 21 , right: 21 ) ,
Consumer < DashboardProviderModel > (
builder: ( BuildContext context , DashboardProviderModel model , Widget ? child ) {
return SizedBox (
height: 103 + 33 ,
child: ListView . separated (
shrinkWrap: true ,
physics: const BouncingScrollPhysics ( ) ,
padding: const EdgeInsets . only ( left: 21 , right: 21 , top: 13 ) ,
scrollDirection: Axis . horizontal ,
itemBuilder: ( BuildContext cxt , int index ) {
return model . isOffersLoading
? const OffersShimmerWidget ( )
: InkWell (
onTap: ( ) {
navigateToDetails ( data . getOffersList [ index ] ) ;
} ,
child: SizedBox (
width: 73 ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . center ,
)
: TextSpan (
children: [
Container (
width: 73 ,
height: 73 ,
decoration: BoxDecoration (
color: Colors . white ,
borderRadius: const BorderRadius . all (
Radius . circular ( 100 ) ,
TextSpan (
text: LocaleKeys . explore . tr ( ) + ' ' ,
style: const TextStyle ( fontSize: 16 , letterSpacing: - 0.2 , fontFamily: ' Poppins ' , fontWeight: FontWeight . w700 , height: 24 / 16 , color: Color ( 0xFF5D5E5E ) ) ,
) ,
TextSpan (
text: LocaleKeys . mazaya . tr ( ) ,
style: const TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w700 ,
fontFamily: ' Poppins ' ,
letterSpacing: - 0.2 ,
height: 24 / 16 ,
color: MyColors . mazayaRedColor , / / Use your MAZAYA red color here if defined , e . g . MyColors . mazayaRed
) ,
) ,
TextSpan (
text: ' ' + LocaleKeys . benefits . tr ( ) ,
style: const TextStyle ( fontSize: 16 , letterSpacing: - 0.2 ,
fontFamily: ' Poppins ' , fontWeight: FontWeight . w700 , height: 24 / 16 , color: Color ( 0xFF5D5E5E ) ) ,
) ,
border: Border . all ( color: MyColors . lightGreyE3Color , width: 1 ) ,
] ,
) ,
child: ClipRRect (
borderRadius: const BorderRadius . all (
Radius . circular ( 50 ) ,
) ,
child: Hero (
tag: " ItemImage " + data . getOffersList [ index ] . offersDiscountId . toString ( ) ! ,
transitionOnUserGestures: true ,
child: Image . network (
data . getOffersList [ index ] . logo ? ? " " ,
fit: BoxFit . contain ,
) ,
const Expanded ( flex: 1 , child: SizedBox ( ) ) ,
] ,
) ,
const SizedBox ( height: 8 ) ,
LocaleKeys . mazayaDesc . tr ( ) . toText11 ( color: const Color ( 0xFF5D5E5E ) ) ,
] ,
) ,
) ,
4. height ,
Expanded (
child: AppState ( ) . isArabic ( context )
? data . getOffersList [ index ] . titleAr ! . toText12 ( isCenter: true , maxLine: 1 )
: data . getOffersList [ index ] . titleEn ! . toText12 ( isCenter: true , maxLine: 1 ) ,
flex: 2 ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . end ,
mainAxisAlignment: MainAxisAlignment . end ,
children: [
SvgPicture . asset ( " assets/icons/mazaya_brand.svg " , width: 90 , height: 47 ) ,
const SizedBox ( height: 28 ) ,
LocaleKeys . viewallofferMazaya . tr ( ) . toText12 ( isUnderLine: true , color: const Color ( 0xFF3B3D4A ) ) . onPress ( ( ) {
Navigator . pushNamed ( context , AppRoutes . offersAndDiscounts ) ;
} ) ,
] ,
) ,
) ,
] ,
) . paddingOnly ( left: 21 , right: 21 , top: 14 , bottom: 14 ) ,
) ,
) ,
) ;
} ,
separatorBuilder: ( BuildContext cxt , int index ) = > 8. width ,
itemCount: 9 ) ,
) ;
} ,
) . paddingOnly ( left: 21 , right: 21 , top: 0 , bottom: 21 ) ,
) ,
] ,
) ;
} ) ,
) ,
Container (
width: double . infinity ,
padding: const EdgeInsets . only ( top: 31 ) ,
@ -588,38 +587,24 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
) ,
) ,
) ,
)
] ,
) ,
drawer: SafeArea (
child: AppDrawer ( onLanguageChange: _onRefresh ) ,
] ,
) ,
drawer: AppDrawer ( onLanguageChange: _onRefresh ) ,
bottomNavigationBar: SizedBox (
height: Platform . isAndroid ? 70 : 100 ,
child: BottomNavigationBar (
items: < BottomNavigationBarItem > [
BottomNavigationBarItem ( icon: SvgPicture . asset ( " assets/icons/home.svg " , color: currentIndex = = 0 ? MyColors . grey3AColor : MyColors . grey98Color ) . paddingAll ( 4 ) , label: LocaleKeys . home . tr ( ) ) ,
BottomNavigationBarItem (
icon: SvgPicture . asset (
" assets/icons/home.svg " ,
color: currentIndex = = 0 ? MyColors . grey3AColor : MyColors . grey98Color ,
) . paddingAll ( 4 ) ,
label: LocaleKeys . home . tr ( ) ,
) ,
BottomNavigationBarItem (
icon: SvgPicture . asset (
" assets/icons/create_req.svg " ,
color: currentIndex = = 1 ? MyColors . grey3AColor : MyColors . grey98Color ,
) . paddingAll ( 4 ) ,
icon: SvgPicture . asset ( " assets/icons/create_req.svg " , color: currentIndex = = 1 ? MyColors . grey3AColor : MyColors . grey98Color ) . paddingAll ( 4 ) ,
label: LocaleKeys . mowadhafhiRequest . tr ( ) ,
) ,
BottomNavigationBarItem (
icon: Stack (
alignment: Alignment . centerLeft ,
children: [
SvgPicture . asset (
" assets/icons/work_list.svg " ,
color: currentIndex = = 2 ? MyColors . grey3AColor : MyColors . grey98Color ,
) . paddingAll ( 4 ) ,
SvgPicture . asset ( " assets/icons/work_list.svg " , color: currentIndex = = 2 ? MyColors . grey3AColor : MyColors . grey98Color ) . paddingAll ( 4 ) ,
Consumer < DashboardProviderModel > (
builder: ( BuildContext cxt , DashboardProviderModel data , Widget ? child ) {
if ( data . workListCounter = = 0 ) {
@ -642,10 +627,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
label: LocaleKeys . workList . tr ( ) ,
) ,
BottomNavigationBarItem (
icon: SvgPicture . asset (
" assets/icons/item_for_sale.svg " ,
color: currentIndex = = 3 ? MyColors . grey3AColor : MyColors . grey98Color ,
) . paddingAll ( 4 ) ,
icon: SvgPicture . asset ( " assets/icons/item_for_sale.svg " , color: currentIndex = = 3 ? MyColors . grey3AColor : MyColors . grey98Color ) . paddingAll ( 4 ) ,
label: LocaleKeys . itemsForSale . tr ( ) ,
) ,
BottomNavigationBarItem (
@ -654,7 +636,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
children: [
SvgPicture . asset (
" assets/icons/chat/chat.svg " ,
color: ! checkIfPrivilegedForChat ( ) ? MyColors . lightGreyE3Color : currentIndex = = 4
color:
! checkIfPrivilegedForChat ( )
? MyColors . lightGreyE3Color
: currentIndex = = 4
? MyColors . grey3AColor
: cProvider . disbaleChatForThisUser
? MyColors . lightGreyE3Color
@ -662,7 +647,9 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
) . paddingAll ( 4 ) ,
Consumer < ChatProviderModel > (
builder: ( BuildContext cxt , ChatProviderModel data , Widget ? child ) {
return ! checkIfPrivilegedForChat ( ) ? const SizedBox ( ) : Positioned (
return ! checkIfPrivilegedForChat ( )
? const SizedBox ( )
: Positioned (
right: 0 ,
top: 0 ,
child: Container (
@ -702,20 +689,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
} ,
) ,
) ,
) ,
) ;
}
bool checkIfPrivilegedForChat ( ) {
for ( PrivilegeListModel element in AppState ( ) . privilegeListModel ! ) {
if ( element . serviceName ? . toLowerCase ( ) = = " chat " ) {
if ( element . previlege ! = null ) {
return element . previlege ! ;
}
}
}
return false ;
}
Widget eventActivityWidget ( BuildContext context ) {
return ( context . watch < DashboardProviderModel > ( ) . isEventLoadingLoading )
? const MarathonBannerShimmer ( ) . paddingOnly ( left: 21 , right: 21 , bottom: 21 , top: 0 )
@ -741,4 +718,15 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
} ) ;
Navigator . pushNamed ( context , AppRoutes . offersAndDiscountsDetails , arguments: getOffersDetailList ) ;
}
bool checkIfPrivilegedForChat ( ) {
for ( PrivilegeListModel element in AppState ( ) . privilegeListModel ! ) {
if ( element . serviceName ? . toLowerCase ( ) = = " chat " ) {
if ( element . previlege ! = null ) {
return element . previlege ! ;
}
}
}
return false ;
}
}