@ -19,6 +19,7 @@ import 'package:mohem_flutter_app/models/worklist_response_model.dart';
import ' package:mohem_flutter_app/provider/dashboard_provider_model.dart ' ;
import ' package:mohem_flutter_app/widgets/app_bar_widget.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:pull_to_refresh/pull_to_refresh.dart ' ;
class WorkListScreen extends StatefulWidget {
WorkListScreen ( { Key ? key } ) : super ( key: key ) ;
@ -32,19 +33,70 @@ class WorkListScreen extends StatefulWidget {
class _WorkListScreenState extends State < WorkListScreen > {
List < WorkListItemTypeModelData > workListItemTypes = [
WorkListItemTypeModelData (
value: 0 , name: ' HR ' , fullName: LocaleKeys . humanResource . tr ( ) , active: false , color: [ Color ( 0xff32D892 ) , Color ( 0xff1AB170 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' HRSSA ' , disable: false ) ,
value: 0 ,
name: ' HR ' ,
fullName: LocaleKeys . humanResource . tr ( ) ,
active: false ,
color: [ Color ( 0xff32D892 ) , Color ( 0xff1AB170 ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' HRSSA ' ,
disable: false ) ,
WorkListItemTypeModelData (
value: 0 , name: ' MO ' , fullName: LocaleKeys . moveOrder . tr ( ) , active: false , color: [ Color ( 0xff58DCFA ) , Color ( 0xff3CB9D5 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' INVMOA ' , disable: false ) ,
value: 0 , name: ' M R ' , fullName: LocaleKeys . moveOrder . tr ( ) , active: false , color: [ Color ( 0xff58DCFA ) , Color ( 0xff3CB9D5 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' INVMOA ' , disable: false ) ,
WorkListItemTypeModelData (
value: 0 , name: ' PR ' , fullName: LocaleKeys . purchaseRequisition . tr ( ) , active: false , color: [ Color ( 0xff48EACF ) , Color ( 0xff3DCAB3 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' REQAPPRV ' , disable: false ) ,
value: 0 ,
name: ' PR ' ,
fullName: LocaleKeys . purchaseRequisition . tr ( ) ,
active: false ,
color: [ Color ( 0xff48EACF ) , Color ( 0xff3DCAB3 ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' REQAPPRV ' ,
disable: false ) ,
WorkListItemTypeModelData (
value: 0 , name: ' PO ' , fullName: LocaleKeys . purchaseOrder . tr ( ) , active: false , color: [ Color ( 0xff5099E3 ) , Color ( 0xff3670AA ) ] , icon: " assets/images/miss_swipe.svg " , key: ' POAPPRV ' , disable: false ) ,
value: 0 ,
name: ' PO ' ,
fullName: LocaleKeys . purchaseOrder . tr ( ) ,
active: false ,
color: [ Color ( 0xff5099E3 ) , Color ( 0xff3670AA ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' POAPPRV ' ,
disable: false ) ,
WorkListItemTypeModelData (
value: 0 , name: ' ITG ' , fullName: LocaleKeys . ITGForms . tr ( ) , active: false , color: [ Color ( 0xffEB8C90 ) , Color ( 0xffDE6C70 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' ITG ' , disable: false ) ,
value: 0 ,
name: ' ITG ' ,
fullName: LocaleKeys . ITGForms . tr ( ) ,
active: false ,
color: [ Color ( 0xffEB8C90 ) , Color ( 0xffDE6C70 ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' ITG ' ,
disable: false ) ,
WorkListItemTypeModelData (
value: 0 , name: ' IC ' , fullName: LocaleKeys . itemCreation . tr ( ) , active: false , color: [ Color ( 0xff32D892 ) , Color ( 0xff1AB170 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' INVITEM ' , disable: false ) ,
value: 0 ,
name: ' IC ' ,
fullName: LocaleKeys . itemCreation . tr ( ) ,
active: false ,
color: [ Color ( 0xff32D892 ) , Color ( 0xff1AB170 ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' INVITEM ' ,
disable: false ) ,
WorkListItemTypeModelData (
value: 0 , name: ' STAMP ' , fullName: LocaleKeys . stamp . tr ( ) , active: false , color: [ Color ( 0xff32D892 ) , Color ( 0xff1AB170 ) ] , icon: " assets/images/miss_swipe.svg " , key: ' STAMP ' , disable: false ) ,
value: 0 ,
name: ' STAMP ' ,
fullName: LocaleKeys . stamp . tr ( ) ,
active: false ,
color: [ Color ( 0xff32D892 ) , Color ( 0xff1AB170 ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' STAMP ' ,
disable: false ) ,
WorkListItemTypeModelData (
value: 0 ,
name: ' COC ' ,
fullName: LocaleKeys . itemCreation . tr ( ) ,
active: false ,
color: [ Color ( 0xff787299 ) , Color ( 0xff1AB170 ) ] ,
icon: " assets/images/miss_swipe.svg " ,
key: ' COC ' ,
disable: true )
] ;
int workListItemIndex = 0 ;
@ -54,6 +106,8 @@ class _WorkListScreenState extends State<WorkListScreen> {
late DashboardProviderModel providerData ;
final RefreshController _refreshController = RefreshController ( initialRefresh: false ) ;
@ override
void initState ( ) {
super . initState ( ) ;
@ -67,8 +121,13 @@ class _WorkListScreenState extends State<WorkListScreen> {
workListItemTypes . forEach ( ( workListElement ) {
if ( workListElement . key = = " ITG " ) {
workListElement . value = providerData . itgFormsModel ? . totalCount ? ? 0 ;
} else if ( workListElement . key = = " COC " ) {
workListElement . value = providerData . cocFinalCount ;
} else {
var tempList = providerData . getOpenNotificationsList ? . where ( ( notificationElement ) = > notificationElement . itemType = = workListElement . key ) . toList ( ) ;
var tempList = providerData . getOpenNotificationsList
? . where ( ( notificationElement ) = >
notificationElement . itemType = = workListElement . key )
. toList ( ) ;
if ( tempList ! . isNotEmpty ) {
workListElement . value = tempList . first . openNtfNumber ? ? 0 ;
}
@ -87,18 +146,26 @@ class _WorkListScreenState extends State<WorkListScreen> {
List < RequestDetails > requestAllList = [ ] ;
for ( int i = 0 ; i < ( itgFormsModel ? . requestType ! . length ? ? 0 ) ; i + + ) {
itgFormsModel ? . requestType ! [ i ] . requestDetails ? . forEach ( ( element ) {
element . requestType = itgFormsModel ? . requestType ! [ i ] . requestTypeCode ;
element . requestType =
itgFormsModel ? . requestType ! [ i ] . requestTypeCode ;
} ) ;
requestAllList = requestAllList + ( itgFormsModel ? . requestType ! [ i ] . requestDetails ? ? [ ] ) ;
requestAllList = requestAllList +
( itgFormsModel ? . requestType ! [ i ] . requestDetails ? ? [ ] ) ;
}
AppState ( ) . setRequestAllList = requestAllList ;
itgFormsModel ? . requestType ! . insert ( 0 , RequestType ( requestDetails: requestAllList , requestTypeCode: " all " , requestTypeName: " All " ) ) ;
itgFormsModel ? . requestType ! . insert (
0 ,
RequestType (
requestDetails: requestAllList ,
requestTypeCode: " all " ,
requestTypeName: " All " ) ) ;
if ( ( itgFormsModel ? . requestType ? . length ? ? 0 ) > 0 ) {
itgRequestTypeIndex = 0 ;
}
} else {
itgRequestTypeIndex = null ;
workList = await WorkListApiClient ( ) . getWorkList ( pageNumber , workListItemTypes [ workListItemIndex ] . key ) ;
workList = await WorkListApiClient ( )
. getWorkList ( pageNumber , workListItemTypes [ workListItemIndex ] . key ) ;
AppState ( ) . setWorkList = workList ;
}
Utils . hideLoading ( context ) ;
@ -109,6 +176,11 @@ class _WorkListScreenState extends State<WorkListScreen> {
}
}
void _onRefresh ( ) async {
getWorkList ( ) ;
_refreshController . refreshCompleted ( ) ;
}
@ override
void dispose ( ) {
super . dispose ( ) ;
@ -129,26 +201,33 @@ class _WorkListScreenState extends State<WorkListScreen> {
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Container (
width: double . infinity ,
height: 1 ,
color: MyColors . lightGreyEFColor ,
) ,
Container ( width: double . infinity , height: 1 , color: MyColors . lightGreyEFColor ) ,
SizedBox (
height: 40 ,
child: ListView . separated (
itemBuilder: ( context , index ) {
return Container (
padding: const EdgeInsets . only ( left: 21 , right: 21 , top: 8 , bottom: 8 ) ,
padding: const EdgeInsets . only (
left: 21 , right: 21 , top: 8 , bottom: 8 ) ,
alignment: Alignment . center ,
decoration: BoxDecoration ( borderRadius: BorderRadius . circular ( 6 ) , color: workListItemIndex = = index ? MyColors . darkIconColor : MyColors . lightGreyEAColor ) ,
child: ( " ${ workListItemTypes [ index ] . name } ${ workListItemTypes [ index ] . value > 0 ? " ( $ {workListItemTypes[index].value } ) " : " " } " )
. toText12 ( color: workListItemIndex = = index ? MyColors . white : MyColors . black ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 6 ) ,
color: workListItemIndex = = index
? MyColors . darkIconColor
: MyColors . lightGreyEAColor ) ,
child:
( " ${ workListItemTypes [ index ] . name } ${ workListItemTypes [ index ] . value > 0 ? " ( $ {workListItemTypes[index].value } ) " : " " } " )
. toText12 (
color: workListItemIndex = = index
? MyColors . white
: MyColors . black ) ,
) . onPress ( ( ) {
if ( workListItemIndex ! = index ) {
if ( workListItemIndex ! = index & &
! workListItemTypes [ index ] . disable ) {
workListItemIndex = index ;
if ( workListItemTypes [ index ] . value = = 0 ) {
workList = [ ] ;
itgRequestTypeIndex = null ;
} else {
workList = null ;
}
@ -167,71 +246,87 @@ class _WorkListScreenState extends State<WorkListScreen> {
) ,
) . paddingOnly ( top: 21 , bottom: 21 ) ,
workListItemTypes [ workListItemIndex ] . fullName . toSectionHeading ( ) . paddingOnly ( left: 21 , right: 21 ) ,
if ( itgRequestTypeIndex ! = null )
SizedBox (
height: 40 ,
child: ListView . separated (
itemBuilder: ( context , index ) {
RequestType type = itgFormsModel ! . requestType ! [ index ] ;
return Container (
padding: const EdgeInsets . only ( left: 21 , right: 21 , top: 8 , bottom: 8 ) ,
alignment: Alignment . center ,
decoration: BoxDecoration ( borderRadius: BorderRadius . circular ( 30 ) , color: itgRequestTypeIndex = = index ? MyColors . darkIconColor : MyColors . lightGreyEAColor ) ,
child: ( " ${ type . requestTypeName } " ) . toText12 ( color: itgRequestTypeIndex = = index ? MyColors . white : MyColors . black ) ,
) . onPress ( ( ) {
if ( itgRequestTypeIndex ! = index ) {
itgRequestTypeIndex = index ;
setState ( ( ) { } ) ;
}
} ) ;
} ,
separatorBuilder: ( context , index ) = > 8. width ,
shrinkWrap: true ,
itemCount: itgFormsModel ? . requestType ? . length ? ? 0 ,
scrollDirection: Axis . horizontal ,
padding: const EdgeInsets . only ( left: 21 , right: 21 ) ,
SmartRefresher (
enablePullDown: true ,
enablePullUp: false ,
header: const MaterialClassicHeader (
color: MyColors . gradiantEndColor ,
) ,
) . paddingOnly ( top: 16 , bottom: 16 ) ,
itgRequestTypeIndex ! = null
? Expanded (
child: ListView . separated (
physics: BouncingScrollPhysics ( ) ,
itemBuilder: ( context , index ) {
return itgRowItem ( workListItemTypes [ workListItemIndex ] , itgFormsModel ! . requestType ! [ itgRequestTypeIndex ! ] . requestDetails ! [ index ] , index ) ;
} ,
separatorBuilder: ( context , index ) = > 12. height ,
itemCount: itgFormsModel ! . requestType ! [ itgRequestTypeIndex ! ] . requestDetails ? . length ? ? 0 ,
padding: const EdgeInsets . all ( 21 ) ,
) ,
)
: Expanded (
child: workList ! = null
? ( ( workList ! ) . isEmpty
? LocaleKeys . noHistoryAvailable . tr ( ) . toText16 ( ) . center
: ListView . separated (
physics: const BouncingScrollPhysics ( ) ,
controller: _refreshController ,
onRefresh: _onRefresh ,
child: SingleChildScrollView (
physics: const BouncingScrollPhysics ( ) ,
child: itgRequestTypeIndex ! = null
? Column (
children: [
SizedBox (
height: 40 ,
child: ListView . separated (
itemBuilder: ( context , index ) {
return rowItem ( workListItemTypes [ workListItemIndex ] , workList ! [ index ] , index ) ;
RequestType type = itgFormsModel ! . requestType ! [ index ] ;
return Container (
padding: const EdgeInsets . only ( left: 21 , right: 21 , top: 8 , bottom: 8 ) ,
alignment: Alignment . center ,
decoration: BoxDecoration ( borderRadius: BorderRadius . circular ( 30 ) , color: itgRequestTypeIndex = = index ? MyColors . darkIconColor : MyColors . lightGreyEAColor ) ,
child: ( " ${ type . requestTypeName } " ) . toText12 ( color: itgRequestTypeIndex = = index ? MyColors . white : MyColors . black ) ,
) . onPress ( ( ) {
if ( itgRequestTypeIndex ! = index ) {
itgRequestTypeIndex = index ;
setState ( ( ) { } ) ;
}
} ) ;
} ,
separatorBuilder: ( context , index ) = > 12. height ,
itemCount: workList ? . length ? ? 0 ,
padding: const EdgeInsets . all ( 21 ) ,
) )
: const SizedBox ( ) ,
) ,
separatorBuilder: ( context , index ) = > 8. width ,
shrinkWrap: true ,
itemCount: itgFormsModel ? . requestType ? . length ? ? 0 ,
scrollDirection: Axis . horizontal ,
padding: const EdgeInsets . only ( left: 21 , right: 21 ) ,
) ,
) . paddingOnly ( top: 16 , bottom: 16 ) ,
ListView . separated (
shrinkWrap: true ,
physics: const NeverScrollableScrollPhysics ( ) ,
itemBuilder: ( context , index ) {
return itgRowItem ( workListItemTypes [ workListItemIndex ] , itgFormsModel ! . requestType ! [ itgRequestTypeIndex ! ] . requestDetails ! [ index ] , index ) ;
} ,
separatorBuilder: ( context , index ) = > 12. height ,
itemCount: itgFormsModel ! . requestType ! [ itgRequestTypeIndex ! ] . requestDetails ? . length ? ? 0 ,
padding: const EdgeInsets . all ( 21 ) ,
) ,
] ,
)
: workList ! = null
? ( ( workList ! ) . isEmpty
? Utils . getNoDataWidget ( context ) . paddingOnly ( top: 100 )
: ListView . separated (
shrinkWrap: true ,
physics: const NeverScrollableScrollPhysics ( ) ,
itemBuilder: ( context , index ) {
return rowItem ( workListItemTypes [ workListItemIndex ] , workList ! [ index ] , index ) ;
} ,
separatorBuilder: ( context , index ) = > 12. height ,
itemCount: workList ? . length ? ? 0 ,
padding: const EdgeInsets . all ( 21 ) ,
) )
: const SizedBox ( ) ,
) ) . expanded ,
] ,
) ,
) ,
) ;
}
Widget itgRowItem ( WorkListItemTypeModelData data , RequestDetails requestDetails , int index ) {
Widget itgRowItem ( WorkListItemTypeModelData data ,
RequestDetails requestDetails , int index ) {
return InkWell (
onTap: ( ) async {
AppState ( ) . setItgWorkListIndex = index ;
var shouldReloadData = await Navigator . pushNamed ( context , AppRoutes . itgDetail ) ;
var shouldReloadData =
await Navigator . pushNamed ( context , AppRoutes . itgDetail ) ;
if ( shouldReloadData ! = null ) {
if ( shouldReloadData . toString ( ) = = " delegate_reload " ) {
providerData . itgFormsModel ! . totalCount =
providerData . itgFormsModel ! . totalCount ! - 1 ;
calculateCounter ( ) ;
getWorkList ( ) ;
}
@ -255,7 +350,8 @@ class _WorkListScreenState extends State<WorkListScreen> {
} ,
child: Container (
width: double . infinity ,
padding: const EdgeInsets . only ( left: 12 , right: 12 , top: 10 , bottom: 10 ) ,
padding:
const EdgeInsets . only ( left: 12 , right: 12 , top: 10 , bottom: 10 ) ,
decoration: BoxDecoration (
color: Colors . white ,
borderRadius: BorderRadius . circular ( 10 ) ,
@ -274,11 +370,20 @@ class _WorkListScreenState extends State<WorkListScreen> {
Container (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 4 ) ,
gradient: LinearGradient ( transform: GradientRotation ( . 218 ) , begin: Alignment . topRight , end: Alignment . bottomRight , colors: data . color ) ,
gradient: LinearGradient (
transform: GradientRotation ( . 218 ) ,
begin: Alignment . topRight ,
end: Alignment . bottomRight ,
colors: data . color ) ,
) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . center ,
children: [ SvgPicture . asset ( " assets/images/miss_swipe.svg " , width: 20 , height: 20 , color: Colors . white ) , 2. height , data . name . toText10 ( color: Colors . white ) ] ,
children: [
SvgPicture . asset ( " assets/images/miss_swipe.svg " ,
width: 20 , height: 20 , color: Colors . white ) ,
2. height ,
data . name . toText10 ( color: Colors . white )
] ,
) . paddingAll ( 6 ) ,
) ,
8. width ,
@ -292,10 +397,7 @@ class _WorkListScreenState extends State<WorkListScreen> {
Row (
children: [
DateUtil . formatDateToDate ( DateUtil . convertStringToDate ( requestDetails . modifiedDate ! ) , false ) . toText10 ( color: MyColors . lightTextColor ) . expanded ,
SvgPicture . asset (
" assets/images/arrow_next.svg " ,
color: MyColors . darkIconColor ,
)
RotatedBox ( quarterTurns: AppState ( ) . isArabic ( context ) ? 2 : 4 , child: SvgPicture . asset ( " assets/images/arrow_next.svg " , color: MyColors . darkIconColor ) ) ,
] ,
) ,
] ,
@ -307,12 +409,15 @@ class _WorkListScreenState extends State<WorkListScreen> {
) ;
}
Widget rowItem ( WorkListItemTypeModelData data , WorkListResponseModel workData , int index ) {
Widget rowItem ( WorkListItemTypeModelData data , WorkListResponseModel workData ,
int index ) {
return InkWell (
onTap: ( ) async {
AppState ( ) . setWorkListIndex = index ;
var data = workList ! [ index ] ;
var shouldReloadData = await Navigator . pushNamed ( context , AppRoutes . workListDetail , arguments: workData ) ;
var shouldReloadData = await Navigator . pushNamed (
context , AppRoutes . workListDetail ,
arguments: workData ) ;
if ( shouldReloadData ! = null ) {
if ( shouldReloadData . toString ( ) = = " delegate_reload " ) {
calculateCounter ( ) ;
@ -337,7 +442,8 @@ class _WorkListScreenState extends State<WorkListScreen> {
} ,
child: Container (
width: double . infinity ,
padding: const EdgeInsets . only ( left: 12 , right: 12 , top: 10 , bottom: 10 ) ,
padding:
const EdgeInsets . only ( left: 12 , right: 12 , top: 10 , bottom: 10 ) ,
decoration: BoxDecoration (
color: Colors . white ,
borderRadius: BorderRadius . circular ( 10 ) ,
@ -356,11 +462,20 @@ class _WorkListScreenState extends State<WorkListScreen> {
Container (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 4 ) ,
gradient: LinearGradient ( transform: GradientRotation ( . 218 ) , begin: Alignment . topRight , end: Alignment . bottomRight , colors: data . color ) ,
gradient: LinearGradient (
transform: GradientRotation ( . 218 ) ,
begin: Alignment . topRight ,
end: Alignment . bottomRight ,
colors: data . color ) ,
) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . center ,
children: [ SvgPicture . asset ( " assets/images/miss_swipe.svg " , width: 20 , height: 20 , color: Colors . white ) , 2. height , data . name . toText10 ( color: Colors . white ) ] ,
children: [
SvgPicture . asset ( " assets/images/miss_swipe.svg " ,
width: 20 , height: 20 , color: Colors . white ) ,
2. height ,
data . name . toText10 ( color: Colors . white )
] ,
) . paddingAll ( 6 ) ,
) ,
8. width ,
@ -374,10 +489,7 @@ class _WorkListScreenState extends State<WorkListScreen> {
Row (
children: [
DateUtil . formatDateToDate ( DateUtil . convertSimpleStringDateToDate ( workData . bEGINDATE ! ) , false ) . toText10 ( color: MyColors . lightTextColor ) . expanded ,
SvgPicture . asset (
" assets/images/arrow_next.svg " ,
color: MyColors . darkIconColor ,
)
RotatedBox ( quarterTurns: AppState ( ) . isArabic ( context ) ? 2 : 4 , child: SvgPicture . asset ( " assets/images/arrow_next.svg " , color: MyColors . darkIconColor ) ) ,
] ,
) ,
] ,