Site Field locked and the data retrieved from user info

main_design2.0
zaid_daoud 3 years ago
parent bb5cc8eda6
commit 64d9305b84

@ -151,13 +151,13 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
_gasRefillProvider = Provider.of<GasRefillProvider>(context, listen: false); _gasRefillProvider = Provider.of<GasRefillProvider>(context, listen: false);
_gasRefillProvider.reset(); _gasRefillProvider.reset();
} }
if (widget.gasRefillModel != null && _firstTime) { if (_firstTime) {
if (widget.gasRefillModel != null) {
_formModel = widget.gasRefillModel; _formModel = widget.gasRefillModel;
_formModel.status = const Lookup(value: 0); _formModel.status = const Lookup(value: 0);
HospitalsProvider().getHospitalsListByVal(searchVal: widget.gasRefillModel.clientName).then((value) { }
_gasRefillProvider.hospital = value?.firstWhere((element) => element.name == widget.gasRefillModel.clientName, orElse: () => null); HospitalsProvider().getHospitalsListByVal(searchVal: _userProvider.user?.clientName).then((value) {
print(_gasRefillProvider.hospital?.buildings?.length); _gasRefillProvider.hospital = value?.firstWhere((element) => element.name == _userProvider.user?.clientName, orElse: () => null);
print(widget.gasRefillModel?.building?.name);
_gasRefillProvider.building = _gasRefillProvider.hospital?.buildings?.firstWhere((element) => element.name == widget.gasRefillModel?.building?.name, orElse: () => null); _gasRefillProvider.building = _gasRefillProvider.hospital?.buildings?.firstWhere((element) => element.name == widget.gasRefillModel?.building?.name, orElse: () => null);
_gasRefillProvider.floor = _gasRefillProvider.building?.floors?.firstWhere((element) => element.name == widget.gasRefillModel?.floor?.name, orElse: () => null); _gasRefillProvider.floor = _gasRefillProvider.building?.floors?.firstWhere((element) => element.name == widget.gasRefillModel?.floor?.name, orElse: () => null);
_gasRefillProvider.department = _gasRefillProvider.floor?.departments?.firstWhere((element) => element.name == widget.gasRefillModel?.department?.departmentName, orElse: () => null); _gasRefillProvider.department = _gasRefillProvider.floor?.departments?.firstWhere((element) => element.name == widget.gasRefillModel?.department?.departmentName, orElse: () => null);
@ -232,6 +232,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
height: 4, height: 4,
), ),
HospitalAutoCompleteField( HospitalAutoCompleteField(
enabled: false,
initialValue: _gasRefillProvider.hospital?.name, initialValue: _gasRefillProvider.hospital?.name,
// onSave: (value){ // onSave: (value){
// _search.hospital = value; // _search.hospital = value;

@ -8,10 +8,12 @@ import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.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/loaders/app_loading.dart';
class HospitalAutoCompleteField extends StatefulWidget { class HospitalAutoCompleteField extends StatefulWidget {
final String initialValue; final String initialValue;
final Function(Hospital) onSearch; final Function(Hospital) onSearch;
final bool enabled;
//final Function(Hospital) onSave; //final Function(Hospital) onSave;
@ -19,6 +21,7 @@ class HospitalAutoCompleteField extends StatefulWidget {
Key key, Key key,
this.onSearch, this.onSearch,
this.initialValue, this.initialValue,
this.enabled = true,
}) : super(key: key); }) : super(key: key);
@override @override
@ -66,7 +69,8 @@ class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
// AppStyle.boxShadow // AppStyle.boxShadow
// ] // ]
), ),
child: TypeAheadField<Hospital>( child: widget.enabled
? TypeAheadField<Hospital>(
textFieldConfiguration: TextFieldConfiguration( textFieldConfiguration: TextFieldConfiguration(
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.headline6,
controller: _controller, controller: _controller,
@ -91,6 +95,14 @@ class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
onSuggestionSelected: (hospital) { onSuggestionSelected: (hospital) {
widget.onSearch(hospital); widget.onSearch(hospital);
}, },
)
: widget.initialValue == null
? const Padding(
padding: EdgeInsets.all(8.0),
child: ALoading(),
)
: ListTile(
title: Center(child: Text(widget.initialValue)),
), ),
); );
} }

Loading…
Cancel
Save