|
|
|
@ -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/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/default_app_bar.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.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 {
|
|
|
|
class CostCenterFormView extends StatefulWidget {
|
|
|
|
final List<CostCenterModel>? costCenterList;
|
|
|
|
final List<CostCenterModel>? costCenterList;
|
|
|
|
@ -115,10 +116,17 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
return provider.isLoading
|
|
|
|
return provider.isLoading
|
|
|
|
? CircularProgressIndicator(color: AppColor.loadingColor(context)).center
|
|
|
|
? CircularProgressIndicator(color: AppColor.loadingColor(context)).center
|
|
|
|
: Column(
|
|
|
|
: Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
ListView(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
itemDetails(),
|
|
|
|
itemDetails(),
|
|
|
|
|
|
|
|
12.height,
|
|
|
|
selectionButton(),
|
|
|
|
selectionButton(),
|
|
|
|
|
|
|
|
12.height,
|
|
|
|
_selectedType == CostCenterType.costCenter ? _buildCostCenterList() : _buildSerialNumberList(),
|
|
|
|
_selectedType == CostCenterType.costCenter ? _buildCostCenterList() : _buildSerialNumberList(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).expanded,
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
child: AppFilledButton(
|
|
|
|
child: AppFilledButton(
|
|
|
|
@ -147,10 +155,12 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildCostCenterList() {
|
|
|
|
Widget _buildCostCenterList() {
|
|
|
|
return ListView.builder(
|
|
|
|
return ListView.separated(
|
|
|
|
itemCount: formModel.costCenters!.length + 1,
|
|
|
|
itemCount: formModel.costCenters!.length + 1,
|
|
|
|
shrinkWrap: true,
|
|
|
|
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) {
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
if (index == formModel.costCenters!.length) {
|
|
|
|
if (index == formModel.costCenters!.length) {
|
|
|
|
return AppFilledButton(
|
|
|
|
return AppFilledButton(
|
|
|
|
@ -184,10 +194,12 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildSerialNumberList() {
|
|
|
|
Widget _buildSerialNumberList() {
|
|
|
|
return ListView.builder(
|
|
|
|
return ListView.separated(
|
|
|
|
itemCount: formModel.serialNos!.length + 1,
|
|
|
|
itemCount: formModel.serialNos!.length + 1,
|
|
|
|
shrinkWrap: true,
|
|
|
|
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) {
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
if (index == formModel.serialNos!.length) {
|
|
|
|
if (index == formModel.serialNos!.length) {
|
|
|
|
return AppFilledButton(
|
|
|
|
return AppFilledButton(
|
|
|
|
@ -217,9 +229,7 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget selectionButton() {
|
|
|
|
Widget selectionButton() {
|
|
|
|
return Padding(
|
|
|
|
return Row(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
Expanded(
|
|
|
|
child: _radioItem(
|
|
|
|
child: _radioItem(
|
|
|
|
@ -246,7 +256,6 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -263,6 +272,13 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Radio<CostCenterType>(
|
|
|
|
Radio<CostCenterType>(
|
|
|
|
value: value,
|
|
|
|
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,
|
|
|
|
groupValue: groupValue,
|
|
|
|
onChanged: (_) => onTap(),
|
|
|
|
onChanged: (_) => onTap(),
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
@ -279,34 +295,12 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
|
|
spacing: 4,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
InfoTextWidget(label: "Item No", value: "\n${widget.itemNo ?? '-'}"),
|
|
|
|
'Item No'.addTranslation,
|
|
|
|
InfoTextWidget(label: "Item Description", value: "\n${widget.itemDescription ?? '-'}"),
|
|
|
|
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),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
).toShadowContainer(
|
|
|
|
).toShadowContainer(context);
|
|
|
|
context,
|
|
|
|
|
|
|
|
borderRadius: 20,
|
|
|
|
|
|
|
|
padding: 12,
|
|
|
|
|
|
|
|
showShadow: false,
|
|
|
|
|
|
|
|
margin: const EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -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,
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)
|
|
|
|
).toShadowContainer(context);
|
|
|
|
.toShadowContainer(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
paddingObject: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.paddingOnly(bottom: 12);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|