|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.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/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';
|
|
|
|
|
|
|
|
|
|
class PentryCalibrationToolForm extends StatefulWidget {
|
|
|
|
|
final List<CalibrationTool> models;
|
|
|
|
|
final bool enableValidate;
|
|
|
|
|
const PentryCalibrationToolForm({
|
|
|
|
|
Key key,
|
|
|
|
|
this.models,
|
|
|
|
|
this.enableValidate,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<PentryCalibrationToolForm> createState() => _PentryCalibrationToolFormState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PentryCalibrationToolFormState extends State<PentryCalibrationToolForm> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
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: subtitle.add,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
widget.models.add(CalibrationTool());
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
final model = widget.models[index];
|
|
|
|
|
return ListView(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const ClampingScrollPhysics(),
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
ASubTitle("#${index + 1}"),
|
|
|
|
|
if (index != 0)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
color: Theme.of(context).colorScheme.error,
|
|
|
|
|
text: subtitle.delete,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
widget.models.remove(model);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Asset Number"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
AutoCompleteDeviceNumberField(
|
|
|
|
|
initialValue: model.assetsNumber,
|
|
|
|
|
hospitalId: userProvider.user.hospital?.id,
|
|
|
|
|
onPick: (number) {
|
|
|
|
|
model.assetsNumber = number;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Date of Testing"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ADatePicker(
|
|
|
|
|
date: model.dataOfTesting,
|
|
|
|
|
onDatePicker: (date) {
|
|
|
|
|
model.dataOfTesting = date;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Theme.of(context).textTheme.titleMedium.color,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|