UI improvements

design_3.0_asset_delivery_module
WaseemAbbasi22 2 days ago
parent 73ee12cba4
commit a0a084803d

@ -121,6 +121,24 @@ extension StringExtensionsRecurrentTaskInpesctionDataType on String {
}
}
}
extension IntExtensionsAssetDeliveryStage on int {
AssetDeliveryStageEnum toAssetDeliveryStageEnum() {
switch (this) {
case 2:
return AssetDeliveryStageEnum.deliveryInspection;
case 3:
return AssetDeliveryStageEnum.technicalInspection;
case 4:
return AssetDeliveryStageEnum.endUserAcceptance;
default:
return AssetDeliveryStageEnum.other;
}
}
}
enum DropDownMatchType {
identifier,
name,
@ -131,3 +149,9 @@ enum CostCenterType {
costCenter,
serialNumber,
}
enum AssetDeliveryStageEnum {
deliveryInspection,
technicalInspection,
endUserAcceptance,
other,
}

@ -7,9 +7,10 @@ class Lookup extends Base {
int? id; // Now nullable
int? value; // Now nullable
WorkOrderNextStepEnum? workOrderNextStepEnum; // Now nullable
AssetDeliveryStageEnum? assetDeliveryStageEnum; // Now nullable
String? name; // Now nullable
Lookup({this.id, this.value, this.name, this.workOrderNextStepEnum}) : super(identifier: id?.toString(), name: name);
Lookup({this.id, this.value, this.name, this.workOrderNextStepEnum, this.assetDeliveryStageEnum}) : super(identifier: id?.toString(), name: name);
@override
bool operator ==(Object other) => identical(this, other) || other is Lookup && ((value != null && value == other.value) || (id != null && id == other.id));
@ -38,10 +39,11 @@ class Lookup extends Base {
// }
factory Lookup.fromJson(Map<String, dynamic>? parsedJson) {
if(parsedJson==null) return Lookup();
if (parsedJson == null) return Lookup();
return Lookup(
name: parsedJson["name"],
workOrderNextStepEnum: parsedJson["value"] == null ? null : (parsedJson["value"] as int).toWorkOrderNextStepEnum(),
assetDeliveryStageEnum: parsedJson["value"] == null ? null : (parsedJson["value"] as int).toAssetDeliveryStageEnum(),
id: parsedJson["id"],
value: parsedJson["value"],
);

@ -10,7 +10,7 @@ import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
class HelperFunction {
static void attachmentTap({required BuildContext context, required AssetDeliveryProvider assetDeliveryProvider, required dynamic deliveryTableItemId}) async {
static void attachmentTap({required BuildContext context, bool viewOnly = false, required AssetDeliveryProvider assetDeliveryProvider, required dynamic deliveryTableItemId}) async {
Lookup? result;
result = await showAttachmentTypeBottomSheet(context);
List<GenericAttachmentModel> list = [];
@ -30,6 +30,7 @@ class HelperFunction {
builder: (context) => AssetDeliveryAttachmentView(
tableItemId: deliveryTableItemId,
attachmentType: result!.value,
viewOnly: viewOnly,
attachmentList: list,
)));
// }

@ -305,6 +305,7 @@ class AssetDeliveryTableModel {
status = json['status'] != null
? Lookup.fromJson(json['status'])
: null;
}
Map<String, dynamic> toJson() {

@ -6,6 +6,7 @@ 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/asset_delivery_data_model.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_stage_tab_page.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_table_card_view.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/change_status_bottomsheet.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/delivery_inspection_form_view.dart';
@ -35,6 +36,7 @@ class AssetDeliveryPage extends StatefulWidget {
class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
AssetDeliveryDataModel? dataModel;
AssetDeliveryProvider? assetDeliveryProvider;
bool loading = false;
@override
void initState() {
@ -46,12 +48,18 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
}
Future<void> getDetailsById() async {
setState(() {
loading = true;
});
final futures = <Future>[
assetDeliveryProvider!.getAssetDeliveryDetailById(requestId: widget.requestId).then((value) => dataModel = value),
assetDeliveryProvider!.getAssetDeliveryTableListById(requestId: widget.requestId),
];
await Future.wait(futures);
setState(() {
loading = false;
});
}
@override
@ -68,7 +76,7 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
body: Consumer<AssetDeliveryProvider>(
builder: (context, provider, child) {
final dataModel = provider.assetDeliveryDataModel;
if (provider.isLoading) {
if (loading) {
return const CircularProgressIndicator(color: AppColor.primary10).center;
}
if (dataModel == null) {
@ -246,16 +254,17 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
),
8.height,
Text(
'EDD (Estimated Delivery Date)'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
Text(
dataModel?.edd != null ? dataModel!.edd!.toAssetDetailsFormat : '-',
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
),
8.height,
//Removed as request by Ahmed backend...
// Text(
// 'EDD (Estimated Delivery Date)'.addTranslation,
// style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
// ),
// 8.height,
// Text(
// dataModel?.edd != null ? dataModel!.edd!.toAssetDetailsFormat : '-',
// style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
// ),
// 8.height,
Text(
'Total'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
@ -321,10 +330,21 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
});
});
} else {
// Navigator.of(context).push(MaterialPageRoute(
// builder: (_) =>
// DeliveryInspectionFormView(
// deliveryTableModel: model,
// requestModel: dataModel,
// ),
// ));
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => DeliveryInspectionFormView(
deliveryTableModel: model,
requestModel: dataModel,
builder: (_) => AssetDeliveryStageTabPage(
title: 'Delivery Inspection'.addTranslation,
detailWidget: DeliveryInspectionFormView(
deliveryTableModel: model,
requestModel: dataModel,
),
tableId: model.id,
),
));
}

@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/enum_extensions.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/pages/history_log_view.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
class AssetDeliveryStageTabPage extends StatefulWidget {
String title;
Widget detailWidget;
int? tableId;
AssetDeliveryStageTabPage({
Key? key,
required this.title,
required this.detailWidget,
this.tableId,
}) : super(key: key);
@override
_AssetDeliveryStageTabPageState createState() {
return _AssetDeliveryStageTabPageState();
}
}
class _AssetDeliveryStageTabPageState extends State<AssetDeliveryStageTabPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: DefaultAppBar(
title: widget.title,
),
body: DefaultTabController(
length: 2,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth, top: 12.toScreenHeight),
decoration: BoxDecoration(color: context.isDark ? AppColor.neutral50 : AppColor.white10, borderRadius: BorderRadius.circular(10)),
child: TabBar(
padding: EdgeInsets.symmetric(vertical: 4.toScreenHeight, horizontal: 4.toScreenWidth),
labelColor: context.isDark ? AppColor.neutral30 : AppColor.black20,
unselectedLabelColor: context.isDark ? AppColor.neutral30 : AppColor.black20,
unselectedLabelStyle: AppTextStyles.bodyText,
labelStyle: AppTextStyles.bodyText,
indicatorPadding: EdgeInsets.zero,
indicatorSize: TabBarIndicatorSize.tab,
dividerColor: Colors.transparent,
indicator: BoxDecoration(color: context.isDark ? AppColor.neutral60 : AppColor.neutral110, borderRadius: BorderRadius.circular(7)),
tabs: [
Tab(text: context.translation.details, height: 57.toScreenHeight),
Tab(text: context.translation.historyLogs, height: 57.toScreenHeight),
],
),
),
// 12.height,
TabBarView(
children: [
widget.detailWidget,
AssetDeliveryHistoryLogView(
tableItemId: widget.tableId,
),
],
).expanded,
],
),
));
}
String getPageTitle({AssetDeliveryStageEnum? deliveryStage}) {
if (deliveryStage == AssetDeliveryStageEnum.deliveryInspection) {
return 'Delivery Inspection'.addTranslation;
}
if (deliveryStage == AssetDeliveryStageEnum.technicalInspection) {
return 'Technical Inspection'.addTranslation;
}
if (deliveryStage == AssetDeliveryStageEnum.endUserAcceptance) {
return 'End-User Acceptance'.addTranslation;
} else {
return 'Details'.addTranslation;
}
}
}

