You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
7.4 KiB
Dart
162 lines
7.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
import 'package:test_sa/models/enums/user_types.dart';
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
import 'package:test_sa/modules/traf_module/traf_request_provider.dart';
|
|
import 'package:test_sa/modules/traf_module/update_traf_request_page.dart';
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
import 'traf_request_model.dart';
|
|
|
|
class TrafRequestDetailPage extends StatefulWidget {
|
|
static const String id = "/details-TRAF";
|
|
|
|
final int trafId;
|
|
|
|
TrafRequestDetailPage({Key? key, required this.trafId}) : super(key: key);
|
|
|
|
@override
|
|
_TrafRequestDetailPageState createState() {
|
|
return _TrafRequestDetailPageState();
|
|
}
|
|
}
|
|
|
|
class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
Provider.of<TrafRequestProvider>(context, listen: false).getTRAFById(widget.trafId);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
bool isEngineer = (Provider.of<UserProvider>(context, listen: false).user?.type) == UsersTypes.engineer;
|
|
return Scaffold(
|
|
appBar: const DefaultAppBar(title: "TRAF Request"),
|
|
body: Selector<TrafRequestProvider, bool>(
|
|
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
|
|
builder: (_, isLoading, __) {
|
|
if (isLoading) return const ALoading();
|
|
TrafRequestProvider trafProvider = Provider.of<TrafRequestProvider>(context, listen: false);
|
|
|
|
return Column(
|
|
children: [
|
|
ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
requesterInformation(trafProvider.trafRequestDataModel!),
|
|
12.height,
|
|
requestInformation(trafProvider.trafRequestDataModel!),
|
|
if (trafProvider.trafRequestDataModel!.requestTypeId == 733) ...[
|
|
12.height,
|
|
assetInformation(trafProvider.trafRequestDataModel!),
|
|
]
|
|
],
|
|
).expanded,
|
|
// if (isEngineer)
|
|
FooterActionButton.footerContainer(
|
|
context: context,
|
|
child: AppFilledButton(
|
|
buttonColor: AppColor.primary10,
|
|
label: "Update",
|
|
onPressed: () {
|
|
Navigator.pushNamed(context, UpdateTrafRequestPage.id);
|
|
}),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
));
|
|
}
|
|
|
|
Widget requesterInformation(TrafRequestDataModel data) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Requester Information",
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
),
|
|
8.height,
|
|
'${context.translation.employeeId}: ${data.employeeId ?? '-'}'.bodyText(context),
|
|
'${context.translation.name}: ${data.employeeId ?? '-'}'.bodyText(context), // todo ask shaheer
|
|
'${context.translation.email}: ${data.employeeId ?? '-'}'.bodyText(context), // todo ask shaheer
|
|
'Position: ${data.employeeId ?? '-'}'.bodyText(context), // todo ask shaheer
|
|
'${context.translation.site}: ${data.siteName ?? '-'}'.bodyText(context),
|
|
'${context.translation.department}: ${data.departments ?? '-'}'.bodyText(context),
|
|
'Requester Extension: ${data.requesterExtensionName ?? '-'}'.bodyText(context),
|
|
'${context.translation.extensionNo}: ${data.requesterExtensionNumber ?? '-'}'.bodyText(context),
|
|
],
|
|
).toShadowContainer(context, borderRadius: 20, padding: 12);
|
|
}
|
|
|
|
Widget requestInformation(TrafRequestDataModel data) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"TRAF Request Information",
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
),
|
|
8.height,
|
|
'TRAF No: ${data.reqCode ?? '-'}'.bodyText(context),
|
|
'Request type: ${data.requestTypeName ?? '-'}'.bodyText(context),
|
|
4.height,
|
|
'What is the current practice?:\n${data.currentPractise ?? '-'}'.bodyText(context),
|
|
4.height,
|
|
'Census Q1: ${data.censusQ1 ?? '-'}'.bodyText(context),
|
|
'Census Q2: ${data.censusQ2 ?? '-'}'.bodyText(context),
|
|
'Census Q3: ${data.censusQ3 ?? '-'}'.bodyText(context),
|
|
'Census Q4: ${data.censusQ4 ?? '-'}'.bodyText(context),
|
|
4.height,
|
|
'List down names & contact information of users going to use the technology & specify if they are part-time or full time?:\n${data.trafContacts ?? '-'}'.bodyText(context),
|
|
4.height,
|
|
'Is the requesting department going to use the technology solely or shared with other departments?:\n${data.usingSolelyOrSharedId ?? '-'}'.bodyText(context),
|
|
4.height,
|
|
'Would other services be effected by acquiring the new equipment?:\n${data.effectedServices ?? '-'}'.bodyText(context),
|
|
4.height,
|
|
'Is the equipment going to be used with combination of other equipment to accomplish a specific procedure?:\n${data.usedWithCombination ?? '-'}'.bodyText(context),
|
|
],
|
|
).toShadowContainer(context, borderRadius: 20, padding: 12);
|
|
}
|
|
|
|
Widget assetInformation(TrafRequestDataModel data) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Asset Information",
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
),
|
|
8.height,
|
|
'Last price & PO: ${data.poNumber ?? '-'}'.bodyText(context),
|
|
'The quantity of the same asset: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Existing asset under SLA: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Age of the asset: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Total Maintenance Cost (TMC): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Net Book Value (NBV): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Mean Time Between Failure (MTBF): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Down Time (DT): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Up Time (UT): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
'Purchased Price: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer
|
|
],
|
|
).toShadowContainer(context, borderRadius: 20, padding: 12);
|
|
}
|
|
}
|