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.
147 lines
4.4 KiB
Dart
147 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../controllers/localization/localization.dart';
|
|
import '../../../controllers/providers/user_provider.dart';
|
|
import '../../../models/pantry/pentry.dart';
|
|
import '../../app_style/sizing.dart';
|
|
import '../app_text_form_field.dart';
|
|
import '../date_and_time/date_picker.dart';
|
|
import '../images/mini_one_image_picker.dart';
|
|
import '../status/pentry/pentry_status_mune.dart';
|
|
import '../status/pentry/pentry_visit_status_mune.dart';
|
|
import '../timer/app_timer.dart';
|
|
import '../titles/app_sub_title.dart';
|
|
|
|
class PentryInfoForm extends StatefulWidget {
|
|
final Pentry? model;
|
|
final bool? enableValidate;
|
|
const PentryInfoForm({
|
|
Key? key,
|
|
this.model,
|
|
this.enableValidate,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
State<PentryInfoForm> createState() => _PentryInfoFormState();
|
|
}
|
|
|
|
class _PentryInfoFormState extends State<PentryInfoForm> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final subtitle = AppLocalization.of(context)!.subtitle;
|
|
final userProvider = Provider.of<UserProvider>(context);
|
|
return ListView(
|
|
padding: EdgeInsets.only(
|
|
top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)),
|
|
shrinkWrap: true,
|
|
physics: const ClampingScrollPhysics(),
|
|
children: [
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
const ASubTitle("PPM Visit Status"),
|
|
if ((widget.enableValidate ?? false) && widget.model?.ppmVisitStatus == null)
|
|
ASubTitle(
|
|
subtitle?.requiredWord ?? "",
|
|
color: Colors.red,
|
|
),
|
|
const SizedBox(
|
|
height: 4,
|
|
),
|
|
PentryVisitsStatusMenu(
|
|
initialValue: widget.model?.ppmVisitStatus,
|
|
onSelect: (status) {
|
|
widget.model?.ppmVisitStatus = status;
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
const ASubTitle("Timer"),
|
|
if ((widget.enableValidate ?? false) && widget.model?.timer?.endAt == null)
|
|
ASubTitle(
|
|
subtitle?.requiredWord ?? "",
|
|
color: Colors.red,
|
|
),
|
|
const SizedBox(
|
|
height: 4,
|
|
),
|
|
AppTimer(
|
|
timer: widget.model?.timer,
|
|
onChange: (timer) async {
|
|
widget.model?.timer = timer;
|
|
return true;
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
const ASubTitle("Status"),
|
|
// if(widget.enableValidate && widget.model.status == null)
|
|
// ASubTitle(subtitle.requiredWord,color: Colors.red,),
|
|
const SizedBox(
|
|
height: 4,
|
|
),
|
|
PentryStatusMenu(
|
|
initialValue: widget.model?.status,
|
|
onSelect: (status) {
|
|
widget.model?.status = status;
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
const ASubTitle("Actual Visit Date"),
|
|
if ((widget.enableValidate ?? false) && widget.model?.actualVisitDate == null)
|
|
ASubTitle(
|
|
subtitle?.requiredWord ?? "",
|
|
color: Colors.red,
|
|
),
|
|
const SizedBox(
|
|
height: 4,
|
|
),
|
|
ADatePicker(
|
|
date: widget.model?.actualVisitDate,
|
|
from: DateTime.now().subtract(const Duration(days: 30)),
|
|
onDatePicker: (date) {
|
|
if (date == null) return;
|
|
widget.model?.actualVisitDate = date;
|
|
setState(() {});
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
const ASubTitle("Traveling Hours"),
|
|
const SizedBox(
|
|
height: 4,
|
|
),
|
|
ATextFormField(
|
|
initialValue: (widget.model?.travelingHours ?? "").toString(),
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
textInputType: TextInputType.number,
|
|
onChange: (value) {
|
|
widget.model?.travelingHours = value;
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 12,
|
|
),
|
|
const ASubTitle("PPM Attachment"),
|
|
AMiniOneImagePicker(
|
|
//error: _validate && _serviceReport.image == null,
|
|
image: widget.model?.imageFile,
|
|
onPick: (image) {
|
|
widget.model?.imageFile = image;
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|