@ -26,28 +26,33 @@ class AssetDeliveryTableCard extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
StatusLabel(
label: deliveryTableModel.status?.name,
textColor: AppColor.neutral50,
backgroundColor: AppColor.orange30,
),
Row(
children: [
'history_icon'.toSvgAsset(height: 14, width: 14),
8.width,
Text(
'View History'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: AppColor.primary10),
),
],
).onPress(() {
onViewHistoryTap();
}),
],
StatusLabel(
label: deliveryTableModel.status?.name,
textColor: AppColor.neutral50,
backgroundColor: AppColor.orange30,
),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// StatusLabel(
// label: deliveryTableModel.status?.name,
// textColor: AppColor.neutral50,
// backgroundColor: AppColor.orange30,
// ),
// Row(
// children: [
// 'history_icon'.toSvgAsset(height: 14, width: 14),
// 8.width,
// Text(
// 'View History'.addTranslation,
// style: AppTextStyles.bodyText.copyWith(color: AppColor.primary10),
// ),
// ],
// ).onPress(() {
// onViewHistoryTap();
// }),
// ],
// ),
8.height,
Text(
'Delivery Number: ${deliveryTableModel.number ?? '-'}',

@ -24,11 +24,13 @@ import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
class AssetDeliveryAttachmentView extends StatefulWidget {
final int? tableItemId;
final int? attachmentType;
bool viewOnly = false;
final List<GenericAttachmentModel> attachmentList;
const AssetDeliveryAttachmentView({
AssetDeliveryAttachmentView({
super.key,
required this.attachmentList,
this.viewOnly=false,
this.attachmentType,
this.tableItemId,
});
@ -80,7 +82,7 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
fit: FlexFit.loose, // expands only as much as needed
child: Column(
children: [
widget.attachmentType == 5
widget.attachmentType == 5 && !widget.viewOnly
? AttachmentPicker(
label: context.translation.attachments,
attachment: _attachments,

@ -1,8 +1,10 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/enum_extensions.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';
@ -14,6 +16,7 @@ import 'package:test_sa/modules/asset_delivery_module/models/delivery_inspection
import 'package:test_sa/modules/asset_delivery_module/models/delivery_line_model.dart';
import 'package:test_sa/modules/asset_delivery_module/models/inspection_person_model.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_line_card_view.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_stage_tab_page.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/cost_center_form_view.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/inpection_bottomsheet.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart';
@ -88,12 +91,12 @@ 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);
},
),
// appBar: DefaultAppBar(
// title: 'Delivery Inspection'.addTranslation,
// onBackPress: () {
// Navigator.pop(context);
// },
// ),
body: isLoading
? const CircularProgressIndicator(color: AppColor.primary10).center
: Form(
@ -164,7 +167,20 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
),
],
)
: AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap),
: Row(
children: [
AppFilledButton(
buttonColor: AppColor.white60,
label: 'Attachments'.addTranslation,
maxWidth: true,
textColor: AppColor.black10,
onPressed: () {
HelperFunction.attachmentTap(context: context, viewOnly: true, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id);
}).expanded,
8.width,
AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap).expanded,
],
),
),
],
),
@ -618,21 +634,44 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
void _nextTap() {
if (widget.deliveryTableModel.isContainsTechnicalInspection == true) {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => TechnicalInspectionLinesListView(
// deliveryTableModel: widget.deliveryTableModel,
// requestModel: widget.requestModel,
// ))
// );
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TechnicalInspectionLinesListView(
deliveryTableModel: widget.deliveryTableModel,
requestModel: widget.requestModel,
builder: (context) => AssetDeliveryStageTabPage(
title: 'Technical Inspection'.addTranslation,
detailWidget: TechnicalInspectionLinesListView(
deliveryTableModel: widget.deliveryTableModel,
requestModel: widget.requestModel,
),
tableId: widget.deliveryTableModel.id,
)));
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EndUserCostCenterLIstView(
deliveryTableModel: widget.deliveryTableModel,
requestModel: widget.requestModel,
builder: (context) => AssetDeliveryStageTabPage(
title: 'End-User Acceptance'.addTranslation,
detailWidget: EndUserCostCenterLIstView(
deliveryTableModel: widget.deliveryTableModel,
requestModel: widget.requestModel,
),
tableId: widget.deliveryTableModel.id,
)));
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => EndUserCostCenterLIstView(
// deliveryTableModel: widget.deliveryTableModel,
// requestModel: widget.requestModel,
// )));
}
}

