Ui improvement and delivery inspection new apis implemented

design_3.0_asset_delivery_module
WaseemAbbasi22 6 days ago
parent a0a084803d
commit 0908cda2b0

@ -412,6 +412,8 @@ class URLs {
static get getAssetDeliveryInspectionData => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/GetAssetDeliveryExternalDeliveryInspectionByDeliveryId';
static get getOracleUserList => '$_baseUrl/AssetDeliveryExternal/GetEmployeesFromOracle';
static get saveMasterInfoDeliveryInspection => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/SaveMaseterInfoDeliveryInspection';
static get sendEmailToAddSignature => '$_baseUrl/Signature/SendEmailToAddSignature';
static get getLineFromExternalPo => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/GetLineFromExternalPo';
static get getCostCenterListToLineDeliveryInspection => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/GetCostCenterToLineDeliveryInspection';

@ -40,7 +40,7 @@ class AssetProvider extends ChangeNotifier {
List<Asset> _devices = [];
List<Asset> _searchDevices = [];
List<TechnicalInspectionAssetBasicInfoModel> technicalInspectionAsset= [];
List<TechnicalInspectionAssetBasicInfoModel> technicalInspectionAsset = [];
List<Asset> get devices => _devices;
@ -133,8 +133,6 @@ class AssetProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
List equipmentListJson = json.decode(response.body)["data"];
var dList = equipmentListJson.map<TechnicalInspectionAssetBasicInfoModel>((asset) => TechnicalInspectionAssetBasicInfoModel.fromJson(asset)).toList() ?? [];
log('dlist ${dList.length}');
technicalInspectionAsset.addAll(dList);
nextPage = true;
} else {

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/attachment_view.dart';
@ -58,7 +60,7 @@ class HelperFunction {
children: [
SingleItemDropDownMenu<Lookup, AttachmentTypeLookupProvider>(
context: context,
title: context.translation.reason,
title: 'Attachment Type'.addTranslation,
onSelect: (value) {
Navigator.pop(context, value);
},

@ -44,13 +44,13 @@ class DeliveryInspectionFormModel {
'deliveryInspectionInspectedDateTo': deliveryInspectionInspectedDateTo?.toIso8601String(),
'totalTime': totalTime,
'deliveryInspectionInspectedBy': inspectedByModel?.name,
"deliveryInspectionInspectedBySignature": inspectedByModel?.signature,
// "deliveryInspectionInspectedBySignature": inspectedByModel?.signature,
"deliveryInspectionInspectedByEmail": inspectedByModel?.email,
'deliveryInspectionApprovedBy': approvedByModel?.name,
"deliveryInspectionApprovedBySignature": approvedByModel?.signature,
// "deliveryInspectionApprovedBySignature": approvedByModel?.signature,
"deliveryInspectionApprovedByEmail": approvedByModel?.email,
"deliveryInspectionThirdApproverBy": thirdApprovalModel?.name,
"deliveryInspectionThirdApproverBySignature": thirdApprovalModel?.signature,
// "deliveryInspectionThirdApproverBySignature": thirdApprovalModel?.signature,
"deliveryInspectionThirdApproverByEmail": thirdApprovalModel?.email,
};
}

@ -14,6 +14,7 @@ class TechnicalInspectionAssetModel {
num? id;
num? tableItemId;
num? lineId;
num? lineNo;
num? assetDeliveryInternalDetailAssetId;
num? assetDeliveryInternalDetailAssetChildId;
num? costCenterId;
@ -47,6 +48,7 @@ class TechnicalInspectionAssetModel {
this.tableItemId,
this.status,
this.lineId,
this.lineNo,
this.costCenterId,
this.assetNumber,
this.assetOrigin,
@ -73,6 +75,7 @@ class TechnicalInspectionAssetModel {
TechnicalInspectionAssetModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
lineNo = json['lineNo'];
assetDeliveryInternalDetailAssetId = json['assetDeliveryInternalDetailAssetId'];
assetDeliveryInternalDetailAssetChildId = json['assetDeliveryInternalDetailAssetChildId'];
assetNumber = json['assetNumber'];
@ -106,6 +109,7 @@ class TechnicalInspectionAssetModel {
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = {};
data['id'] = id;
// data['lineNo'] = lineNo;
data['assetDeliveryInternalDetailAssetId'] = assetDeliveryInternalDetailAssetId;
data['assetDeliveryExternalDeliveryId'] = tableItemId;
data['assetDeliveryExternalDetailId'] = lineId;

@ -87,13 +87,13 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
requestDetailCard(context),
const Divider().defaultStyle(context),
requestDetailCard(context).toShadowContainer(context, borderRadius: 20),
20.height,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Asset Delivery Table",
"Asset Delivery Table".addTranslation,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
Row(
@ -130,10 +130,10 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
}),
],
),
8.height,
16.height,
assetDeliveryTableList(context: context, assetDeliveryProvider: provider),
],
).toShadowContainer(context, borderRadius: 20),
),
);
},
),

