You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
5.1 KiB
Dart
149 lines
5.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/models/lookup.dart';
|
|
import 'package:test_sa/models/pantry/pentry.dart';
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
import 'package:test_sa/providers/ppm_device_status_provider.dart';
|
|
import 'package:test_sa/providers/ppm_visit_status_provider.dart';
|
|
import 'package:test_sa/views/widgets/e_signature/e_signature.dart';
|
|
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
|
|
|
import '../date_and_time/date_picker.dart';
|
|
import '../images/multi_image_picker.dart';
|
|
|
|
class PentryTBSForm extends StatefulWidget {
|
|
final Pentry model;
|
|
final bool enableValidate;
|
|
|
|
const PentryTBSForm({
|
|
Key key,
|
|
this.model,
|
|
this.enableValidate,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
State<PentryTBSForm> createState() => _PentryTBSFormState();
|
|
}
|
|
|
|
class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
widget.model?.files ??= [];
|
|
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
8.height,
|
|
SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
|
|
context: context,
|
|
initialValue: widget.model.ppmVisitStatus,
|
|
title: context.translation.ppmVisit,
|
|
onSelect: (value) {
|
|
if (value != null) {
|
|
widget.model.ppmVisitStatus = value;
|
|
}
|
|
},
|
|
),
|
|
8.height,
|
|
AppTimer(
|
|
label: context.translation.timer,
|
|
timer: widget.model.timer,
|
|
enabled: widget.model.timer.endAt == null,
|
|
onChange: (timer) async {
|
|
widget.model.timer = timer;
|
|
return true;
|
|
},
|
|
),
|
|
8.height,
|
|
SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
|
|
context: context,
|
|
initialValue: widget.model.status,
|
|
title: context.translation.deviceStatus,
|
|
onSelect: (value) {
|
|
if (value != null) {
|
|
widget.model.status = value;
|
|
}
|
|
},
|
|
),
|
|
8.height,
|
|
ADatePicker(
|
|
label: context.translation.actualVisitDate,
|
|
date: widget.model.actualVisitDate,
|
|
from: DateTime.now().subtract(const Duration(days: 30)),
|
|
onDatePicker: (date) {
|
|
if (date == null) return;
|
|
widget.model.actualVisitDate = date;
|
|
setState(() {});
|
|
},
|
|
),
|
|
8.height,
|
|
ADatePicker(
|
|
label: context.translation.expectedVisitDate,
|
|
date: widget.model.expectedVisitDate,
|
|
from: DateTime.now().subtract(const Duration(days: 30)),
|
|
onDatePicker: (date) {
|
|
if (date == null) return;
|
|
widget.model.expectedVisitDate = date;
|
|
setState(() {});
|
|
},
|
|
),
|
|
8.height,
|
|
// const ASubTitle("Traveling Hours"),
|
|
// const SizedBox(
|
|
// height: 4,
|
|
// ),
|
|
// ATextFormField(
|
|
// initialValue: (widget.model.travelingHours ?? "").toString(),
|
|
// textAlign: TextAlign.center,
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
// textInputType: TextInputType.number,
|
|
// onChange: (value) {
|
|
// widget.model.travelingHours = value;
|
|
// },
|
|
// ),
|
|
8.height,
|
|
MultiFilesPicker(label: context.translation.attachImage, files: widget.model.files),
|
|
// AMiniOneFilePicker(
|
|
// //error: _validate && _serviceReport.image == null,
|
|
// file: widget.model.file,
|
|
// onPick: (file) {
|
|
// widget.model.file = file;
|
|
// },
|
|
// ),
|
|
8.height,
|
|
ESignature(
|
|
title: context.translation.nurseSignature,
|
|
oldSignature: widget.model.signatureNurse,
|
|
newSignature: widget.model.localNurseSignature,
|
|
onChange: (signature) {
|
|
// if (signature == null || signature.isEmpty) {
|
|
// return;
|
|
// }
|
|
widget.model.localNurseSignature = signature;
|
|
widget.model.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
},
|
|
),
|
|
8.height,
|
|
ESignature(
|
|
title: context.translation.engSign,
|
|
oldSignature: widget.model.signatureEngineer,
|
|
newSignature: widget.model.localEngineerSignature,
|
|
onChange: (signature) {
|
|
// if (signature == null || signature.isEmpty) {
|
|
// return;
|
|
// }
|
|
widget.model.localEngineerSignature = signature;
|
|
widget.model.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
},
|
|
),
|
|
8.height,
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|