@ -72,10 +72,10 @@ class _EndUserCostCenterLIstViewState extends State<EndUserCostCenterLIstView> {
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: DefaultAppBar(
title: 'End-User Acceptance'.addTranslation,
titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
// appBar: DefaultAppBar(
// title: 'End-User Acceptance'.addTranslation,
// titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
// ),
body: Form(
key: _formKey,
child: isLoading
@ -108,7 +108,17 @@ class _EndUserCostCenterLIstViewState extends State<EndUserCostCenterLIstView> {
),
],
))
: const SizedBox(),
: FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
buttonColor: AppColor.white60,
label: 'Attachments'.addTranslation,
maxWidth: true,
textColor: AppColor.black10,
onPressed: () {
HelperFunction.attachmentTap(context: context, viewOnly: true, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id);
}),
),
],
),
),

@ -292,7 +292,6 @@ class _UpdateEndUserAssetDetailsViewState extends State<UpdateEndUserAssetDetail
model.rejectionReason = widget.assetDetailsModel?.rejectionReason;
model.receivedQty = widget.assetDetailsModel?.receivedQty;
}
log('details ${model.toJson()}');
quantityController.text = model.rejectedQty != null ? model.rejectedQty.toString() : '';
descriptionController.text = model.description ?? '';

@ -41,12 +41,12 @@ class _AssetDeliveryHistoryLogViewState extends State<AssetDeliveryHistoryLogVie
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: DefaultAppBar(
title: 'History Log'.addTranslation,
onBackPress: () {
Navigator.pop(context);
},
),
// appBar: DefaultAppBar(
// title: 'History Log'.addTranslation,
// onBackPress: () {
// Navigator.pop(context);
// },
// ),
body: Consumer<AssetDeliveryProvider>(builder: (context, provider, _) {
return provider.isLoading
? const CircularProgressIndicator(color: AppColor.primary10).center

@ -13,34 +13,27 @@ 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';
class InspectionChecklistBottomSheet extends StatefulWidget {
class InspectionCheckListView extends StatefulWidget {
final List<InspectionChecklistItem>? initialValues;
const InspectionChecklistBottomSheet({super.key, this.initialValues});
const InspectionCheckListView({super.key, this.initialValues});
@override
State<InspectionChecklistBottomSheet> createState() =>
_InspectionChecklistBottomSheetState();
State<InspectionCheckListView> createState() => _InspectionCheckListViewState();
}
class _InspectionChecklistBottomSheetState
extends State<InspectionChecklistBottomSheet> {
class _InspectionCheckListViewState extends State<InspectionCheckListView> {
late List<InspectionChecklistItem> checklist;
@override
void initState() {
super.initState();
checklist = AssetDeliveryUtils.inspectionChecklist.map((e) => InspectionChecklistItem(title: e.title)).toList();
/// Create local copy (no shared mutation)
checklist = AssetDeliveryUtils.inspectionChecklist
.map((e) => InspectionChecklistItem(title: e.title))
.toList();
/// Apply initial values only if provided
if (widget.initialValues != null && widget.initialValues!.isNotEmpty) {
for (final item in checklist) {
final matched = widget.initialValues!.firstWhere(
(e) => e.title == item.title,
(e) => e.title == item.title,
orElse: () => InspectionChecklistItem(),
);
item.status = matched.status; // null-safe
@ -54,70 +47,36 @@ class _InspectionChecklistBottomSheetState
});
}
List<InspectionChecklistItem> get selectedValues =>
checklist.where((e) => e.status != null).toList();
List<InspectionChecklistItem> get selectedValues => checklist.where((e) => e.status != null).toList();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.white10,
appBar: DefaultAppBar(
title: 'Asset Check List'.addTranslation,
showBackButton: false,
titleStyle: AppTextStyles.heading3.copyWith(
fontWeight: FontWeight.w500,
color: context.isDark
? AppColor.neutral30
: AppColor.neutral50,
),
),
body: Column(
children: [
12.height,
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: checklist.length,
padding: const EdgeInsets.symmetric(horizontal: 12),
itemBuilder: (context, index) {
final item = checklist[index];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title ?? '',
style: AppTextStyles.heading6.copyWith(
color: context.isDark
? AppColor.neutral30
: AppColor.black10,
),
),
Row(
children: [
Expanded(
child: RadioListTile<String>(
title: const Text('Pass'),
value: 'PASS',
groupValue: item.status,
onChanged: (v) =>
updateStatus(index, v!),
),
),
Expanded(
child: RadioListTile<String>(
title: const Text('Fail'),
value: 'FAIL',
groupValue: item.status,
onChanged: (v) =>
updateStatus(index, v!),
),
),
],
),
],
);
},
).expanded,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: List.generate(
checklist.length,
(index) {
final model = checklist[index];
return inspectionStatusRadioWidget(
model: model,
index: index,
context: context,
);
},
),
).toShadowContainer(
context,
borderRadius: 20,
margin: const EdgeInsets.only(top: 12, left: 12, right: 12),
),
const Spacer(),
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
@ -133,5 +92,124 @@ class _InspectionChecklistBottomSheetState
),
);
}
}
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);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
model.title ?? '',
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? Colors.white : AppColor.white936),
),
14.height,
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
//
// (status ? 'Pass' : 'Fail').bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500),
// ],
// ).expanded,
GestureDetector(
onTap: () {
setState(() {
status = !status;
model.status = status.toString();
});
},
child: Container(
width: 99.toScreenWidth,
height: 40.toScreenHeight,
padding: EdgeInsetsDirectional.all(4.toScreenHeight),
decoration: BoxDecoration(
color: AppColor.fieldBgColor(context),
borderRadius: BorderRadius.circular(5),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
buildToggleOption(
label: "PASS",
isActive: status,
activeColor: AppColor.green20,
inactiveColor: Colors.transparent,
textColor: status
? AppColor.green50
: context.isDark
? Colors.white
: AppColor.black20,
),
buildToggleOption(
label: "FAIL",
isActive: !status,
activeColor: AppColor.red20,
inactiveColor: Colors.transparent,
textColor: status
? context.isDark
? Colors.white
: AppColor.black20
: AppColor.red30,
),
],
),
),
),
],
).paddingOnly(top: 4, bottom: 4);
}
Widget buildToggleOption({
required String label,
required bool isActive,
required Color activeColor,
required Color inactiveColor,
required Color textColor,
}) {
return Container(
width: 44.toScreenWidth,
height: 30.toScreenHeight,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isActive ? activeColor : inactiveColor,
borderRadius: BorderRadius.circular(3),
),
child: label.bodyText2(context).custom(color: textColor),
);
}
//older widget ...
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// item.title ?? '',
// style: AppTextStyles.heading6.copyWith(
// color: context.isDark ? AppColor.neutral30 : AppColor.black10,
// ),
// ),
// Row(
// children: [
// Expanded(
// child: RadioListTile<String>(
// title: const Text('Pass'),
// value: 'PASS',
// groupValue: item.status,
// onChanged: (v) => updateStatus(index, v!),
// ),
// ),
// Expanded(
// child: RadioListTile<String>(
// title: const Text('Fail'),
// value: 'FAIL',
// groupValue: item.status,
// onChanged: (v) => updateStatus(index, v!),
// ),
// ),
// ],
// ),
// ],
// );
}

