|
|
|
|
// import 'package:flutter/material.dart';
|
|
|
|
|
// import 'package:provider/provider.dart';
|
|
|
|
|
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
|
// import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
// import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
// import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
// import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
// import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
// import 'package:test_sa/models/device/asset.dart';
|
|
|
|
|
// import 'package:test_sa/models/service_request/service_request.dart';
|
|
|
|
|
//
|
|
|
|
|
// import '../../../../controllers/providers/api/service_requests_provider.dart';
|
|
|
|
|
// import '../../../../models/lookup.dart';
|
|
|
|
|
// import '../../../../new_views/app_style/app_color.dart';
|
|
|
|
|
// import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
// import '../../../../new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
// import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
// import '../../../../providers/service_request_providers/first_action_provider.dart';
|
|
|
|
|
// import '../../../widgets/date_and_time/date_picker.dart';
|
|
|
|
|
//
|
|
|
|
|
// class FirstActionBottomSheet extends StatefulWidget {
|
|
|
|
|
// final ServiceRequest request;
|
|
|
|
|
// todo @delete
|
|
|
|
|
// const FirstActionBottomSheet({Key? key, required this.request}) : super(key: key);
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// State<FirstActionBottomSheet> createState() => _FirstActionBottomSheetState();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
|
// late ServiceRequest _serviceRequest;
|
|
|
|
|
// Asset? asset;
|
|
|
|
|
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
//
|
|
|
|
|
// Lookup? firstAction;
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// void initState() {
|
|
|
|
|
// super.initState();
|
|
|
|
|
// _serviceRequest = widget.request;
|
|
|
|
|
// firstAction = _serviceRequest.firstAction;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
|
// final userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
// return Wrap(
|
|
|
|
|
// children: [
|
|
|
|
|
// Container(
|
|
|
|
|
// clipBehavior: Clip.antiAlias,
|
|
|
|
|
// margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
|
// color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
// borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)),
|
|
|
|
|
// ),
|
|
|
|
|
// padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight),
|
|
|
|
|
// child: Form(
|
|
|
|
|
// key: _formKey,
|
|
|
|
|
// child: SingleChildScrollView(
|
|
|
|
|
// child: Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// Container(
|
|
|
|
|
// width: 40.toScreenWidth,
|
|
|
|
|
// height: 5.toScreenHeight,
|
|
|
|
|
// decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)),
|
|
|
|
|
// ),
|
|
|
|
|
// Align(
|
|
|
|
|
// alignment: AlignmentDirectional.centerStart,
|
|
|
|
|
// child: context.translation.firstAction.heading3(context).custom(fontWeight: FontWeight.w600).paddingOnly(top: 16, bottom: 16),
|
|
|
|
|
// ),
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, FirstActionStatusProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// title: context.translation.firstActionStatus,
|
|
|
|
|
// initialValue: firstAction, //_serviceRequest.firstAction,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// setState(() {
|
|
|
|
|
// //_serviceRequest.firstAction = value;
|
|
|
|
|
// firstAction = value;
|
|
|
|
|
// if (firstAction?.value != 2) {
|
|
|
|
|
// _serviceRequest.visitDate = null;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// if (firstAction?.value == 2) ...[
|
|
|
|
|
// 8.height,
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: context.translation.visitDate,
|
|
|
|
|
// date: DateTime.tryParse(_serviceRequest.visitDate ?? ""),
|
|
|
|
|
// formatDateWithTime: true,
|
|
|
|
|
// onDatePicker: (selectedDate) {
|
|
|
|
|
// showTimePicker(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialTime: TimeOfDay.now(),
|
|
|
|
|
// ).then((selectedTime) {
|
|
|
|
|
// // Handle the selected date and time here.
|
|
|
|
|
// if (selectedTime != null) {
|
|
|
|
|
// DateTime selectedDateTime = DateTime(
|
|
|
|
|
// selectedDate.year,
|
|
|
|
|
// selectedDate.month,
|
|
|
|
|
// selectedDate.day,
|
|
|
|
|
// selectedTime.hour,
|
|
|
|
|
// selectedTime.minute,
|
|
|
|
|
// );
|
|
|
|
|
// if (selectedDateTime.isBefore(DateTime.parse(_serviceRequest.date!))) {
|
|
|
|
|
// "Visit Date time must be greater then request date".showToast;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _serviceRequest.visitDate = selectedDateTime.toIso8601String();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
//
|
|
|
|
|
// if (firstAction?.id == 404 && Provider.of<SettingProvider>(context, listen: false).assetGroup!.id == 1) ...[
|
|
|
|
|
// 8.height,
|
|
|
|
|
// Row(
|
|
|
|
|
// children: [
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: context.translation.startDate,
|
|
|
|
|
// date: DateTime.tryParse(_serviceRequest.startDate ?? ""),
|
|
|
|
|
// formatDateWithTime: true,
|
|
|
|
|
// onDatePicker: (selectedDate) {
|
|
|
|
|
// showTimePicker(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialTime: TimeOfDay.now(),
|
|
|
|
|
// ).then((selectedTime) {
|
|
|
|
|
// // Handle the selected date and time here.
|
|
|
|
|
// if (selectedTime != null) {
|
|
|
|
|
// DateTime selectedDateTime = DateTime(
|
|
|
|
|
// selectedDate.year,
|
|
|
|
|
// selectedDate.month,
|
|
|
|
|
// selectedDate.day,
|
|
|
|
|
// selectedTime.hour,
|
|
|
|
|
// selectedTime.minute,
|
|
|
|
|
// );
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _serviceRequest.startDate = selectedDateTime.toIso8601String();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ).expanded,
|
|
|
|
|
// 8.width,
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: context.translation.endDate,
|
|
|
|
|
// date: DateTime.tryParse(_serviceRequest.endDate ?? ""),
|
|
|
|
|
// formatDateWithTime: true,
|
|
|
|
|
// onDatePicker: (selectedDate) {
|
|
|
|
|
// showTimePicker(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialTime: TimeOfDay.now(),
|
|
|
|
|
// ).then((selectedTime) {
|
|
|
|
|
// // Handle the selected date and time here.
|
|
|
|
|
// if (selectedTime != null) {
|
|
|
|
|
// DateTime selectedDateTime = DateTime(
|
|
|
|
|
// selectedDate.year,
|
|
|
|
|
// selectedDate.month,
|
|
|
|
|
// selectedDate.day,
|
|
|
|
|
// selectedTime.hour,
|
|
|
|
|
// selectedTime.minute,
|
|
|
|
|
// );
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _serviceRequest.endDate = selectedDateTime.toIso8601String();
|
|
|
|
|
// _serviceRequest.workingHours =
|
|
|
|
|
// (((DateTime.parse(_serviceRequest.endDate!).difference(DateTime.parse(_serviceRequest.startDate!)).inSeconds ?? 0) / 60) / 60).toStringAsFixed(2);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ).expanded,
|
|
|
|
|
// ],
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
//
|
|
|
|
|
// /// Loan availability not required
|
|
|
|
|
// // 8.height,
|
|
|
|
|
// // SingleItemDropDownMenu<Lookup, LoanAvailabilityProvider>(
|
|
|
|
|
// // context: context,
|
|
|
|
|
// // title: context.translation.loanAvailability,
|
|
|
|
|
// // initialValue: _serviceRequest.loanAvailability,
|
|
|
|
|
// // onSelect: (status) {
|
|
|
|
|
// // setState(() {
|
|
|
|
|
// // _serviceRequest.loanAvailability = status;
|
|
|
|
|
// // if (_serviceRequest.loanAvailability.value != 1) {
|
|
|
|
|
// // asset = null;
|
|
|
|
|
// // }
|
|
|
|
|
// // });
|
|
|
|
|
// // },
|
|
|
|
|
// // ),
|
|
|
|
|
// // if (_serviceRequest?.loanAvailability?.value == 1) 8.height,
|
|
|
|
|
// // if (_serviceRequest?.loanAvailability?.value == 1)
|
|
|
|
|
// // PickAsset(
|
|
|
|
|
// // device: asset ?? _serviceRequest.device,
|
|
|
|
|
// // onPickAsset: (asset) {
|
|
|
|
|
// // setState(() {
|
|
|
|
|
// // this.asset = asset;
|
|
|
|
|
// // });
|
|
|
|
|
// // },
|
|
|
|
|
// // ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: context.translation.comments,
|
|
|
|
|
// textInputType: TextInputType.multiline,
|
|
|
|
|
// alignLabelWithHint: true,
|
|
|
|
|
// onChange: (text) {
|
|
|
|
|
// _serviceRequest.comments = text;
|
|
|
|
|
// },
|
|
|
|
|
// onSaved: (text) {
|
|
|
|
|
// _serviceRequest.comments = text;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 16.height,
|
|
|
|
|
// Consumer<ServiceRequestsProvider>(
|
|
|
|
|
// builder: (context, snapshot, _) => AppFilledButton(
|
|
|
|
|
// label: context.translation.save,
|
|
|
|
|
// loading: snapshot.isLoading ?? false,
|
|
|
|
|
// onPressed: () async {
|
|
|
|
|
// _formKey.currentState!.save();
|
|
|
|
|
// _serviceRequest.device = asset;
|
|
|
|
|
// _serviceRequest.firstAction = firstAction;
|
|
|
|
|
// await snapshot.updateRequest(user: userProvider.user!, request: _serviceRequest);
|
|
|
|
|
// Navigator.pop(context, true);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// 16.height,
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// }
|