@ -23,6 +23,7 @@ import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart';
import ' package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart ' ;
import ' package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart ' ;
import ' package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart ' ;
import ' package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:pull_to_refresh/pull_to_refresh.dart ' ;
class DashboardScreen extends StatefulWidget {
class DashboardScreen extends StatefulWidget {
DashboardScreen ( { Key ? key } ) : super ( key: key ) ;
DashboardScreen ( { Key ? key } ) : super ( key: key ) ;
@ -37,12 +38,24 @@ class _DashboardScreenState extends State<DashboardScreen> {
late DashboardProviderModel data ;
late DashboardProviderModel data ;
final GlobalKey < ScaffoldState > _scaffoldState = GlobalKey ( ) ;
final GlobalKey < ScaffoldState > _scaffoldState = GlobalKey ( ) ;
final RefreshController _refreshController = RefreshController ( initialRefresh: false ) ;
int currentIndex = 0 ;
int currentIndex = 0 ;
@ override
@ override
void initState ( ) {
void initState ( ) {
super . initState ( ) ;
super . initState ( ) ;
data = Provider . of < DashboardProviderModel > ( context , listen: false ) ;
data = Provider . of < DashboardProviderModel > ( context , listen: false ) ;
_onRefresh ( ) ;
}
@ override
void dispose ( ) {
super . dispose ( ) ;
}
void _onRefresh ( ) async {
data . initProvider ( ) ;
data . fetchListMenu ( ) ;
data . fetchListMenu ( ) ;
data . fetchAttendanceTracking ( context ) ;
data . fetchAttendanceTracking ( context ) ;
data . fetchWorkListCounter ( context ) ;
data . fetchWorkListCounter ( context ) ;
@ -50,11 +63,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
data . fetchLeaveTicketBalance ( context , DateTime . now ( ) ) ;
data . fetchLeaveTicketBalance ( context , DateTime . now ( ) ) ;
data . fetchMenuEntries ( ) ;
data . fetchMenuEntries ( ) ;
data . getCategoryOffersListAPI ( context ) ;
data . getCategoryOffersListAPI ( context ) ;
}
_refreshController . refreshCompleted ( ) ;
@ override
void dispose ( ) {
super . dispose ( ) ;
}
}
@ override
@ override
@ -122,236 +131,243 @@ class _DashboardScreenState extends State<DashboardScreen> {
] ,
] ,
) . paddingOnly ( left: 21 , right: 21 , top: 48 , bottom: 7 ) ,
) . paddingOnly ( left: 21 , right: 21 , top: 48 , bottom: 7 ) ,
Expanded (
Expanded (
child: SingleChildScrollView (
child: SmartRefresher (
child: Column (
enablePullDown: true ,
children: [
enablePullUp: false ,
Column (
header: const MaterialClassicHeader ( color: MyColors . gradiantEndColor , ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
controller: _refreshController ,
children: [
onRefresh: _onRefresh ,
LocaleKeys . goodMorning . tr ( ) . toText14 ( color: MyColors . grey77Color ) ,
child: SingleChildScrollView (
( AppState ( ) . memberInformationList ! . eMPLOYEENAME ? ? " " ) . toText24 ( isBold: true ) ,
child: Column (
16. height ,
children: [
Row (
Column (
children: [
crossAxisAlignment: CrossAxisAlignment . start ,
Expanded (
children: [
child: AspectRatio (
LocaleKeys . goodMorning . tr ( ) . toText14 ( color: MyColors . grey77Color ) ,
aspectRatio: 159 / 159 ,
( AppState ( ) . memberInformationList ! . eMPLOYEENAME ? ? " " ) . toText24 ( isBold: true ) ,
child: Consumer < DashboardProviderModel > (
16. height ,
builder: ( context , model , child ) {
Row (
return ( model . isAttendanceTrackingLoading
children: [
? GetAttendanceTrackingShimmer ( )
Expanded (
: Container (
child: AspectRatio (
decoration: BoxDecoration (
aspectRatio: 159 / 159 ,
borderRadius: BorderRadius . circular ( 15 ) ,
child: Consumer < DashboardProviderModel > (
gradient: const LinearGradient ( transform: GradientRotation ( . 46 ) , begin: Alignment . topRight , end: Alignment . bottomLeft , colors: [
builder: ( context , model , child ) {
MyColors . gradiantEndColor ,
return ( model . isAttendanceTrackingLoading
MyColors . gradiantStartColor ,
? GetAttendanceTrackingShimmer ( )
] ) ,
: Container (
) ,
decoration: BoxDecoration (
child: Stack (
borderRadius: BorderRadius . circular ( 15 ) ,
alignment: Alignment . center ,
gradient: const LinearGradient ( transform: GradientRotation ( . 46 ) , begin: Alignment . topRight , end: Alignment . bottomLeft , colors: [
children: [
MyColors . gradiantEndColor ,
if ( model . isTimeRemainingInSeconds = = 0 ) SvgPicture . asset ( " assets/images/thumb.svg " ) ,
MyColors . gradiantStartColor ,
Column (
] ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
) ,
children: [
child: Stack (
Expanded (
alignment: Alignment . center ,
child: Column (
children: [
mainAxisSize: MainAxisSize . min ,
if ( model . isTimeRemainingInSeconds = = 0 ) SvgPicture . asset ( " assets/images/thumb.svg " ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
Column (
children: [
crossAxisAlignment: CrossAxisAlignment . start ,
LocaleKeys . markAttendance . tr ( ) . toText14 ( color: Colors . white , isBold: true ) ,
children: [
if ( model . isTimeRemainingInSeconds = = 0 ) " 01-02-2022 " . toText12 ( color: Colors . white ) ,
Expanded (
if ( model . isTimeRemainingInSeconds ! = 0 )
child: Column (
Column (
mainAxisSize: MainAxisSize . min ,
mainAxisSize: MainAxisSize . min ,
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
LocaleKeys . markAttendance . tr ( ) . toText14 ( color: Colors . white , isBold: true ) ,
9. height ,
if ( model . isTimeRemainingInSeconds = = 0 ) " 01-02-2022 " . toText12 ( color: Colors . white ) ,
CountdownTimer (
if ( model . isTimeRemainingInSeconds ! = 0 )
endTime: model . endTime ,
Column (
onEnd: null ,
mainAxisSize: MainAxisSize . min ,
endWidget: " 00:00:00 " . toText14 ( color: Colors . white , isBold: true ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
textStyle: TextStyle ( color: Colors . white , fontSize: 14 , letterSpacing: - 0.48 , fontWeight: FontWeight . bold ) ,
) ,
LocaleKeys . timeLeftToday . tr ( ) . toText12 ( color: Colors . white ) ,
9. height ,
ClipRRect (
borderRadius: BorderRadius . all (
Radius . circular ( 20 ) ,
) ,
child: LinearProgressIndicator (
value: model . progress ,
minHeight: 8 ,
valueColor: const AlwaysStoppedAnimation < Color > ( Colors . white ) ,
backgroundColor: const Color ( 0xff196D73 ) ,
) ,
) ,
] ,
) ,
] ,
) . paddingOnly ( top: 12 , right: 15 , left: 12 ) ,
) ,
Row (
children: [
children: [
Expanded (
9. height ,
child: Column (
CountdownTimer (
mainAxisSize: MainAxisSize . min ,
endTime: model . endTime ,
crossAxisAlignment: CrossAxisAlignment . start ,
onEnd: null ,
children: [
endWidget: " 00:00:00 " . toText14 ( color: Colors . white , isBold: true ) ,
LocaleKeys . checkIn . tr ( ) . toText12 ( color: Colors . white ) ,
textStyle: TextStyle ( color: Colors . white , fontSize: 14 , letterSpacing: - 0.48 , fontWeight: FontWeight . bold ) ,
( model . attendanceTracking ! . pSwipeIn = = null ? " --:-- " : model . attendanceTracking ! . pSwipeIn )
. toString ( )
. toText14 ( color: Colors . white , isBold: true ) ,
4. height ,
] ,
) . paddingOnly ( left: 12 ) ,
) ,
) ,
Container (
LocaleKeys . timeLeftToday . tr ( ) . toText12 ( color: Colors . white ) ,
width: 45 ,
9. height ,
height: 45 ,
ClipRRect (
padding: const EdgeInsets . only ( left: 14 , right: 14 ) ,
borderRadius: BorderRadius . all (
decoration: const BoxDecoration (
Radius . circular ( 20 ) ,
color: Color ( 0xff259EA4 ) ,
borderRadius: BorderRadius . only (
bottomRight: Radius . circular ( 15 ) ,
) ,
) ,
) ,
child: SvgPicture . asset ( model . isTimeRemainingInSeconds = = 0 ? " assets/images/play.svg " : " assets/images/stop.svg " ) ,
child: LinearProgressIndicator (
) . onPress ( ( ) {
value: model . progress ,
showMyBottomSheet ( context , child: MarkAttendanceWidget ( model ) ) ;
minHeight: 8 ,
} ) ,
valueColor: const AlwaysStoppedAnimation < Color > ( Colors . white ) ,
backgroundColor: const Color ( 0xff196D73 ) ,
) ,
) ,
] ,
] ,
) ,
) ,
] ,
] ,
) . paddingOnly ( top: 12 , right: 15 , left: 12 ) ,
) ,
Row (
children: [
Expanded (
child: Column (
mainAxisSize: MainAxisSize . min ,
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 ) ,
4. height ,
] ,
) . paddingOnly ( left: 12 ) ,
) ,
) ,
Container (
width: 45 ,
height: 45 ,
padding: const EdgeInsets . only ( left: 14 , right: 14 ) ,
decoration: const BoxDecoration (
color: Color ( 0xff259EA4 ) ,
borderRadius: BorderRadius . only (
bottomRight: Radius . circular ( 15 ) ,
) ,
) ,
child: SvgPicture . asset ( model . isTimeRemainingInSeconds = = 0 ? " assets/images/play.svg " : " assets/images/stop.svg " ) ,
) . onPress ( ( ) {
showMyBottomSheet ( context , child: MarkAttendanceWidget ( model ) ) ;
} ) ,
] ,
] ,
) ,
) ,
) . onPress (
] ,
( ) {
) ,
Navigator . pushNamed ( context , AppRoutes . todayAttendance ) ;
] ,
} ,
) ,
) )
) . onPress (
. animatedSwither ( ) ;
( ) {
} ,
Navigator . pushNamed ( context , AppRoutes . todayAttendance ) ;
} ,
) )
. animatedSwither ( ) ;
} ,
) ,
) ,
) ,
) ,
) ,
) ,
9. width ,
9. width ,
Expanded (
child: MenusWidget ( ) ,
) ,
] ,
) ,
] ,
) . paddingOnly ( left: 21 , right: 21 , top: 7 ) ,
ServicesWidget ( ) ,
/ / 8. height ,
Container (
width: double . infinity ,
padding: const EdgeInsets . only ( top: 31 ) ,
decoration: BoxDecoration (
color: Colors . white ,
borderRadius: const BorderRadius . only ( topRight: Radius . circular ( 50 ) , topLeft: Radius . circular ( 50 ) ) ,
border: Border . all ( color: MyColors . lightGreyEDColor , width: 1 ) ,
) ,
child: Column (
mainAxisSize: MainAxisSize . min ,
children: [
Row (
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
Expanded (
Expanded (
child: Column (
child: MenusWidget ( ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . min ,
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 ) ,
) ,
child: LocaleKeys . newString . tr ( ) . toText10 ( isBold: true ) ) ,
] ,
) ,
] ,
) ,
) ,
) ,
LocaleKeys . viewAllOffers . tr ( ) . toText12 ( isUnderLine: true ) . onPress ( ( ) {
Navigator . pushNamed ( context , AppRoutes . offersAndDiscounts ) ;
} )
] ,
] ,
) . paddingOnly ( left: 21 , right: 21 ) ,
) ,
Consumer < DashboardProviderModel > (
] ,
builder: ( context , model , child ) {
) . paddingOnly ( left: 21 , right: 21 , top: 7 ) ,
return SizedBox (
ServicesWidget ( ) ,
height: 103 + 33 ,
/ / 8. height ,
child: ListView . separated (
Container (
shrinkWrap: true ,
width: double . infinity ,
physics: const BouncingScrollPhysics ( ) ,
padding: const EdgeInsets . only ( top: 31 ) ,
padding: const EdgeInsets . only ( left: 21 , right: 21 , top: 13 ) ,
decoration: BoxDecoration (
scrollDirection: Axis . horizontal ,
color: Colors . white ,
itemBuilder: ( cxt , index ) {
borderRadius: const BorderRadius . only ( topRight: Radius . circular ( 50 ) , topLeft: Radius . circular ( 50 ) ) ,
return model . isOffersLoading
border: Border . all ( color: MyColors . lightGreyEDColor , width: 1 ) ,
? const OffersShimmerWidget ( )
) ,
: InkWell (
child: Column (
onTap: ( ) {
mainAxisSize: MainAxisSize . min ,
navigateToDetails ( data . getOffersList [ index ] ) ;
children: [
} ,
Row (
child: SizedBox (
crossAxisAlignment: CrossAxisAlignment . center ,
width: 73 ,
children: [
child: Column (
Expanded (
crossAxisAlignment: CrossAxisAlignment . center ,
child: Column (
children: [
crossAxisAlignment: CrossAxisAlignment . start ,
Container (
mainAxisSize: MainAxisSize . min ,
width: 73 ,
children: [
height: 73 ,
LocaleKeys . offers . tr ( ) . toText12 ( ) ,
decoration: BoxDecoration (
Row (
borderRadius: const BorderRadius . all (
children: [
Radius . circular ( 100 ) ,
LocaleKeys . discounts . tr ( ) . toText24 ( isBold: true ) ,
) ,
6. width ,
border: Border . all ( color: MyColors . lightGreyE3Color , width: 1 ) ,
Container (
) ,
padding: const EdgeInsets . only ( left: 8 , right: 8 ) ,
child: ClipRRect (
decoration: BoxDecoration (
borderRadius: const BorderRadius . all (
color: MyColors . yellowColor ,
Radius . circular ( 50 ) ,
borderRadius: BorderRadius . circular ( 10 ) ,
) ,
) ,
child: Hero (
child: LocaleKeys . newString . tr ( ) . toText10 ( isBold: true ) ) ,
tag: " ItemImage " + data . getOffersList [ index ] . rowID ! ,
] ,
transitionOnUserGestures: true ,
) ,
child: Image . network (
] ,
data . getOffersList [ index ] . bannerImage ! ,
) ,
fit: BoxFit . contain ,
) ,
) ,
LocaleKeys . viewAllOffers . tr ( ) . toText12 ( isUnderLine: true ) . onPress ( ( ) {
) ,
Navigator . pushNamed ( context , AppRoutes . offersAndDiscounts ) ;
) ,
} )
] ,
) . paddingOnly ( left: 21 , right: 21 ) ,
Consumer < DashboardProviderModel > (
builder: ( context , model , 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: ( cxt , index ) {
return model . isOffersLoading
? const OffersShimmerWidget ( )
: InkWell (
onTap: ( ) {
navigateToDetails ( data . getOffersList [ index ] ) ;
} ,
child: SizedBox (
width: 73 ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
Container (
width: 73 ,
height: 73 ,
decoration: BoxDecoration (
borderRadius: const BorderRadius . all (
Radius . circular ( 100 ) ,
) ,
) ,
4. height ,
border: Border . all ( color: MyColors . lightGreyE3Color , width: 1 ) ,
Expanded (
) ,
child: AppState ( ) . isArabic ( context )
child: ClipRRect (
? data . getOffersList [ index ] . titleAR ! . toText12 ( isCenter: true , maxLine: 1 )
borderRadius: const BorderRadius . all (
: data . getOffersList [ index ] . title ! . toText12 ( isCenter: true , maxLine: 1 ) ,
Radius . circular ( 50 ) ,
) ,
) ,
] ,
child: Hero (
tag: " ItemImage " + data . getOffersList [ index ] . rowID ! ,
transitionOnUserGestures: true ,
child: Image . network (
data . getOffersList [ index ] . bannerImage ! ,
fit: BoxFit . contain ,
) ,
) ,
) ,
) ,
) ,
) ,
4. height ,
) ;
Expanded (
} ,
child: AppState ( ) . isArabic ( context )
separatorBuilder: ( cxt , index ) = > 8. width ,
? data . getOffersList [ index ] . titleAR ! . toText12 ( isCenter: true , maxLine: 1 )
itemCount: 6 ) ,
: data . getOffersList [ index ] . title ! . toText12 ( isCenter: true , maxLine: 1 ) ,
) ;
) ,
} ,
] ,
) ,
) ,
] ,
) ,
) ,
) ;
)
} ,
] ,
separatorBuilder: ( cxt , index ) = > 8. width ,
itemCount: 6 ) ,
) ;
} ,
) ,
] ,
) ,
)
] ,
) ,
) ,
) ,
) ,
) ,
)
)
@ -424,9 +440,13 @@ class _DashboardScreenState extends State<DashboardScreen> {
selectedIconTheme: const IconThemeData ( color: MyColors . grey3AColor , size: 28 ) ,
selectedIconTheme: const IconThemeData ( color: MyColors . grey3AColor , size: 28 ) ,
unselectedIconTheme: const IconThemeData ( color: MyColors . grey98Color , size: 28 ) ,
unselectedIconTheme: const IconThemeData ( color: MyColors . grey98Color , size: 28 ) ,
onTap: ( int index ) {
onTap: ( int index ) {
/ / currentIndex = index ;
if ( index = = 1 ) {
/ / setState ( ( ) { } ) ;
Navigator . pushNamed ( context , AppRoutes . mowadhafhi ) ;
Navigator . pushNamed ( context , AppRoutes . itemsForSale ) ;
} else if ( index = = 2 ) {
Navigator . pushNamed ( context , AppRoutes . workList ) ;
} else if ( index = = 3 ) {
Navigator . pushNamed ( context , AppRoutes . itemsForSale ) ;
}
} ,
} ,
) ,
) ,
) ,
) ,