@ -27,10 +27,10 @@ class AssetDeliveryAttachmentView extends StatefulWidget {
bool viewOnly = false;
final List<GenericAttachmentModel> attachmentList;
AssetDeliveryAttachmentView({
AssetDeliveryAttachmentView({
super.key,
required this.attachmentList,
this.viewOnly=false,
this.viewOnly = false,
this.attachmentType,
this.tableItemId,
});
@ -106,15 +106,16 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
],
),
),
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
buttonColor: AppColor.primary10,
label: 'Save'.addTranslation,
maxWidth: true,
onPressed: _onSavePressed,
if (widget.attachmentType == 5 && !widget.viewOnly)
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
buttonColor: AppColor.primary10,
label: 'Save'.addTranslation,
maxWidth: true,
onPressed: _onSavePressed,
),
),
),
],
),
);

@ -77,9 +77,11 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
),
]);
model = results[0] as DeliveryInspectionFormModel;
setState(() {
isLoading = false;
});
if (mounted) {
setState(() {
isLoading = false;
});
}
}
@override
@ -91,12 +93,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
// appBar: DefaultAppBar(
// title: 'Delivery Inspection'.addTranslation,
// onBackPress: () {
// Navigator.pop(context);
// },
// ),
body: isLoading
? const CircularProgressIndicator(color: AppColor.primary10).center
: Form(
@ -104,51 +100,38 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
child: Column(
children: [
SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!viewOnly) ...[inspectionDetailsForm()] else ...[inspectionDetails()],
8.height,
Text(
'Total Time'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
Text(
formatInspectionDuration(model.totalTime),
style: AppTextStyles.bodyText2.copyWith(
color: context.isDark ? AppColor.neutral30 : AppColor.neutral120,
),
),
// Text(
// model.totalTime != null ? '${model.totalTime.toString()} hours' : '-',
// style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
// ),
8.height,
const Divider().defaultStyle(context),
Text(
"Lines",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
linesList(context),
],
).toShadowContainer(context, borderRadius: 20, padding: 12))
.expanded,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!viewOnly) ...[inspectionDetailsForm()] else ...[inspectionDetails()],
20.height,
Text(
"Lines",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
linesList(context),
],
)).expanded,
FooterActionButton.footerContainer(
context: context,
child: !viewOnly
? Column(
children: [
AppFilledButton(
buttonColor: AppColor.primary10,
label: 'Attachments'.addTranslation,
maxWidth: true,
onPressed: () {
HelperFunction.attachmentTap(context: context, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id);
}),
Row(
children: [
AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap).expanded,
8.width,
AppFilledButton(
buttonColor: AppColor.primary10,
label: 'Attachments'.addTranslation,
maxWidth: true,
onPressed: () {
HelperFunction.attachmentTap(context: context, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id);
}).expanded,
],
),
16.height,
Row(
children: [
@ -247,6 +230,7 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
Widget inspectionDetailsForm() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_inspectionTile(
title: 'Inspected by'.addTranslation,
@ -264,7 +248,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
}
},
),
8.height,
_inspectionTile(
title: 'Approved by'.addTranslation,
@ -285,13 +268,13 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
if (widget.requestModel?.paymentTerm?.value == 2) ...[
8.height,
_inspectionTile(
title: 'Third Approved by'.addTranslation,
title: 'ThirdApprover'.addTranslation,
model: model.thirdApprovalModel,
isHmg: widget.requestModel?.isHMG == true,
onTap: () async {
final result = await showInspectionBottomSheet(
context,
title: 'Third Approved by'.addTranslation,
title: 'ThirdApprover'.addTranslation,
isHmg: widget.requestModel?.isHMG == true,
initialModel: model.thirdApprovalModel ?? InspectionPersonModel(),
);
@ -301,57 +284,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
},
),
],
// if (widget.requestModel?.isHMG == true) ...[
// OracleUserAutoCompleteField(
// clearAfterPick: false,
// initialValue: model.deliveryInspectionInspectedBy ?? '',
// label: 'Inspected by'.addTranslation,
// onPick: (value) {
// model.deliveryInspectionInspectedBy = value.fullName;
// setState(() {});
// },
// onChanged: (value) {},
// ),
// 8.height,
// OracleUserAutoCompleteField(
// clearAfterPick: false,
// initialValue: model.deliveryInspectionApprovedBy ?? '',
// label: 'Approved by'.addTranslation,
// onChanged: (value) {},
// onPick: (value) {
// model.deliveryInspectionApprovedBy = value.fullName;
// setState(() {});
// },
// ),
// ] //No HMG user free text insted of dropdown ...
// else ...[
// AppTextFormField(
// labelText: 'Inspected by'.addTranslation,
// backgroundColor: AppColor.fieldBgColor(context),
// initialValue: model.deliveryInspectionInspectedBy ?? '',
// textAlign: TextAlign.center,
// labelStyle: AppTextStyles.textFieldLabelStyle,
// showShadow: false,
// onChange: (value) {
// model.deliveryInspectionInspectedBy = value;
// },
// style: Theme.of(context).textTheme.titleMedium,
// ),
// 8.height,
// AppTextFormField(
// labelText: 'Approved by'.addTranslation,
// backgroundColor: AppColor.fieldBgColor(context),
// initialValue: model.deliveryInspectionApprovedBy ?? '',
// textAlign: TextAlign.center,
// labelStyle: AppTextStyles.textFieldLabelStyle,
// showShadow: false,
// onChange: (value) {
// model.deliveryInspectionApprovedBy = value;
// },
// style: Theme.of(context).textTheme.titleMedium,
// ),
// ],
8.height,
ADatePicker(
label: 'Inspected Date/Time From'.addTranslation,
@ -385,7 +317,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
setState(() {});
},
),
8.height,
ADatePicker(
label: 'Inspected Date/Time To'.addTranslation,
@ -424,8 +355,20 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
setState(() {});
},
),
8.height,
Text(
'Total Time'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
Text(
formatInspectionDuration(model.totalTime),
style: AppTextStyles.bodyText2.copyWith(
color: context.isDark ? AppColor.neutral30 : AppColor.neutral120,
),
),
],
);
).toShadowContainer(context, borderRadius: 20, padding: 12);
}
bool _validateInspectionDates({DateTime? from, DateTime? to}) {
@ -552,8 +495,20 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
model.deliveryInspectionInspectedDateTo != null ? model.deliveryInspectionInspectedDateTo!.toString().toServiceRequestDetailsFormat : '-',
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
),
8.height,
Text(
'Total Time'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
Text(
formatInspectionDuration(model.totalTime),
style: AppTextStyles.bodyText2.copyWith(
color: context.isDark ? AppColor.neutral30 : AppColor.neutral120,
),
),
],
);
).toShadowContainer(context, borderRadius: 20, padding: 12);
}
Widget _inspectionTile({
@ -603,24 +558,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
);
}
Future<Lookup?> showAttachmentTypePicker() {
return showDialog<Lookup>(
context: context,
builder: (_) {
return AlertDialog(
content: SingleItemDropDownMenu<Lookup, AttachmentTypeLookupProvider>(
context: context,
title: context.translation.reason,
showAsFullScreenDialog: false,
onSelect: (value) {
Navigator.pop(context, value);
},
),
);
},
);
}
void _cancelTap() async {
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
await assetDeliveryProvider!.changeDeliveryStatusToCancel(itemId: widget.deliveryTableModel.id).then((status) async {
@ -632,6 +569,19 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
});
}
void _saveTap() async {
_formKey.currentState!.save();
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
model.assetDeliveryExternalDeliveryId = widget.deliveryTableModel.id;
await assetDeliveryProvider!.saveMasterInfoDeliveryInspection(requestPayload: model.toJson()).then((status) async {
Navigator.pop(context);
if (status) {
Navigator.pop(context);
await assetDeliveryProvider!.getAssetDeliveryTableListById(requestId: widget.requestModel?.id);
}
});
}
void _nextTap() {
if (widget.deliveryTableModel.isContainsTechnicalInspection == true) {
// Navigator.push(
@ -678,8 +628,8 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
void _changeStatusTap() async {
_formKey.currentState!.save();
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
model.assetDeliveryExternalDeliveryId = widget.deliveryTableModel.id;
await assetDeliveryProvider!.changeDeliveryStatus(requestPayload: model.toJson()).then((status) async {
// await assetDeliveryProvider!.changeDeliveryStatus(requestPayload: model.toJson()).then((status) async {
await assetDeliveryProvider!.changeDeliveryStatus(itemId: widget.deliveryTableModel.id).then((status) async {
Navigator.pop(context);
if (status) {
Navigator.pop(context);
@ -707,6 +657,7 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
return InspectionPersonBottomSheet(
title: title,
isHmg: isHmg,
tableId: widget.deliveryTableModel.id,
model: InspectionPersonModel(
name: initialModel.name,
email: initialModel.email,

@ -2,14 +2,19 @@ import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/dashboard_latest/widgets/app_bar_widget.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/asset_delivery_module/models/inspection_person_model.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/oracle_user_autocomplete_field.dart';
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.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/app_lazy_loading.dart';
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/e_signature/e_signature.dart';
@ -17,12 +22,14 @@ class InspectionPersonBottomSheet extends StatefulWidget {
final String title;
bool isHmg;
final InspectionPersonModel model;
int? tableId;
InspectionPersonBottomSheet({
super.key,
required this.title,
required this.isHmg,
required this.model,
this.tableId,
});
@override
@ -67,7 +74,7 @@ class _InspectionPersonBottomSheetState extends State<InspectionPersonBottomShee
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.title, style: Theme.of(context).textTheme.titleLarge),
16.height,
12.height,
if (widget.isHmg)
OracleUserAutoCompleteField(
clearAfterPick: false,
@ -94,46 +101,90 @@ class _InspectionPersonBottomSheetState extends State<InspectionPersonBottomShee
setState(() {});
},
),
12.height,
AppTextFormField(
labelText: 'Email'.addTranslation,
controller: emailController,
textInputType: TextInputType.emailAddress,
backgroundColor: AppColor.fieldBgColor(context),
showShadow: false,
enable: widget.isHmg?false:true,
textAlign: TextAlign.center,
labelStyle: AppTextStyles.textFieldLabelStyle,
style: Theme.of(context).textTheme.titleMedium,
onChange: (v) {
setState(() {
_model.email = v;
});
},
8.height,
Row(
children: [
AppTextFormField(
labelText: 'Email'.addTranslation,
controller: emailController,
textInputType: TextInputType.emailAddress,
backgroundColor: AppColor.fieldBgColor(context),
showShadow: false,
enable: widget.isHmg ? false : true,
textAlign: TextAlign.center,
labelStyle: AppTextStyles.textFieldLabelStyle,
style: Theme.of(context).textTheme.titleMedium,
onChange: (v) {
setState(() {
_model.email = v;
});
},
).expanded,
if (emailController.text.isNotEmpty) ...[
8.width,
AppFilledButton(
buttonColor: AppColor.primary10,
label: 'SendEmail'.addTranslation,
width: 100.toScreenWidth,
height: 54,
onPressed: () async {
AssetDeliveryProvider assetDeliveryProvider = Provider.of<AssetDeliveryProvider>(context, listen: false);
if (nameController.text.isEmpty) {
return 'Enter Name'.showToast;
}
String type = '';
if (widget.title.contains('Inspected')) {
type = 'Inspected';
} else if (widget.title.contains('Approved')) {
type = 'Approved';
} else if (widget.title.contains('ThirdApprover')) {
type = 'ThirdApprover';
}
Map<String, dynamic> payload = {
"recordId": widget.tableId,
"parameter1": "DeliveryInspection",
"parameter2": type,
"username": nameController.text,
"email": emailController.text
};
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
await assetDeliveryProvider.sendEmailToAddSignature(requestPayload: payload).then((status) async {
Navigator.pop(context);
if (status) {
'Email sent successfully'.showToast;
}
});
//send email.
}),
],
],
),
12.height,
8.height,
ESignature(
title: '',
editable: false,
oldSignature: _model.localSignature == null ? _model.signature : null,
newSignature: _model.localSignature,
backgroundColor: AppColor.neutral100,
showShadow: false,
onChange: (signature) {
if (signature.isEmpty) return;
setState(() {
_model.localSignature = signature;
_model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
});
},
onSaved: (signature) {
if (signature == null || signature.isEmpty) return;
setState(() {
_model.localSignature = signature;
_model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
});
},
// onChange: (signature) {
// if (signature.isEmpty) return;
// setState(() {
// _model.localSignature = signature;
// _model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// });
// },
// onSaved: (signature) {
// if (signature == null || signature.isEmpty) return;
// setState(() {
// _model.localSignature = signature;
// _model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// });
// },
),
20.height,
12.height,
AppFilledButton(
label: context.translation.save,
maxWidth: true,

@ -83,7 +83,7 @@ class _EndUserCostCenterLIstViewState extends State<EndUserCostCenterLIstView> {
: Column(
children: [
//Refactor this
SingleChildScrollView(padding: const EdgeInsets.all(16), child: linesList(context).toShadowContainer(context, borderRadius: 20, padding: 12)).expanded,
SingleChildScrollView(padding: const EdgeInsets.all(16), child: linesList(context)).expanded,
!viewOnly
? FooterActionButton.footerContainer(

@ -108,9 +108,7 @@ class _UpdateEndUserCostCenterDetailsViewState extends State<UpdateEndUserCostCe
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
inspectionDetailsForm(),
8.height,
const Divider().defaultStyle(context),
inspectionDetailsForm().toShadowContainer(context, borderRadius: 20, padding: 12),
///Need to implement later as discuss with Ahmed.
// Text(
@ -130,15 +128,15 @@ class _UpdateEndUserCostCenterDetailsViewState extends State<UpdateEndUserCostCe
// 'web_link_icon'.toSvgAsset(height: 20, width: 20),
// ],
// ),
16.height,
20.height,
Text(
"Items",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
16.height,
endUserAssetList(context),
],
).toShadowContainer(context, borderRadius: 20, padding: 12))
))
.expanded,
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
],

@ -14,17 +14,17 @@ import 'package:test_sa/views/widgets/requests/request_status.dart';
class AssetDeliveryHistoryLogView extends StatefulWidget {
final int? tableItemId;
const AssetDeliveryHistoryLogView({Key? key,this.tableItemId}) : super(key: key);
const AssetDeliveryHistoryLogView({Key? key, this.tableItemId}) : super(key: key);
@override
State<AssetDeliveryHistoryLogView> createState() => _AssetDeliveryHistoryLogViewState();
}
class _AssetDeliveryHistoryLogViewState extends State<AssetDeliveryHistoryLogView> {
List<AssetDeliveryHistoryModel> history = [];
bool loading = false;
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) {
@ -33,10 +33,18 @@ class _AssetDeliveryHistoryLogViewState extends State<AssetDeliveryHistoryLogVie
super.initState();
}
void getInitialData() async {
setState(() {
loading = true;
});
history = await Provider.of<AssetDeliveryProvider>(context, listen: false).getHistory(tableItemId: widget.tableItemId);
if (mounted) {
setState(() {
loading = false;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -47,65 +55,64 @@ class _AssetDeliveryHistoryLogViewState extends State<AssetDeliveryHistoryLogVie
// Navigator.pop(context);
// },
// ),
body: Consumer<AssetDeliveryProvider>(builder: (context, provider, _) {
return provider.isLoading
? const CircularProgressIndicator(color: AppColor.primary10).center
: Stack(
children: [
Padding(
padding: EdgeInsets.only(left: 122.toScreenWidth),
child: const VerticalDivider(
color: AppColor.white40,
thickness: 2,
width: 20,
indent: 10,
endIndent: 10,
),
),
SafeArea(
child: Builder(builder: (cxt) {
List<Widget> items = [];
String lastStatus = "";
DateTime? nextDate;
for (int i = 0; i < history.length; i++) {
var object = history[i];
String currentStatus = object.status!.name!;
if (lastStatus.isEmpty) {
lastStatus = currentStatus;
}
if (lastStatus == currentStatus) {
if (i + 1 < history.length) {
nextDate = history[i + 1].createdDate;
String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!);
object.timeDifference = timeDifference;
} else {
object.timeDifference = ''; // Empty string for the last action
body: loading
? const CircularProgressIndicator(color: AppColor.primary10).center
: Stack(
children: [
Padding(
padding: EdgeInsets.only(left: 122.toScreenWidth),
child: const VerticalDivider(
color: AppColor.white40,
thickness: 2,
width: 20,
indent: 10,
endIndent: 10,
),
),
SafeArea(
child: Builder(builder: (cxt) {
List<Widget> items = [];
String lastStatus = "";
DateTime? nextDate;
for (int i = 0; i < history.length; i++) {
var object = history[i];
String currentStatus = object.status!.name!;
if (lastStatus.isEmpty) {
lastStatus = currentStatus;
}
if (lastStatus == currentStatus) {
if (i + 1 < history.length) {
nextDate = history[i + 1].createdDate;
String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!);
object.timeDifference = timeDifference;
} else {
object.timeDifference = ''; // Empty string for the last action
}
items.add(historyLogCard(cxt, object));
} else {
items.add(statusCard(cxt, lastStatus));
lastStatus = currentStatus;
if (i + 1 < history.length) {
nextDate = history[i + 1].createdDate;
String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!);
object.timeDifference = timeDifference;
} else {
object.timeDifference = ''; // Empty string for the last action
}
items.add(historyLogCard(cxt, object));
}
}
items.add(historyLogCard(cxt, object));
} else {
items.add(statusCard(cxt, lastStatus));
lastStatus = currentStatus;
if (i + 1 < history.length) {
nextDate = history[i + 1].createdDate;
String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!);
object.timeDifference = timeDifference;
} else {
object.timeDifference = ''; // Empty string for the last action
}
items.add(historyLogCard(cxt, object));
}
}
items.add(statusCard(cxt, lastStatus));
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(children: items),
);
}),
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(children: items),
);
}),
),
],
),
],
);
}),
);}
);
}
Widget historyLogCard(BuildContext context, AssetDeliveryHistoryModel object) {
String title = object.status!.name!;
@ -148,7 +155,8 @@ class _AssetDeliveryHistoryLogViewState extends State<AssetDeliveryHistoryLogVie
),
).paddingOnly(bottom: 16, start: 40);
}
// Need to check status text we have
//Todo Need to check status text we have
String statusText(String status) {
if (status == "new" || status == "open") {
return "New".addTranslation;

@ -94,18 +94,19 @@ class _InspectionCheckListViewState extends State<InspectionCheckListView> {
}
Widget inspectionStatusRadioWidget({required int index, required InspectionChecklistItem model, required BuildContext context}) {
bool status = (model.status == null || model.status == null) ? true : (model.status != null ? (model.status == 'true' ? true : false) : false);
bool status = (model.status == null) ? false : (model.status != null ? (model.status == 'true' ? true : false) : false);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
// ' (${index+1}) ${model.title}',
model.title ?? '',
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? Colors.white : AppColor.white936),
softWrap: true,
// maxLines: 1,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? Colors.white : AppColor.white936, height: 1.5),
),
14.height,
7.height,
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
@ -119,6 +120,7 @@ class _InspectionCheckListViewState extends State<InspectionCheckListView> {
status = !status;
model.status = status.toString();
});
updateStatus(index, status.toString());
},
child: Container(
width: 99.toScreenWidth,
@ -158,7 +160,7 @@ class _InspectionCheckListViewState extends State<InspectionCheckListView> {
),
),
],
).paddingOnly(top: 4, bottom: 4);
).paddingOnly(top: 14);
}
Widget buildToggleOption({

@ -66,6 +66,11 @@ class TechnicalInspectionAssetCard extends StatelessWidget {
),
2.height,
],
if (!ischild)
Text(
'Line No: ${assetModel.lineNo ?? '-'}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Asset Name: ${assetModel.modelDefinition?.assetName ?? '-'}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),

@ -130,7 +130,7 @@ class _TechnicalInspectionLinesListViewState extends State<TechnicalInspectionLi
},
);
},
).toShadowContainer(context, borderRadius: 20, padding: 12),
)
],
),
).expanded,

