///todo deleted
// import 'package:flutter/material.dart';
// import 'package:flutter_typeahead/flutter_typeahead.dart';
// import 'package:provider/provider.dart';
// import 'package:test_sa/controllers/providers/api/devices_provider.dart';
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
// import 'package:test_sa/extensions/context_extension.dart';
// import 'package:test_sa/extensions/int_extensions.dart';
// import 'package:test_sa/extensions/widget_extensions.dart';
// import 'package:test_sa/models/lookup.dart';
//
// import '../../../../extensions/text_extensions.dart';
// import '../../../../models/device/asset.dart';
// import '../../../../models/device/asset_search.dart';
// import '../../../../new_views/app_style/app_color.dart';
// import '../../../../new_views/app_style/app_text_style.dart';
// import '../../../app_style/sizing.dart';
//
// class AutoCompleteDeviceNumberField extends StatefulWidget {
//   final Lookup initialValue;
//   final int hospitalId;
//   final Function(Lookup) onPick;
//
//   const AutoCompleteDeviceNumberField({Key? key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key);
//
//   @override
//   State<AutoCompleteDeviceNumberField> createState() => _AutoCompleteDeviceNumberFieldState();
// }
//
// class _AutoCompleteDeviceNumberFieldState extends State<AutoCompleteDeviceNumberField> {
//   SettingProvider _settingProvider;
//   AssetProvider _devicesProvider;
//   UserProvider _userProvider;
//   TextEditingController _controller;
//
//   @override
//   void initState() {
//     _controller = TextEditingController(text: widget.initialValue?.name);
//     super.initState();
//   }
//
//   @override
//   void didUpdateWidget(covariant AutoCompleteDeviceNumberField oldWidget) {
//     if (widget.initialValue != oldWidget.initialValue) {
//       _controller = TextEditingController(text: widget.initialValue?.name);
//     }
//     super.didUpdateWidget(oldWidget);
//   }
//
//   @override
//   void dispose() {
//     _controller.dispose();
//     super.dispose();
//   }
//
//   @override
//   Widget build(BuildContext context) {
//     _settingProvider = Provider.of<SettingProvider>(context);
//     _userProvider = Provider.of<UserProvider>(context);
//     _devicesProvider = Provider.of<AssetProvider>(context);
//     final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10));
//     return Container(
//       decoration: BoxDecoration(
//         color: AppColor.background(context),
//         borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
//         boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
//       ),
//       child: TypeAheadField<Asset>(
//         minCharsForSuggestions: 1,
//         textFieldConfiguration: TextFieldConfiguration(
//           style: AppTextStyles.bodyText,
//           controller: _controller,
//           textAlign: TextAlign.start,
//           textInputAction: TextInputAction.search,
//           decoration: InputDecoration(
//             border: border,
//             disabledBorder: border,
//             focusedBorder: border,
//             enabledBorder: border,
//             errorBorder: border,
//             contentPadding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 16.toScreenWidth),
//             constraints: const BoxConstraints(),
//             suffixIconConstraints: const BoxConstraints(minWidth: 0),
//             filled: true,
//             fillColor: (context.isDark ? AppColor.neutral50 : AppColor.background(context)),
//             errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60),
//             floatingLabelStyle: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20),
//             labelText: context.translation.assetNumber,
//           ),
//         ),
//         suggestionsCallback: (value) async {
//           return await _devicesProvider.getDevicesList(
//             host: _settingProvider.host,
//             user: _userProvider.user,
//             hospitalId: widget.hospitalId,
//             addPagination: false,
//             search: AssetSearch(assetNo: value),
//           );
//         },
//         itemBuilder: (context, device) {
//           return device.assetNumber.bodyText(context).paddingOnly(bottom: 16, start: 16);
//         },
//         onSuggestionSelected: (device) {
//           _controller.text = device.assetNumber;
//           widget.onPick(Lookup(id: device.id, name: device.assetNumber));
//         },
//       ),
//     );
//   }
// }