@ -12,6 +12,7 @@ import 'package:test_sa/modules/asset_delivery_module/helper_function.dart';
import 'package:test_sa/modules/asset_delivery_module/models/asset_delivery_data_model.dart';
import 'package:test_sa/modules/asset_delivery_module/models/delivery_line_model.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_line_card_view.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_stage_tab_page.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/attachment_view.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/update_technical_inspection_lines_view.dart';
@ -79,10 +80,10 @@ class _TechnicalInspectionLinesListViewState extends State<TechnicalInspectionLi
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: DefaultAppBar(
title: 'Technical Inspection'.addTranslation,
titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
// appBar: DefaultAppBar(
// title: 'Technical Inspection'.addTranslation,
// titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
// ),
body: Form(
key: _formKey,
child: (isLoading)
@ -157,7 +158,21 @@ class _TechnicalInspectionLinesListViewState extends State<TechnicalInspectionLi
),
],
)
: AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap),
: Row(
children: [
AppFilledButton(
buttonColor: AppColor.white60,
label: 'Attachments'.addTranslation,
maxWidth: true,
textColor: AppColor.black10,
onPressed: () {
HelperFunction.attachmentTap(
context: context, viewOnly: true, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id);
}).expanded,
8.width,
AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap).expanded,
],
),
),
],
),
@ -246,12 +261,24 @@ class _TechnicalInspectionLinesListViewState extends State<TechnicalInspectionLi
}
void _nextTap() async {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => EndUserCostCenterLIstView(
// requestModel: widget.requestModel,
// deliveryTableModel: widget.deliveryTableModel,
// )));
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EndUserCostCenterLIstView(
requestModel: widget.requestModel,
deliveryTableModel: widget.deliveryTableModel,
builder: (context) => AssetDeliveryStageTabPage(
title: 'End-User Acceptance'.addTranslation,
detailWidget: EndUserCostCenterLIstView(
deliveryTableModel: widget.deliveryTableModel,
requestModel: widget.requestModel,
),
tableId: widget.deliveryTableModel.id,
)));
}
}