@ -112,15 +112,13 @@ class _UpdateChildAssetViewState extends State<UpdateChildAssetView> {
inspectionDetailsForm(
lineId: widget.lineId,
provider: provider,
),
8.height,
const Divider().defaultStyle(context),
8.height,
).toShadowContainer(context, borderRadius: 20, padding: 12),
20.height,
testLines(
context: context,
)
],
).toShadowContainer(context, borderRadius: 20, padding: 12))
))
.expanded,
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
],
@ -165,26 +163,7 @@ class _UpdateChildAssetViewState extends State<UpdateChildAssetView> {
showShadow: false,
enable: false,
style: Theme.of(context).textTheme.titleMedium,
).onPress(() async {
var data = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TechnicalInspectionSearchAssetView(
lineId: lineId,
)));
if (data != null) {
TechnicalInspectionAssetModel? assetModel = await provider.getAssetDetails(assetId: data?.id);
if (assetModel != null) {
provider.setChildModel(assetModel);
if (assetModel.site != null) {
await provider.getSiteData(siteId: assetModel.site?.id, model: provider.childFormModel);
}
provider.setParentModel(assetModel);
populateTextFields(model: provider.childFormModel);
}
}
}),
),
8.height,
AppTextFormField(
labelText: 'Asset Name'.addTranslation,
@ -415,7 +394,7 @@ class _UpdateChildAssetViewState extends State<UpdateChildAssetView> {
orElse: () => InspectionChecklistItem(status: 'FAIL'),
)
.status ==
'PASS';
'true';
}
buildInspectionPayload(List<InspectionChecklistItem> checklist) {

@ -114,34 +114,31 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
: Column(
children: [
SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
inspectionDetailsForm(lineId: widget.lineId, provider: provider).toShadowContainer(context, borderRadius: 20, padding: 12),
20.height,
Row(
children: [
inspectionDetailsForm(lineId: widget.lineId, provider: provider),
8.height,
const Divider().defaultStyle(context),
8.height,
Row(
children: [
Text(
"Test List",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.width,
'web_link_icon'.toSvgAsset().onPress(() {
openInspectionChecklist(context);
}),
],
Text(
"Test List",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
childList(
context: context,
provider: provider,
)
8.width,
'web_link_icon'.toSvgAsset().onPress(() {
openInspectionChecklist(context);
}),
],
).toShadowContainer(context, borderRadius: 20, padding: 12))
.expanded,
),
16.height,
childList(
context: context,
provider: provider,
)
],
)).expanded,
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
],
);
@ -468,7 +465,7 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
orElse: () => InspectionChecklistItem(status: 'FAIL'),
)
.status ==
'PASS';
'true';
}
buildInspectionPayload(List<InspectionChecklistItem> checklist) {

@ -89,24 +89,27 @@ class _UpdateTechnicalInspectionLinesViewState extends State<UpdateTechnicalInsp
: Column(
children: [
SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
itemDetails(context: context, itemNo: widget.deliveryLineModel?.itemNumber, itemDescription: widget.deliveryLineModel?.itemDescription),
12.height,
inspectionDetailsForm(),
8.height,
const Divider().defaultStyle(context),
Text(
"Cost Centers",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
costCenterList(context),
],
).toShadowContainer(context, borderRadius: 20, padding: 12))
.expanded,
).toShadowContainer(context, borderRadius: 20, padding: 12),
20.height,
Text(
"Cost Centers",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
16.height,
costCenterList(context),
],
)).expanded,
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
],
),

