|
|
|
|
@ -16,6 +16,7 @@ import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/create_service_report.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/update_service_report.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/work_order_details_page.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
class WorkOrderListPage extends StatelessWidget {
|
|
|
|
|
@ -43,91 +44,92 @@ class WorkOrderListPage extends StatelessWidget {
|
|
|
|
|
child: FutureBuilder(
|
|
|
|
|
future: serviceRequestsProvider.searchWorkOrders(callId: serviceRequest.requestCode),
|
|
|
|
|
builder: (context, snap) {
|
|
|
|
|
workOrders = snap.data as List<SearchWorkOrder>;
|
|
|
|
|
if (snap.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
|
|
|
|
|
|
|
|
|
workOrders = snap.data as List<SearchWorkOrder>;
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
ListView.separated(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: workOrders?.length ?? 0,
|
|
|
|
|
separatorBuilder: (czt, index) => 8.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
(workOrders.isEmpty)
|
|
|
|
|
? NoItemFound(message: context.translation.noDataFound).expanded
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: workOrders.length,
|
|
|
|
|
separatorBuilder: (czt, index) => 8.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
StatusLabel(label: workOrders[index].currentSituation.name, textColor: AppColor.orange60, backgroundColor: AppColor.orange40),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(serviceRequest.requestCode, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3)
|
|
|
|
|
context.translation.edit.toSvgAsset(height: 48, width: 48).onPress(() {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(builder: (_) => UpdateServiceReport(request: serviceRequest, workOrder: workOrders[index])),
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.assetName}: ${workOrders[index].callRequest.asset.modelDefinition.assetName}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.status}: ${workOrders[index].currentSituation.name}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
Text(workOrders[index].visitDate?.toServiceRequestCardFormat ?? "",
|
|
|
|
|
textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
context.translation.viewDetails,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
const Icon(Icons.arrow_forward, color: Color(0xFF4A8DB7), size: 14)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(builder: (context) => WorkOrderDetailsPage(workOrder: workOrders[index], serviceRequest: serviceRequest)),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
},
|
|
|
|
|
).expanded,
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
StatusLabel(label: workOrders[index].currentSituation.name, textColor: AppColor.orange60, backgroundColor: AppColor.orange40),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(serviceRequest.requestCode, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3)
|
|
|
|
|
context.translation.edit.toSvgAsset(height: 48, width: 48).onPress(() {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(builder: (_) => UpdateServiceReport(request: serviceRequest, workOrder: workOrders[index])),
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.assetName}: ${workOrders[index].callRequest.asset.modelDefinition.assetName}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.status}: ${workOrders[index].currentSituation.name}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
Text(workOrders[index].visitDate?.toServiceRequestCardFormat ?? "",
|
|
|
|
|
textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
context.translation.viewDetails,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
const Icon(Icons.arrow_forward, color: Color(0xFF4A8DB7), size: 14)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(builder: (context) => WorkOrderDetailsPage(workOrder: workOrders[index], serviceRequest: serviceRequest)),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
},
|
|
|
|
|
).expanded,
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer && (serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3))
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.createWorkOrder,
|
|
|
|
|
|