|
|
|
|
@ -1,5 +1,3 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart';
|
|
|
|
|
@ -17,9 +15,8 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/localization/localization.dart';
|
|
|
|
|
import '../../../controllers/providers/api/hospitals_provider.dart';
|
|
|
|
|
import '../../../controllers/validator/validator.dart';
|
|
|
|
|
import '../../../models/hospital.dart';
|
|
|
|
|
import '../../app_style/colors.dart';
|
|
|
|
|
import '../../widgets/app_text_form_field.dart';
|
|
|
|
|
import '../../widgets/gas_refill/building_type_menu.dart';
|
|
|
|
|
import '../../widgets/gas_refill/department_type_menu.dart';
|
|
|
|
|
@ -45,7 +42,6 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
|
|
|
|
|
final DeviceTransfer _formModel = DeviceTransfer(receiver: DeviceTransferInfo(), sender: DeviceTransferInfo());
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void setState(VoidCallback fn) {
|
|
|
|
|
if (mounted) super.setState(() {});
|
|
|
|
|
@ -149,26 +145,50 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
|
|
|
|
|
6.height,
|
|
|
|
|
DeviceButton(
|
|
|
|
|
device: _formModel.device,
|
|
|
|
|
onDevicePick: (device) async {
|
|
|
|
|
onDevicePick: (device) {
|
|
|
|
|
_formModel.device = device;
|
|
|
|
|
log(device?.hospital?.toMap().toString());
|
|
|
|
|
// _deviceTransferProvider.building.name = device.destDepartmentName;
|
|
|
|
|
// _deviceTransferProvider.building?.name = device.destBuildingName;
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
setState(() {});
|
|
|
|
|
HospitalsProvider().getHospitalsListByVal(searchVal: device.hospital.name).then((hos) {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
_setHospital(hos.firstWhere((element) => element.name == device.hospital.name));
|
|
|
|
|
_deviceTransferProvider.department = _deviceTransferProvider.hospital.buildings
|
|
|
|
|
?.firstWhere((element) => element.name == device.destBuildingName, orElse: () => null)
|
|
|
|
|
?.floors
|
|
|
|
|
?.firstWhere((element) => element.name == device.destFloor, orElse: () => null)
|
|
|
|
|
?.departments
|
|
|
|
|
?.firstWhere((element) => element.name == device.destDepartmentName, orElse: () => null);
|
|
|
|
|
setState(() {});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (_formModel.device != null) 8.height,
|
|
|
|
|
if (_formModel.device != null) const ASubTitle("Asset Site"),
|
|
|
|
|
if (_formModel.device != null)
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AColors.inputFieldBackgroundColor,
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: const Color(0xffefefef),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
|
|
|
|
// boxShadow: const [
|
|
|
|
|
// AppStyle.boxShadow
|
|
|
|
|
// ]
|
|
|
|
|
),
|
|
|
|
|
child: ASubTitle(_formModel.device?.hospital?.name),
|
|
|
|
|
),
|
|
|
|
|
if (_formModel.device != null) 4.height,
|
|
|
|
|
if (_formModel.device != null && _formModel.device.destDepartmentName != null) const ASubTitle("Asset Department"),
|
|
|
|
|
if (_formModel.device != null && _formModel.device.destDepartmentName != null)
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AColors.inputFieldBackgroundColor,
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: const Color(0xffefefef),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
|
|
|
|
// boxShadow: const [
|
|
|
|
|
// AppStyle.boxShadow
|
|
|
|
|
// ]
|
|
|
|
|
),
|
|
|
|
|
child: ASubTitle(_formModel.device.destDepartmentName.toString()),
|
|
|
|
|
),
|
|
|
|
|
if (_formModel.device != null) 8.height,
|
|
|
|
|
// const SizedBox(height: 8,),
|
|
|
|
|
// const ASubTitle("Sender Department"),
|
|
|
|
|
// if(_validate && _formModel.senderDepartment == null)
|
|
|
|
|
@ -217,6 +237,8 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
|
|
|
|
|
Divider(
|
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
const ASubTitle("Destination"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
@ -226,7 +248,11 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
|
|
|
|
|
// _search.hospital = value;
|
|
|
|
|
// },
|
|
|
|
|
onSearch: (value) {
|
|
|
|
|
_setHospital(value);
|
|
|
|
|
_deviceTransferProvider.hospital = value;
|
|
|
|
|
_deviceTransferProvider.building = null;
|
|
|
|
|
_deviceTransferProvider.floor = null;
|
|
|
|
|
_deviceTransferProvider.department = null;
|
|
|
|
|
_formModel.receiver.client = value;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -261,8 +287,8 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
ASubTitle("Room"),
|
|
|
|
|
SizedBox(
|
|
|
|
|
const ASubTitle("Room"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ATextFormField(
|
|
|
|
|
@ -291,12 +317,4 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _setHospital(Hospital hospital) {
|
|
|
|
|
_deviceTransferProvider.hospital = hospital;
|
|
|
|
|
_deviceTransferProvider.building = null;
|
|
|
|
|
_deviceTransferProvider.floor = null;
|
|
|
|
|
_deviceTransferProvider.department = null;
|
|
|
|
|
_formModel.receiver.client = hospital;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|