@ -337,6 +337,52 @@ class AssetDeliveryProvider extends ChangeNotifier {
}
}
Future<bool> saveMasterInfoDeliveryInspection({
Map<String, dynamic>? requestPayload,
}) async {
isLoading = true;
try {
final response = await ApiManager.instance.post(URLs.saveMasterInfoDeliveryInspection, body: requestPayload??{});
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
isLoading = false;
notifyListeners();
return true;
} else {
isLoading = false;
notifyListeners();
return false;
}
} catch (error) {
isLoading = false;
notifyListeners();
return false;
}
}
Future<bool> sendEmailToAddSignature({
Map<String, dynamic>? requestPayload,
}) async {
isLoading = true;
try {
final response = await ApiManager.instance.post(URLs.sendEmailToAddSignature, body: requestPayload??{});
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
isLoading = false;
notifyListeners();
return true;
} else {
isLoading = false;
notifyListeners();
return false;
}
} catch (error) {
isLoading = false;
notifyListeners();
return false;
}
}
Future<DeliveryInspectionFormModel> getAssetDeliveryInspectionData({int? itemId}) async {
isLoading = true;
DeliveryInspectionFormModel deliveryInspectionFormModel = DeliveryInspectionFormModel();

@ -18,6 +18,7 @@ class AppFilledButton extends StatelessWidget {
final bool showBorder;
final double radius;
final int height;
final double? width;
final bool disableButton;
const AppFilledButton(
@ -29,6 +30,7 @@ class AppFilledButton extends StatelessWidget {
this.fontSize,
this.loading = false,
this.height = 56,
this.width,
this.showBorder = false,
this.disableButton = false,
this.buttonColor,
@ -41,7 +43,7 @@ class AppFilledButton extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
height: height.toScreenHeight,
width: maxWidth ? double.infinity : null,
width: maxWidth ? double.infinity : width,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),

@ -4,6 +4,7 @@ import 'package:signature/signature.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
@ -16,10 +17,12 @@ class ESignature extends StatefulWidget {
final Function(Uint8List?)? onSaved;
final Color? backgroundColor;
final Function(Uint8List)? onChange;
final bool editable;
final bool showShadow;
final String title;
const ESignature({Key? key, required this.title, required this.oldSignature, this.backgroundColor, this.onSaved, this.onChange, this.showShadow = true, required this.newSignature})
const ESignature(
{Key? key, required this.title, required this.oldSignature, this.backgroundColor, this.onSaved, this.onChange, this.editable = true, this.showShadow = true, required this.newSignature})
: super(key: key);
@override
@ -39,7 +42,6 @@ class _ESignatureState extends State<ESignature> {
if (widget.newSignature != null) {
signature = widget.newSignature;
}
super.initState();
}
@ -69,54 +71,70 @@ class _ESignatureState extends State<ESignature> {
borderRadius: _editable ? const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)) : BorderRadius.circular(10),
boxShadow: widget.showShadow ? [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)] : null,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
widget.title.tinyFont(context).paddingOnly(top: 8),
(!_editable
? "edit".toSvgAsset(width: 48).paddingOnly(top: 8)
: Container(
width: 48.toScreenWidth,
height: 48.toScreenWidth,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(color: AppColor.neutral30)),
padding: const EdgeInsets.all(11),
margin: const EdgeInsets.only(top: 8),
child: "done".toSvgAsset(width: 26),
))
.onPress(() async {
if (_editable) {
signature = await _controller!.toPngBytes();
if (widget.onChange != null && signature != null) {
widget.onChange!(signature!);
}
}
_editable = !_editable;
setState(() {});
}),
],
),
((widget.oldSignature != null || signature != null) && !_editable)
? Container(
child: widget.editable == false
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Signature'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
Container(
height: 135.toScreenHeight,
width: MediaQuery.of(context).size.width,
padding: const EdgeInsets.only(bottom: 8),
child: signature != null ? Image.memory(signature!) : ImageLoader(showDefaultIcon: true, boxFit: BoxFit.contain, url: URLs.getFileUrl(widget.oldSignature) ?? ''),
)
: AbsorbPointer(
absorbing: !_editable,
child: Signature(
controller: _controller!,
height: 135.toScreenHeight,
width: MediaQuery.of(context).size.width - 64.toScreenWidth,
backgroundColor: Colors.transparent,
),
),
],
),
],
)
: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
widget.title.tinyFont(context).paddingOnly(top: 8),
(!_editable
? "edit".toSvgAsset(width: 48).paddingOnly(top: 8)
: Container(
width: 48.toScreenWidth,
height: 48.toScreenWidth,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(color: AppColor.neutral30)),
padding: const EdgeInsets.all(11),
margin: const EdgeInsets.only(top: 8),
child: "done".toSvgAsset(width: 26),
))
.onPress(() async {
if (_editable) {
signature = await _controller!.toPngBytes();
if (widget.onChange != null && signature != null) {
widget.onChange!(signature!);
}
}
_editable = !_editable;
setState(() {});
}),
],
),
((widget.oldSignature != null || signature != null) && !_editable)
? Container(
height: 135.toScreenHeight,
width: MediaQuery.of(context).size.width,
padding: const EdgeInsets.only(bottom: 8),
child: signature != null ? Image.memory(signature!) : ImageLoader(showDefaultIcon: true, boxFit: BoxFit.contain, url: URLs.getFileUrl(widget.oldSignature) ?? ''),
)
: AbsorbPointer(
absorbing: !_editable,
child: Signature(
controller: _controller!,
height: 135.toScreenHeight,
width: MediaQuery.of(context).size.width - 64.toScreenWidth,
backgroundColor: Colors.transparent,
),
),
],
),
),
if (_editable)
Container(

Loading…
Cancel
Save