@ -25,8 +25,6 @@ import '../../../../models/new_models/department.dart';
import '../../../../new_views/common_widgets/app_filled_button.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
//TODO need to refactor this screen when done ...
class UpdateChildAssetView extends StatefulWidget {
final TechnicalInspectionAssetModel assetModel;
final int? lineId;
@ -183,7 +181,6 @@ class _UpdateChildAssetViewState extends State<UpdateChildAssetView> {
await provider.getSiteData(siteId: assetModel.site?.id, model: provider.childFormModel);
}
provider.setParentModel(assetModel);
log('child list length ${assetModel.childAssetList?.length}');
populateTextFields(model: provider.childFormModel);
}
}
@ -383,8 +380,8 @@ class _UpdateChildAssetViewState extends State<UpdateChildAssetView> {
///Need to check which details show here...
void _saveTap() async {
if(!_formKey.currentState!.validate()) return;
if(assetDeliveryProvider.childFormModel.installationDate==null){
if (!_formKey.currentState!.validate()) return;
if (assetDeliveryProvider.childFormModel.installationDate == null) {
"Installation Date is Required".showToast;
return;
}
@ -401,7 +398,7 @@ class _UpdateChildAssetViewState extends State<UpdateChildAssetView> {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => InspectionChecklistBottomSheet(
builder: (context) => InspectionCheckListView(
initialValues: checkList,
)));
if (result != null) {

@ -28,8 +28,6 @@ import '../../../../models/new_models/department.dart';
import '../../../../new_views/common_widgets/app_filled_button.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
//TODO need to refactor this screen also add loaders when done ...
class UpdateParentAssetView extends StatefulWidget {
final TechnicalInspectionAssetModel assetModel;
final int? lineId;
@ -438,7 +436,6 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
assetDeliveryProvider.parentFormModel.tableItemId = widget.tableItemId;
assetDeliveryProvider.parentFormModel.costCenterId = widget.costCenterItemId;
log('model data ${assetDeliveryProvider.parentFormModel.toJson()}');
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
await assetDeliveryProvider.saveTechnicalInspectionAssetData(model: assetDeliveryProvider.parentFormModel).then((status) async {
Navigator.pop(context);
@ -453,7 +450,7 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => InspectionChecklistBottomSheet(
builder: (context) => InspectionCheckListView(
initialValues: checkList,
)));
@ -462,18 +459,6 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
setState(() {});
}
buildInspectionPayload(checkList);
if (checkList.isNotEmpty) {
final isPass = checkList.every((e) => e.status == 'PASS');
log('Final Status: ${isPass ? 'PASS' : 'FAIL'}');
}
// call this as bottomsheet.
// final result = await showModalBottomSheet<List<Map<String, dynamic>>>(
// context: context,
// isScrollControlled: true,
// backgroundColor: Colors.transparent,
// builder: (_) => const InspectionChecklistBottomSheet(),
// );
}
bool _isPass(List<InspectionChecklistItem> list, String title) {
@ -528,446 +513,9 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
break;
}
}
checkList.forEach((item) {
log('items ${item.toJson()}');
});
}
String _statusFromBool(bool? value) {
return value == true ? 'PASS' : 'FAIL';
}
}
// import 'dart:developer';
// import 'package:flutter/material.dart';
// import 'package:provider/provider.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/models/new_models/building.dart';
// import 'package:test_sa/models/new_models/floor.dart';
// import 'package:test_sa/models/new_models/site.dart';
// import 'package:test_sa/modules/asset_delivery_module/models/technical_inspection_asset_model.dart';
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/search_asset_view.dart';
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/status_checklist_view.dart';
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart';
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/update_child_asset_view.dart';
// import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
// import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
// import 'package:test_sa/new_views/app_style/app_color.dart';
// import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
// import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
// import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
// import 'package:test_sa/providers/loading_list_notifier.dart';
// import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
// import '../../../../models/new_models/department.dart';
// import '../../../../new_views/common_widgets/app_filled_button.dart';
// import '../../../../new_views/common_widgets/default_app_bar.dart';
//
// //TODO need to refactor this screen when done ...
//
// class UpdateParentAssetView extends StatefulWidget {
// final TechnicalInspectionParentAssetModel assetModel;
// final int? lineId;
//
// UpdateParentAssetView({
// Key? key,
// required this.assetModel,
// this.lineId,
// }) : super(key: key);
//
// @override
// State<UpdateParentAssetView> createState() => _UpdateParentAssetViewState();
// }
//
// class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
// List<InspectionChecklistItem> checkList = [];
// late SiteProvider siteProvider;
// late AssetDeliveryProvider assetDeliveryProvider;
//
// @override
// void initState() {
// siteProvider = Provider.of<SiteProvider>(context, listen: false);
// assetDeliveryProvider = Provider.of<AssetDeliveryProvider>(context, listen: false);
// // WidgetsBinding.instance.addPostFrameCallback((_) {
// populateForm();
// // });
// super.initState();
// }
//
// void populateForm() async {
// // _model = widget.assetModel;
// assetDeliveryProvider.setModel(widget.assetModel);
// applyInspectionFlagsToChecklist(model: widget.assetModel,checklist: checkList);
// if (widget.assetModel.site != null) {
// await assetDeliveryProvider.getSiteData(siteId: widget.assetModel.site?.id, model: _model);
// }
// setState(() {});
// }
//
// @override
// void dispose() {
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// key: _scaffoldKey,
// appBar: DefaultAppBar(
// title: 'Parent Details'.addTranslation,
// titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
// ),
// body: Form(
// key: _formKey,
// child: Column(
// children: [
// SingleChildScrollView(
// padding: const EdgeInsets.all(16),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// inspectionDetailsForm(lineId: widget.lineId),
// 8.height,
// const Divider().defaultStyle(context),
// 8.height,
// childList(context),
// ],
// ).toShadowContainer(context, borderRadius: 20, padding: 12))
// .expanded,
// FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
// ],
// ),
// ),
// );
// }
//
// Widget childList(BuildContext context) {
// final assetDeliveryTableList = ['abc', 'def', 'ghi', 'fhg', 'hjhh'];
// return Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// 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);
// }),
// ],
// ),
// 8.height,
// ListView.separated(
// itemCount: assetDeliveryTableList.length,
// separatorBuilder: (_, __) => 8.height,
// padding: EdgeInsets.zero,
// shrinkWrap: true,
// physics: const NeverScrollableScrollPhysics(),
// itemBuilder: (listContext, itemIndex) {
// return TechnicalInspectionAssetCard(
// assetModel: TechnicalInspectionParentAssetModel(),
// ischild: true,
// editPress: () {
// Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateChildAssetView()));
// },
// isViewOnly: false,
// );
// },
// ),
// ],
// );
// }
//
// Widget inspectionDetailsForm({int? lineId}) {
// return Column(
// children: [
// //Replace with simple container...
// AppTextFormField(
// labelText: 'Asset Number'.addTranslation,
// backgroundColor: AppColor.fieldBgColor(context),
// initialValue: _model.assetNumber,
// textAlign: TextAlign.center,
// labelStyle: AppTextStyles.textFieldLabelStyle,
// textInputType: TextInputType.number,
// 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) {
// TechnicalInspectionParentAssetModel? assetModel = await assetDeliveryProvider.getAssetDetails(assetId: data?.id);
//
// if (assetModel != null) {
// _model =TechnicalInspectionParentAssetModel();
// setState(() {
//
// });
// setState(() {
// _model = assetModel;
// });
// if (assetModel.site != null) {
// await assetDeliveryProvider.getSiteData(siteId: assetModel.site?.id, model: _model);
// }
// setState(() {});
// }
// }
// }),
// 8.height,
// AppTextFormField(
// labelText: 'Serial Number'.addTranslation,
// backgroundColor: AppColor.fieldBgColor(context),
// initialValue: _model.serialNo ?? '',
// textAlign: TextAlign.center,
// labelStyle: AppTextStyles.textFieldLabelStyle,
// textInputType: TextInputType.number,
// showShadow: false,
// onSaved: (value) {
// _model.serialNo = value;
// },
// style: Theme.of(context).textTheme.titleMedium,
// ),
// 8.height,
// AppTextFormField(
// labelText: 'System ID'.addTranslation,
// backgroundColor: AppColor.fieldBgColor(context),
// initialValue: _model.systemId ?? '',
// textAlign: TextAlign.center,
// labelStyle: AppTextStyles.textFieldLabelStyle,
// showShadow: false,
// onSaved: (value) {
// _model.systemId = value;
// },
// style: Theme.of(context).textTheme.titleMedium,
// ),
// 8.height,
// SingleItemDropDownMenu<Site, SiteProvider>(
// context: context,
// title: 'Site',
// initialValue: _model.site,
// loading: assetDeliveryProvider.isSiteLoading,
// showAsBottomSheet: true,
// backgroundColor: AppColor.fieldBgColor(context),
// showShadow: false,
// // enabled: false,
// onSelect: (value) {
// if (value == null) {
// return;
// }
// _model.site = value;
// _model.building = null;
// _model.floor = null;
// _model.department = null;
// setState(() {});
// },
// ),
// 8.height,
// SingleItemDropDownMenu<Building, NullableLoadingProvider>(
// context: context,
// title: 'Building',
// backgroundColor: AppColor.fieldBgColor(context),
// showAsBottomSheet: true,
// loading: assetDeliveryProvider.isSiteLoading,
// showShadow: false,
// initialValue: _model.building,
// enabled: _model.site?.buildings?.isNotEmpty ?? false,
// staticData: _model.site?.buildings ?? [],
// onSelect: (value) {
// if (value == null) {
// return;
// }
// _model.building = value;
// _model.floor = null;
// _model.department = null;
// setState(() {});
// },
// ),
// 8.height,
// SingleItemDropDownMenu<Floor, NullableLoadingProvider>(
// context: context,
// showAsBottomSheet: true,
// backgroundColor: AppColor.fieldBgColor(context),
// loading: assetDeliveryProvider.isSiteLoading,
// showShadow: false,
// title: 'Floor',
// initialValue: _model.floor,
// enabled: _model.building?.floors?.isNotEmpty ?? false,
// staticData: _model.building?.floors ?? [],
// onSelect: (value) {
// if (value == null) {
// return;
// }
// _model.floor = value;
// _model.department = null;
// setState(() {});
// },
// ),
// 8.height,
// SingleItemDropDownMenu<Department, NullableLoadingProvider>(
// context: context,
// title: 'Department',
// backgroundColor: AppColor.fieldBgColor(context),
// loading: assetDeliveryProvider.isSiteLoading,
// showAsBottomSheet: true,
// showShadow: false,
// initialValue: _model.department,
// enabled: _model.floor?.departments?.isNotEmpty ?? false,
// staticData: _model.floor?.departments ?? [],
// onSelect: (value) {
// if (value == null) {
// return;
// }
// _model.department = value;
// _model.room = null;
// setState(() {});
// },
// ),
//
// 8.height,
// ADatePicker(
// label: 'Installation Date'.addTranslation,
// hideShadow: true,
// height: 56.toScreenHeight,
// backgroundColor: AppColor.fieldBgColor(context),
// date: _model.installationDate,
// // from: widget.pickerFromDate,
// formatDateWithTime: true,
// onDatePicker: (selectedDate) {
// showTimePicker(
// context: context,
// initialTime: TimeOfDay.now(),
// builder: (BuildContext context, Widget? child) {
// final ThemeData currentTheme = Theme.of(context);
// return Theme(
// data: currentTheme.copyWith(
// timePickerTheme: TimePickerThemeData(
// dialHandColor: AppColor.primary10,
// dialBackgroundColor: Colors.grey.withOpacity(0.1),
// hourMinuteColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.grey.withOpacity(0.1)),
// dayPeriodColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.transparent),
// dayPeriodTextColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? Colors.white : AppColor.primary10),
// dayPeriodBorderSide: BorderSide(color: Colors.grey.withOpacity(0.2)),
// entryModeIconColor: AppColor.primary10,
// ),
// textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(foregroundColor: AppColor.primary10)),
// ),
// child: child!,
// );
// },
// ).then((selectedTime) {
// if (selectedTime != null) {
// _model.installationDate = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
// setState(() {});
// }
// });
// },
// ),
// 8.height,
// ],
// );
// }
//
// ///Need to check which details show here...
//
// void _saveTap() async {
// _formKey.currentState!.save();
// }
//
// Future<void> openInspectionChecklist(BuildContext context) async {
// final result = await Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => InspectionChecklistBottomSheet(
// initialValues: checkList,
// )));
//
// log('result i got is $result');
// if(result!=null){
// checkList = result;
// setState(() {});
// }
// if (checkList.isNotEmpty) {
// final isPass = checkList.every((e) => e.status == 'PASS');
// log('Final Status: ${isPass ? 'PASS' : 'FAIL'}');
// }
// final payload = buildInspectionPayload(checkList);
//
// log('API Payload: $payload');
// // call this as bottomsheet.
// // final result = await showModalBottomSheet<List<Map<String, dynamic>>>(
// // context: context,
// // isScrollControlled: true,
// // backgroundColor: Colors.transparent,
// // builder: (_) => const InspectionChecklistBottomSheet(),
// // );
// }
//
// bool _isPass(List<InspectionChecklistItem> list, String title) {
// return list
// .firstWhere(
// (e) => e.title == title,
// orElse: () => InspectionChecklistItem(status: 'FAIL'),
// )
// .status ==
// 'PASS';
// }
//
// Map<String, bool> buildInspectionPayload(List<InspectionChecklistItem> checklist) {
// return {
// 'flagphysicalInspection': _isPass(checklist, 'Physical Inspection As Per Manufacturer Instructions'),
// 'flagFunctionPerformance': _isPass(checklist, 'Functional Performance As Per Results Of Manufacturer Recommended Check List'),
// 'flagGroundingResistance': _isPass(checklist, 'Grounding Resistance: Ω'),
// 'flagChassiss': _isPass(checklist, 'Chassis Leakage Current: µA'),
// 'flagLeadsLeakage': _isPass(checklist, 'Leads Leakage Current: µA'),
// 'flagAlert': _isPass(checklist, 'This Device Is Not Subject To Any Alert Or Recall Until The Date Of Preparation Of This Inspection Form'),
// };
// }
//
// void applyInspectionFlagsToChecklist({
// required List<InspectionChecklistItem> checklist,
// required TechnicalInspectionParentAssetModel model,
// }) {
// for (final item in checklist) {
// switch (item.title) {
// case 'Physical Inspection As Per Manufacturer Instructions':
// item.status = _statusFromBool(model.flagphysicalInspection);
// break;
//
// case 'Functional Performance As Per Results Of Manufacturer Recommended Check List':
// item.status = _statusFromBool(model.flagFunctionPerformance);
// break;
//
// case 'Grounding Resistance: Ω':
// item.status = _statusFromBool(model.flagGroundingResistance);
// break;
//
// case 'Chassis Leakage Current: µA':
// item.status = _statusFromBool(model.flagChassiss);
// break;
//
// case 'Leads Leakage Current: µA':
// item.status = _statusFromBool(model.flagLeadsLeakage);
// break;
//
// case 'This Device Is Not Subject To Any Alert Or Recall Until The Date Of Preparation Of This Inspection Form':
// item.status = _statusFromBool(model.flagAlert);
// break;
// }
// }
// }
// String _statusFromBool(bool? value) {
// return value == true ? 'PASS' : 'FAIL';
// }
// }

Loading…
Cancel
Save