|
|
|
|
@ -2,13 +2,15 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/pantry/calibration_tools.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/pentry/auto_complete_fields/auto_complete_devices_field.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../new_views/app_style/app_color.dart';
|
|
|
|
|
|
|
|
|
|
class PentryCalibrationToolForm extends StatefulWidget {
|
|
|
|
|
final List<CalibrationTool> models;
|
|
|
|
|
@ -24,45 +26,44 @@ class _PentryCalibrationToolFormState extends State<PentryCalibrationToolForm> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
itemCount: widget.models.length + 1,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
if (index == widget.models.length) {
|
|
|
|
|
return AButton(
|
|
|
|
|
text: context.translation.add,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
widget.models.add(CalibrationTool());
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
final model = widget.models[index];
|
|
|
|
|
return Column(
|
|
|
|
|
itemCount: widget.models.length + 1,
|
|
|
|
|
padding: EdgeInsets.only(top: 16.toScreenHeight),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
if (index == widget.models.length) {
|
|
|
|
|
return AppFilledButton(
|
|
|
|
|
label: "Add Asset",
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.neutral50,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
widget.models.add(CalibrationTool());
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
final model = widget.models[index];
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
margin: EdgeInsets.only(bottom: 16.toScreenHeight),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Theme.of(context).cardColor,
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
ASubTitle("#${index + 1}"),
|
|
|
|
|
if (index != 0)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
color: Theme.of(context).colorScheme.error,
|
|
|
|
|
text: context.translation.delete,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
widget.models.remove(model);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
"Asset ${index + 1}".heading5(context),
|
|
|
|
|
"trash".toSvgAsset(height: 20, width: 15).onPress(() {
|
|
|
|
|
widget.models.remove(model);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Asset Number"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
AutoCompleteDeviceNumberField(
|
|
|
|
|
initialValue: model.assetsNumber,
|
|
|
|
|
hospitalId: userProvider.user.clientId,
|
|
|
|
|
@ -70,28 +71,19 @@ class _PentryCalibrationToolFormState extends State<PentryCalibrationToolForm> {
|
|
|
|
|
model.assetsNumber = number;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Date of Testing"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: "Calibration Date",
|
|
|
|
|
date: model.dataOfTesting,
|
|
|
|
|
onDatePicker: (date) {
|
|
|
|
|
model.dataOfTesting = date;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Theme.of(context).textTheme.titleMedium.color,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|