|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
|
|
|
|
|
import 'package:test_sa/dashboard_latest/widgets/request_category_list.dart';
|
|
|
|
|
@ -15,6 +16,8 @@ import 'package:test_sa/new_views/common_widgets/tab_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../new_views/pages/land_page/widgets/request_item_view_list.dart';
|
|
|
|
|
|
|
|
|
|
class RequestCategoryFragment extends StatefulWidget {
|
|
|
|
|
const RequestCategoryFragment({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@ -75,13 +78,16 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
|
|
|
|
|
|
|
|
|
|
// Reload data with new sort order
|
|
|
|
|
dashboardProvider.resetRequestDataList();
|
|
|
|
|
dashboardProvider.getRequestDetail(
|
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
|
showLoader: true,
|
|
|
|
|
status: tabs[dashboardProvider.currentListIndex].tag,
|
|
|
|
|
tabId: tabs[dashboardProvider.currentListIndex].id,
|
|
|
|
|
isAscending: isAscending,
|
|
|
|
|
);
|
|
|
|
|
if (dashboardProvider.currentListIndex == null) {
|
|
|
|
|
} else {
|
|
|
|
|
dashboardProvider.getRequestDetail(
|
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
|
showLoader: true,
|
|
|
|
|
status: tabs[dashboardProvider.currentListIndex!].tag,
|
|
|
|
|
tabId: tabs[dashboardProvider.currentListIndex!].id,
|
|
|
|
|
isAscending: isAscending,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -104,47 +110,62 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
|
|
|
|
|
opacity: _headerFadeAnimation,
|
|
|
|
|
child: SlideTransition(
|
|
|
|
|
position: _headerSlideAnimation,
|
|
|
|
|
child: !isNurse && dashboardProvider.tabs.isNotEmpty && dashboardProvider.tabs[dashboardProvider.currentListIndex].tag == 0
|
|
|
|
|
? Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(context.translation.allWorkOrder, style: AppTextStyles.heading4.copyWith(color: AppColor.headingTextColor(context))),
|
|
|
|
|
// Row(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
// children: [
|
|
|
|
|
// context.translation.allWorkOrder.heading4(context),
|
|
|
|
|
// GestureDetector(
|
|
|
|
|
// onTap: () {
|
|
|
|
|
// dashboardProvider.isShowDashBoardCalendar = !dashboardProvider.isShowDashBoardCalendar;
|
|
|
|
|
// },
|
|
|
|
|
// child: dashboardProvider.isShowDashBoardCalendar ? AppAsset.listIcon.toSvgAsset() : AppAsset.calendarIcon.toSvgAsset())
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
dashboardProvider.isShowDashBoardCalendar
|
|
|
|
|
? Padding(
|
|
|
|
|
padding: EdgeInsets.only(top: 12.toScreenHeight),
|
|
|
|
|
child: const WeeklyCalendarFragment(),
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox(),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(start: 14, end: 12)
|
|
|
|
|
: Row(
|
|
|
|
|
spacing: 16,
|
|
|
|
|
children: [
|
|
|
|
|
Text(context.translation.allWorkOrder, style: AppTextStyles.heading4.copyWith(color: AppColor.headingTextColor(context))).expanded,
|
|
|
|
|
// todo commenting this code, for FM
|
|
|
|
|
// if (!isFMSEngineer)
|
|
|
|
|
// 'search'.toSvgAsset(width: 24, height: 24, color: AppColor.headingTextColor(context)).onPress(() {
|
|
|
|
|
// Navigator.of(context).pushNamed('/cleaner_search');
|
|
|
|
|
// }),
|
|
|
|
|
Transform.flip(
|
|
|
|
|
flipY: isAscending,
|
|
|
|
|
child: 'dashboard/sort_descending'.toSvgAsset(width: 24, height: 24, color: AppColor.headingTextColor(context)).onPress(() {
|
|
|
|
|
_toggleSort(dashboardProvider, user?.type);
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(start: 16, end: 16),
|
|
|
|
|
child:
|
|
|
|
|
// !isNurse && dashboardProvider.tabs.isNotEmpty
|
|
|
|
|
// //&& dashboardProvider.tabs[dashboardProvider.currentListIndex].tag == 0
|
|
|
|
|
// ? Column(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// Text(context.translation.allWorkOrder, style: AppTextStyles.heading4.copyWith(color: AppColor.headingTextColor(context))),
|
|
|
|
|
// // Row(
|
|
|
|
|
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
// // children: [
|
|
|
|
|
// // context.translation.allWorkOrder.heading4(context),
|
|
|
|
|
// // GestureDetector(
|
|
|
|
|
// // onTap: () {
|
|
|
|
|
// // dashboardProvider.isShowDashBoardCalendar = !dashboardProvider.isShowDashBoardCalendar;
|
|
|
|
|
// // },
|
|
|
|
|
// // child: dashboardProvider.isShowDashBoardCalendar ? AppAsset.listIcon.toSvgAsset() : AppAsset.calendarIcon.toSvgAsset())
|
|
|
|
|
// // ],
|
|
|
|
|
// // ),
|
|
|
|
|
// dashboardProvider.isShowDashBoardCalendar
|
|
|
|
|
// ? Padding(
|
|
|
|
|
// padding: EdgeInsets.only(top: 12.toScreenHeight),
|
|
|
|
|
// child: const WeeklyCalendarFragment(),
|
|
|
|
|
// )
|
|
|
|
|
// : const SizedBox(),
|
|
|
|
|
// ],
|
|
|
|
|
// ).paddingOnly(start: 14, end: 12)
|
|
|
|
|
// :
|
|
|
|
|
Row(
|
|
|
|
|
spacing: 16,
|
|
|
|
|
children: [
|
|
|
|
|
Text(context.translation.allWorkOrder, style: AppTextStyles.heading4.copyWith(color: AppColor.headingTextColor(context))).expanded,
|
|
|
|
|
// todo commenting this code, for FM
|
|
|
|
|
// if (!isFMSEngineer)
|
|
|
|
|
// 'search'.toSvgAsset(width: 24, height: 24, color: AppColor.headingTextColor(context)).onPress(() {
|
|
|
|
|
// Navigator.of(context).pushNamed('/cleaner_search');
|
|
|
|
|
// }),
|
|
|
|
|
|
|
|
|
|
if (dashboardProvider.listIndex.isNotEmpty)
|
|
|
|
|
Text(
|
|
|
|
|
'Clear Filters',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.red30),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
dashboardProvider.resetRequestDataList();
|
|
|
|
|
dashboardProvider.currentListIndex = null;
|
|
|
|
|
Provider.of<AllRequestsProvider>(context, listen: false)
|
|
|
|
|
..reset()
|
|
|
|
|
..getAllRequests(context);
|
|
|
|
|
}),
|
|
|
|
|
Transform.flip(
|
|
|
|
|
flipY: isAscending,
|
|
|
|
|
child: 'dashboard/sort_descending'.toSvgAsset(width: 24, height: 24, color: AppColor.headingTextColor(context)).onPress(() {
|
|
|
|
|
_toggleSort(dashboardProvider, user?.type);
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(start: 16, end: 16),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
@ -159,19 +180,26 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
|
|
|
|
|
// ],
|
|
|
|
|
// ).paddingOnly(start: 16, end: 16)
|
|
|
|
|
// : context.translation.allWorkOrder.heading4(context).paddingOnly(start: 16, end: 16),
|
|
|
|
|
|
|
|
|
|
dashboardProvider.isDetailLoading
|
|
|
|
|
? Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
|
children: List.generate(3, (index) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight, horizontal: 0),
|
|
|
|
|
child: const SizedBox().toRequestShimmer(context, dashboardProvider.isDetailLoading),
|
|
|
|
|
);
|
|
|
|
|
})).paddingOnly(start: 16, end: 16, top: 16)
|
|
|
|
|
: (dashboardProvider.requestDetailList == null || dashboardProvider.requestDetailList?.data?.isEmpty == true)
|
|
|
|
|
? const NoDataFound().paddingOnly(top: 80).center
|
|
|
|
|
: RequestCategoryList(dashboardProvider.requestDetailList?.data ?? <Data>[], dashboardProvider.isDetailLoading, dashboardProvider.requestDetailList?.totalRows ?? 0),
|
|
|
|
|
(dashboardProvider.currentListIndex == null)
|
|
|
|
|
? Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
|
|
|
|
|
return RequestItemViewList(
|
|
|
|
|
snapshot.allRequestsAndCount?.requestsDetails ?? [],
|
|
|
|
|
snapshot.isAllLoading,
|
|
|
|
|
key: ValueKey('request_list_'), // Key changes on every tab click
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
: dashboardProvider.isDetailLoading
|
|
|
|
|
? Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
|
children: List.generate(3, (index) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight, horizontal: 0),
|
|
|
|
|
child: const SizedBox().toRequestShimmer(context, dashboardProvider.isDetailLoading),
|
|
|
|
|
);
|
|
|
|
|
})).paddingOnly(start: 16, end: 16, top: 16)
|
|
|
|
|
: (dashboardProvider.requestDetailList == null || dashboardProvider.requestDetailList?.data?.isEmpty == true)
|
|
|
|
|
? const NoDataFound().paddingOnly(top: 80).center
|
|
|
|
|
: RequestCategoryList(dashboardProvider.requestDetailList?.data ?? <Data>[], dashboardProvider.isDetailLoading, dashboardProvider.requestDetailList?.totalRows ?? 0),
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|