Merge branch 'zaid_development_new' into majd_development_new

main_design2.0
nextwo 2 years ago
commit 648d48e486

@ -1,49 +1,64 @@
import '../lookup.dart'; import 'package:test_sa/models/device/device.dart';
import '../hospital.dart';
class DeviceTransferSearch { class DeviceTransferSearch {
String assetName, assetNumber, site; Device device;
String title, room;
bool mostRecent; bool mostRecent;
Lookup dateOperator; Hospital hospital;
String from, to; Buildings building;
List<Buildings> buildingsList;
Floors floor;
List<Floors> floorsList;
Departments department;
List<Departments> departmentsList;
DeviceTransferSearch({ DeviceTransferSearch({
this.assetName, this.device,
this.assetNumber, this.hospital,
this.site, this.building,
this.floor,
this.department,
this.room,
this.title,
this.mostRecent, this.mostRecent,
this.dateOperator,
this.from,
this.to,
}); });
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
Map<String, dynamic> search = {}; Map<String, dynamic> search = {};
if (assetName != null && assetName.isNotEmpty) { if (title != null && title.isNotEmpty) {
search["assetName"] = assetName; search["transferCode"] = title;
}
if (device != null) {
search["assetId"] = device.id;
}
if (hospital?.id != null) {
search["destSiteId"] = hospital.id;
} }
if (assetNumber != null && assetNumber.isNotEmpty) { if (building?.id != null) {
search["assetNumber"] = assetNumber; search["destBuildingId"] = building.id;
} }
if (site != null && site.isNotEmpty) { if (floor?.id != null) {
search["site"] = site; search["destFloorId"] = floor.id;
} }
if (dateOperator != null && from != null) { if (department?.id != null) {
search["requestedDateSymbol"] = dateOperator.toMap(); search["destDepartmentId"] = department.id;
search["requestedDateFrom"] = from;
} }
if (dateOperator != null && to != null) { if (room != null && room.isNotEmpty) {
search["requestedDateTo"] = to; search["destRoom"] = department.id;
} }
return search; return search;
} }
void fromSearch(DeviceTransferSearch newSearch) { void fromSearch(DeviceTransferSearch newSearch) {
assetName = newSearch.assetName; title = newSearch.title;
assetNumber = newSearch.assetNumber; room = newSearch.room;
site = newSearch.site;
mostRecent = newSearch.mostRecent; mostRecent = newSearch.mostRecent;
from = newSearch.from; device = newSearch.device;
to = newSearch.to; hospital = newSearch.hospital;
dateOperator = newSearch.dateOperator; building = newSearch.building;
floor = newSearch.floor;
department = newSearch.department;
} }
} }

