Site Field locked and the data retrieved from user info

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

@ -151,13 +151,13 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
_gasRefillProvider = Provider.of<GasRefillProvider>(context, listen: false);
_gasRefillProvider.reset();
}
if (widget.gasRefillModel != null && _firstTime) {
_formModel = widget.gasRefillModel;
_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);
print(_gasRefillProvider.hospital?.buildings?.length);
print(widget.gasRefillModel?.building?.name);
if (_firstTime) {
if (widget.gasRefillModel != null) {
_formModel = widget.gasRefillModel;
_formModel.status = const Lookup(value: 0);
}
HospitalsProvider().getHospitalsListByVal(searchVal: _userProvider.user?.clientName).then((value) {
_gasRefillProvider.hospital = value?.firstWhere((element) => element.name == _userProvider.user?.clientName, 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.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,
),
HospitalAutoCompleteField(
enabled: false,
initialValue: _gasRefillProvider.hospital?.name,
// onSave: (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/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
class HospitalAutoCompleteField extends StatefulWidget {
final String initialValue;
final Function(Hospital) onSearch;
final bool enabled;
//final Function(Hospital) onSave;
@ -19,6 +21,7 @@ class HospitalAutoCompleteField extends StatefulWidget {
Key key,
this.onSearch,
this.initialValue,
this.enabled = true,
}) : super(key: key);
@override
@ -66,32 +69,41 @@ class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
// AppStyle.boxShadow
// ]
),
child: TypeAheadField<Hospital>(
textFieldConfiguration: TextFieldConfiguration(
style: Theme.of(context).textTheme.headline6,
controller: _controller,
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: _subtitle.hospital,
border: InputBorder.none,
disabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
textInputAction: TextInputAction.search,
),
suggestionsCallback: (vale) async {
return await HospitalsProvider().getHospitalsListByVal(searchVal: _controller.text);
},
itemBuilder: (context, hospital) {
return ListTile(
title: Text(hospital.name),
);
},
onSuggestionSelected: (hospital) {
widget.onSearch(hospital);
},
),
child: widget.enabled
? TypeAheadField<Hospital>(
textFieldConfiguration: TextFieldConfiguration(
style: Theme.of(context).textTheme.headline6,
controller: _controller,
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: _subtitle.hospital,
border: InputBorder.none,
disabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
textInputAction: TextInputAction.search,
),
suggestionsCallback: (vale) async {
return await HospitalsProvider().getHospitalsListByVal(searchVal: _controller.text);
},
itemBuilder: (context, hospital) {
return ListTile(
title: Text(hospital.name),
);
},
onSuggestionSelected: (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