|
|
|
|
@ -18,6 +18,7 @@ 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/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
|
|
|
|
|
|
|
|
|
|
class CostCenterFormView extends StatefulWidget {
|
|
|
|
|
final List<CostCenterModel>? costCenterList;
|
|
|
|
|
@ -113,44 +114,53 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
|
),
|
|
|
|
|
body: Consumer<AssetDeliveryProvider>(builder: (context, provider, child) {
|
|
|
|
|
return provider.isLoading
|
|
|
|
|
? CircularProgressIndicator(color: AppColor.loadingColor(context)).center
|
|
|
|
|
? CircularProgressIndicator(color: AppColor.loadingColor(context)).center
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
itemDetails(),
|
|
|
|
|
selectionButton(),
|
|
|
|
|
_selectedType == CostCenterType.costCenter ? _buildCostCenterList() : _buildSerialNumberList(),
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
context: context,
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
label: 'Save'.addTranslation,
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
await assetDeliveryProvider
|
|
|
|
|
.saveCostCenterToLineDeliveryInspection(tableItemId: widget.tableItemId, lineId: widget.lineId, list: formModel.costCenters, serialNoList: formModel.serialNos)
|
|
|
|
|
.then((status) async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (status) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
assetDeliveryProvider.getDeliveryLinesListById(
|
|
|
|
|
itemId: widget.tableItemId,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
children: [
|
|
|
|
|
ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
children: [
|
|
|
|
|
itemDetails(),
|
|
|
|
|
12.height,
|
|
|
|
|
selectionButton(),
|
|
|
|
|
12.height,
|
|
|
|
|
_selectedType == CostCenterType.costCenter ? _buildCostCenterList() : _buildSerialNumberList(),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
context: context,
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
label: 'Save'.addTranslation,
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
await assetDeliveryProvider
|
|
|
|
|
.saveCostCenterToLineDeliveryInspection(tableItemId: widget.tableItemId, lineId: widget.lineId, list: formModel.costCenters, serialNoList: formModel.serialNos)
|
|
|
|
|
.then((status) async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (status) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
assetDeliveryProvider.getDeliveryLinesListById(
|
|
|
|
|
itemId: widget.tableItemId,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildCostCenterList() {
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
return ListView.separated(
|
|
|
|
|
itemCount: formModel.costCenters!.length + 1,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
separatorBuilder: (context, index) => 12.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
if (index == formModel.costCenters!.length) {
|
|
|
|
|
return AppFilledButton(
|
|
|
|
|
@ -184,10 +194,12 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildSerialNumberList() {
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
return ListView.separated(
|
|
|
|
|
itemCount: formModel.serialNos!.length + 1,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
separatorBuilder: (context, index) => 12.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
if (index == formModel.serialNos!.length) {
|
|
|
|
|
return AppFilledButton(
|
|
|
|
|
@ -217,36 +229,33 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget selectionButton() {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _radioItem(
|
|
|
|
|
value: CostCenterType.costCenter,
|
|
|
|
|
groupValue: _selectedType,
|
|
|
|
|
title: 'Cost Center',
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedType = CostCenterType.costCenter;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _radioItem(
|
|
|
|
|
value: CostCenterType.costCenter,
|
|
|
|
|
groupValue: _selectedType,
|
|
|
|
|
title: 'Cost Center',
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedType = CostCenterType.costCenter;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _radioItem(
|
|
|
|
|
value: CostCenterType.serialNumber,
|
|
|
|
|
groupValue: _selectedType,
|
|
|
|
|
title: 'Serial Number',
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedType = CostCenterType.serialNumber;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _radioItem(
|
|
|
|
|
value: CostCenterType.serialNumber,
|
|
|
|
|
groupValue: _selectedType,
|
|
|
|
|
title: 'Serial Number',
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedType = CostCenterType.serialNumber;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -263,6 +272,13 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
|
children: [
|
|
|
|
|
Radio<CostCenterType>(
|
|
|
|
|
value: value,
|
|
|
|
|
activeColor: AppColor.primary10,
|
|
|
|
|
fillColor: WidgetStateColor.resolveWith((states) {
|
|
|
|
|
if (states.contains(WidgetState.selected)) {
|
|
|
|
|
return AppColor.primary10; // Thumb color when selected
|
|
|
|
|
}
|
|
|
|
|
return AppColor.icon2Color(context); // Thumb color when unselected (grey)
|
|
|
|
|
}),
|
|
|
|
|
groupValue: groupValue,
|
|
|
|
|
onChanged: (_) => onTap(),
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
@ -279,34 +295,12 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
spacing: 4,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'Item No'.addTranslation,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
widget.itemNo ?? '-',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
'Item Description'.addTranslation,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
widget.itemDescription ?? '-',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
InfoTextWidget(label: "Item No", value: "\n${widget.itemNo ?? '-'}"),
|
|
|
|
|
InfoTextWidget(label: "Item Description", value: "\n${widget.itemDescription ?? '-'}"),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(
|
|
|
|
|
context,
|
|
|
|
|
borderRadius: 20,
|
|
|
|
|
padding: 12,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
margin: const EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
|
|
|
|
);
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -354,34 +348,34 @@ class CostCenterItemCard extends StatelessWidget {
|
|
|
|
|
children: [
|
|
|
|
|
isHmg == true
|
|
|
|
|
? SingleItemDropDownMenu<Lookup, CostCenterProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: 'Cost Center'.addTranslation,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
requestById: requestId,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
matchBy: DropDownMatchType.name,
|
|
|
|
|
initialValue: model.costCenter,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
if (status != null) {
|
|
|
|
|
model.costCenter = status;
|
|
|
|
|
model.costCenterName = status.name;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
context: context,
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: 'Cost Center'.addTranslation,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
requestById: requestId,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
matchBy: DropDownMatchType.name,
|
|
|
|
|
initialValue: model.costCenter,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
if (status != null) {
|
|
|
|
|
model.costCenter = status;
|
|
|
|
|
model.costCenterName = status.name;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: AppTextFormField(
|
|
|
|
|
labelText: 'Cost Center'.addTranslation,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: model.costCenterName ?? '',
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
model.costCenterName = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
labelText: 'Cost Center'.addTranslation,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: model.costCenterName ?? '',
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
model.costCenterName = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: 'Quantity'.addTranslation,
|
|
|
|
|
@ -402,7 +396,7 @@ class CostCenterItemCard extends StatelessWidget {
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 12, vertical: 12)).paddingOnly(bottom: 12);
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -447,11 +441,6 @@ class SerialNumberItemCard extends StatelessWidget {
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
.toShadowContainer(
|
|
|
|
|
context,
|
|
|
|
|
paddingObject: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
|
|
|
|
)
|
|
|
|
|
.paddingOnly(bottom: 12);
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|