|
|
|
|
@ -9,25 +9,54 @@ import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/input_widget.dart';
|
|
|
|
|
import 'package:sizer/sizer.dart';
|
|
|
|
|
|
|
|
|
|
class SearchLabResultsContent extends StatelessWidget {
|
|
|
|
|
const SearchLabResultsContent({super.key});
|
|
|
|
|
class SearchLabResultsContent extends StatefulWidget {
|
|
|
|
|
final List<String> labSuggestionsList;
|
|
|
|
|
|
|
|
|
|
final List<String> _chipLabels = const [
|
|
|
|
|
"Blood Test",
|
|
|
|
|
"X-Ray",
|
|
|
|
|
"MRI Scan",
|
|
|
|
|
"CT Scan",
|
|
|
|
|
"Ultrasound",
|
|
|
|
|
"Urine Test",
|
|
|
|
|
"Allergy Test",
|
|
|
|
|
"Cholesterol Test",
|
|
|
|
|
"Diabetes Test",
|
|
|
|
|
"Thyroid Test",
|
|
|
|
|
];
|
|
|
|
|
const SearchLabResultsContent({super.key, required this.labSuggestionsList});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
State<SearchLabResultsContent> createState() => _SearchLabResultsContentState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SearchLabResultsContentState extends State<SearchLabResultsContent> {
|
|
|
|
|
TextEditingController searchEditingController = TextEditingController();
|
|
|
|
|
List<String> filteredSuggestions = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
filteredSuggestions = List.from(widget.labSuggestionsList);
|
|
|
|
|
|
|
|
|
|
// Listen for changes in the search field
|
|
|
|
|
searchEditingController.addListener(() {
|
|
|
|
|
filterSuggestions();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
searchEditingController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void filterSuggestions() {
|
|
|
|
|
final query = searchEditingController.text.toLowerCase();
|
|
|
|
|
|
|
|
|
|
if (query.isEmpty) {
|
|
|
|
|
setState(() {
|
|
|
|
|
filteredSuggestions = List.from(widget.labSuggestionsList);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
filteredSuggestions = widget.labSuggestionsList
|
|
|
|
|
.where((suggestion) => suggestion.toLowerCase().contains(query))
|
|
|
|
|
.toList();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
@ -39,18 +68,22 @@ class SearchLabResultsContent extends StatelessWidget {
|
|
|
|
|
TextInputWidget(
|
|
|
|
|
labelText: "Search lab results",
|
|
|
|
|
hintText: "Type test name",
|
|
|
|
|
controller: TextEditingController(),
|
|
|
|
|
controller: searchEditingController,
|
|
|
|
|
isEnable: true,
|
|
|
|
|
prefix: null,
|
|
|
|
|
autoFocus: true,
|
|
|
|
|
isBorderAllowed: false,
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical:ResponsiveExtension(10).h, horizontal: ResponsiveExtension(15).h),
|
|
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
vertical: ResponsiveExtension(10).h,
|
|
|
|
|
horizontal: ResponsiveExtension(15).h,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: ResponsiveExtension(20).h),
|
|
|
|
|
if (filteredSuggestions.isNotEmpty) ...[
|
|
|
|
|
"Suggestions".toText16(isBold: true),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
@ -60,10 +93,12 @@ class SearchLabResultsContent extends StatelessWidget {
|
|
|
|
|
alignment: WrapAlignment.start,
|
|
|
|
|
spacing: 10,
|
|
|
|
|
runSpacing: 10,
|
|
|
|
|
children: _chipLabels
|
|
|
|
|
children: filteredSuggestions
|
|
|
|
|
.map((label) => SuggestionChip(
|
|
|
|
|
label: label,
|
|
|
|
|
onTap: () {},
|
|
|
|
|
onTap: () {
|
|
|
|
|
searchEditingController.text = label;
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
|
.toList(),
|
|
|
|
|
),
|
|
|
|
|
@ -76,7 +111,7 @@ class SearchLabResultsContent extends StatelessWidget {
|
|
|
|
|
text: LocaleKeys.search.tr(),
|
|
|
|
|
icon: AppAssets.search_icon,
|
|
|
|
|
iconColor: Colors.white,
|
|
|
|
|
onPressed: () => Navigator.pop(context),
|
|
|
|
|
onPressed: () => Navigator.pop(context, searchEditingController.text),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -99,12 +134,16 @@ class SuggestionChip extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: onTap, // optional tap callback
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: isSelected ? AppColors.primaryRedColor : AppColors.whiteColor,
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: AppColors.greyColor,
|
|
|
|
|
width: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: label.toText12(
|
|
|
|
|
color: isSelected ? Colors.white : Colors.black87,
|
|
|
|
|
|