@ -72,11 +72,12 @@ class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage> with
backgroundColor: AColors.white, backgroundColor: AColors.white,
onPressed: () async { onPressed: () async {
DeviceTransferSearch temp = await showModalBottomSheet( DeviceTransferSearch temp = await showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
builder: (context) { builder: (context) {
return AssetTransferSearchDialog(initialSearchValue: _deviceTransferProvider.deviceTransferSearch); return AssetTransferSearchDialog(initialSearchValue: _deviceTransferProvider.deviceTransferSearch);
}); },
);
if (temp != null) { if (temp != null) {
_deviceTransferProvider.deviceTransferSearch = temp; _deviceTransferProvider.deviceTransferSearch = temp;
_deviceTransferProvider.reset(); _deviceTransferProvider.reset();

@ -90,7 +90,7 @@ class _DepartmentTypeMenuState extends State<DepartmentTypeMenu> {
return DropdownMenuItem<Departments>( return DropdownMenuItem<Departments>(
value: value, value: value,
child: Text( child: Text(
value.name, value?.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontSize: 11, fontSize: 11,

@ -5,12 +5,15 @@ import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/sizing.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_button.dart';
import 'package:test_sa/views/widgets/buttons/app_small_button.dart'; import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
import 'package:test_sa/views/widgets/equipment/device_button.dart';
import '../../../controllers/providers/api/hospitals_provider.dart';
import '../app_text_form_field.dart'; import '../app_text_form_field.dart';
import '../date_and_time/date_picker.dart'; import '../gas_refill/building_type_menu.dart';
import '../status/report/service_report_visit_date_operator.dart'; import '../gas_refill/department_type_menu.dart';
import '../gas_refill/floor_type_menu.dart';
import '../hospitals/hospital_auto_complete_field.dart';
import '../switch_button.dart'; import '../switch_button.dart';
import '../titles/app_sub_title.dart';
class AssetTransferSearchDialog extends StatefulWidget { class AssetTransferSearchDialog extends StatefulWidget {
final DeviceTransferSearch initialSearchValue; final DeviceTransferSearch initialSearchValue;
@ -25,6 +28,7 @@ class AssetTransferSearchDialog extends StatefulWidget {
class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> with TickerProviderStateMixin { class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> with TickerProviderStateMixin {
DeviceTransferSearch _search; DeviceTransferSearch _search;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
bool _isLoading = false;
@override @override
void initState() { void initState() {
@ -36,165 +40,161 @@ class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> wi
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Subtitle subtitle = AppLocalization.of(context).subtitle; Subtitle subtitle = AppLocalization.of(context).subtitle;
return SizedBox( return Padding(
height: MediaQuery.of(context).size.height / 1.3, padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Form( child: ClipRRect(
key: _formKey, borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
child: ListView( clipBehavior: Clip.antiAliasWithSaveLayer,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), child: Container(
children: [ color: Colors.white,
Row( height: MediaQuery.of(context).size.height / 1.3,
mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 20),
child: Form(
key: _formKey,
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
children: [ children: [
ASmallButton( Row(
text: subtitle.cancel, mainAxisAlignment: MainAxisAlignment.spaceBetween,
onPressed: () { children: [
Navigator.of(context).pop(); ASmallButton(
text: subtitle.cancel,
onPressed: () {
Navigator.of(context).pop();
},
),
ASmallButton(
text: subtitle.search,
onPressed: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
)
],
),
ASwitchButton(
title: "Most Recent",
value: _search.mostRecent ?? false,
onChange: (value) {
_search.mostRecent = value;
setState(() {});
}, },
), ),
ASmallButton( SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
text: subtitle.search, DeviceButton(
onPressed: () { device: _search.device,
onDevicePick: (device) {
_search.device = device;
setState(() {});
},
),
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
ATextFormField(
initialValue: _search.title,
hintText: subtitle.title,
style: Theme.of(context).textTheme.titleLarge,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) { if (!_formKey.currentState.validate()) {
return; return;
} }
_formKey.currentState.save(); _formKey.currentState.save();
Navigator.of(context).pop(_search); Navigator.of(context).pop(_search);
}, },
) onSaved: (value) {
], _search.title = value;
), },
ASwitchButton(
title: "Most Recent",
value: _search.mostRecent ?? false,
onChange: (value) {
_search.mostRecent = value;
setState(() {});
},
),
SizedBox(
height: 8.0 * AppStyle.getScaleFactor(context),
),
ATextFormField(
initialValue: _search.assetNumber,
hintText: subtitle.assetNumber,
style: Theme.of(context).textTheme.headline6,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
onSaved: (value) {
_search.assetNumber = value;
},
),
SizedBox(
height: 8.0 * AppStyle.getScaleFactor(context),
),
ATextFormField(
initialValue: _search.assetName,
hintText: subtitle.assetName,
style: Theme.of(context).textTheme.headline6,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
onSaved: (value) {
_search.site = value;
},
),
SizedBox(
height: 8.0 * AppStyle.getScaleFactor(context),
),
ATextFormField(
initialValue: _search.site,
hintText: subtitle.site,
style: Theme.of(context).textTheme.headline6,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
onSaved: (value) {
_search.assetName = value;
},
),
SizedBox(
height: 8.0 * AppStyle.getScaleFactor(context),
),
const ASubTitle("Request Date"),
const SizedBox(height: 4),
ServiceReportVisitDateOperator(
initialValue: _search.dateOperator,
onSelect: (status) {
_search.dateOperator = status;
setState(() {});
},
),
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const ASubTitle("From"),
ADatePicker(
date: DateTime.tryParse(_search.from ?? ""),
from: DateTime(1950),
onDatePicker: (date) {
_search.from = date?.toIso8601String();
setState(() {});
},
),
],
),
), ),
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const SizedBox(width: 16), SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) HospitalAutoCompleteField(
Expanded( initialValue: _search?.hospital?.name,
child: Column( onSearch: (selected) async {
crossAxisAlignment: CrossAxisAlignment.stretch, _search.building = null;
children: [ _search.floor = null;
const ASubTitle("To"), _search.department = null;
ADatePicker( _search.buildingsList = null;
date: DateTime.tryParse(_search.to ?? ""), _search.floorsList = null;
from: DateTime(1950), _search.departmentsList = null;
onDatePicker: (date) { _isLoading = true;
_search.to = date?.toIso8601String(); setState(() {});
setState(() {}); await HospitalsProvider().getHospitalsListByVal(searchVal: selected?.name ?? "").then((value) {
}, _search.hospital = value?.firstWhere((element) => element.name == selected.name, orElse: () => null);
), _search.buildingsList = _search.hospital?.buildings;
], });
), _isLoading = false;
), setState(() {});
], },
), ),
const SizedBox(width: 16), const SizedBox(height: 8),
Visibility( BuildingTypeMenu(
visible: _search.toMap().isNotEmpty, initialValue: _search?.building,
child: Padding( building: _search.buildingsList,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), enabled: !_isLoading,
child: AButton( onSelect: (status) {
padding: EdgeInsets.zero, _search.building = status;
text: subtitle.clearSearch, _search.floorsList = status?.floors;
onPressed: () { setState(() {});
_search = DeviceTransferSearch(); },
),
const SizedBox(height: 8),
FloorTypeMenu(
initialValue: _search?.floor,
floors: _search.floorsList,
enabled: !_isLoading,
onSelect: (status) {
_search.floor = status;
_search.departmentsList = _search.floor?.departments;
setState(() {});
},
),
const SizedBox(height: 8),
DepartmentTypeMenu(
initialValue: _search?.department,
departments: _search.departmentsList,
enabled: !_isLoading,
onSelect: (status) {
_search.department = status;
setState(() {});
},
),
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
ATextFormField(
initialValue: _search.room,
hintText: subtitle.room,
style: Theme.of(context).textTheme.titleLarge,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search); Navigator.of(context).pop(_search);
}, },
onSaved: (value) {
_search.room = value;
},
), ),
), SizedBox(height: 16.0 * AppStyle.getScaleFactor(context)),
Visibility(
visible: _search.toMap().isNotEmpty,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: AButton(
padding: EdgeInsets.zero,
text: subtitle.clearSearch,
onPressed: () {
_search = DeviceTransferSearch();
Navigator.of(context).pop(_search);
},
),
),
),
],
), ),
], ),
), ),
), ),
); );

Loading…
Cancel
Save