|
|
|
|
@ -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)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|