Merge branch 'refs/heads/master' into dev_sikander

pull/11/head
Sikander Saleem 2 months ago
commit 0db18c789c

1
.gitignore vendored

@ -43,4 +43,3 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/android/

@ -12,9 +12,9 @@ class LabViewModel extends ChangeNotifier {
List<PatientLabOrdersResponseModel> patientLabOrders = [];
List<String> labSuggestionsList =[];
late List<String> _labSuggestionsList = [];
get labSuggestions => labSuggestionsList;
List<String> get labSuggestions => _labSuggestionsList;
LabViewModel({required this.labRepo, required this.errorHandlerService});
@ -38,6 +38,7 @@ class LabViewModel extends ChangeNotifier {
patientLabOrders = apiResponse.data!;
isLabOrdersLoading = false;
isLabResultsLoading = false;
filterSuggestions();
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse);
@ -48,6 +49,13 @@ class LabViewModel extends ChangeNotifier {
}
filterSuggestions(){
final List<String> labels = patientLabOrders
.expand((order) => order.testDetails!) // flatten testDetails
.map((detail) => detail.description) // pick description
.whereType<String>() // remove nulls if any
.toList();
_labSuggestionsList = labels.toSet().toList(); // remove duplicates by converting to a set and back to a list
notifyListeners();
}
}

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_config.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
@ -15,7 +14,6 @@ import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart';
import 'package:hmg_patient_app_new/presentation/lab/search_lab_report.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/shimmer/movies_shimmer_widget.dart';
@ -65,9 +63,9 @@ class _LabOrdersPageState extends State<LabOrdersPage> {
Utils.buildSvgWithAssets(icon: AppAssets.search_icon).onPress(() {
if(model.isLabOrdersLoading){
return;
} else {
labSuggestions = getLabSuggestions(model);
showCommonBottomSheet(context, child: SearchLabResultsContent(),
}else {
showCommonBottomSheet(context, child: SearchLabResultsContent(labSuggestionsList: model.labSuggestions),
callBackFunc: () {},
title: LocaleKeys.searchLabReport.tr(),
height: ResponsiveExtension.screenHeight,

@ -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: [
@ -37,19 +66,23 @@ class SearchLabResultsContent extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextInputWidget(
labelText:"Search lab results",
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),
"Suggestions".toText16(isBold: true),
const SizedBox(height: 12),
SizedBox(height: ResponsiveExtension(20).h),
if (filteredSuggestions.isNotEmpty) ...[
"Suggestions".toText16(isBold: true),
const SizedBox(height: 12),
],
],
),
),
@ -60,11 +93,13 @@ class SearchLabResultsContent extends StatelessWidget {
alignment: WrapAlignment.start,
spacing: 10,
runSpacing: 10,
children: _chipLabels
children: filteredSuggestions
.map((label) => SuggestionChip(
label: label,
onTap: () {},
))
label: label,
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,
@ -113,4 +152,4 @@ class SuggestionChip extends StatelessWidget {
),
);
}
}
}

@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: async
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
url: "https://pub.dev"
source: hosted
version: "2.13.0"
version: "2.12.0"
audio_session:
dependency: transitive
description:
@ -742,14 +742,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "13.1.3"
hijri_gregorian_calendar:
dependency: "direct main"
description:
name: hijri_gregorian_calendar
sha256: "9d23b52192783c1ad134b1ac001be7977342cb579c6b380647b6494fbd464d29"
url: "https://pub.dev"
source: hosted
version: "0.0.4"
html:
dependency: transitive
description:
@ -1599,10 +1591,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
url: "https://pub.dev"
source: hosted
version: "15.0.0"
version: "14.3.1"
web:
dependency: "direct main"
description:
@ -1644,5 +1636,5 @@ packages:
source: hosted
version: "6.5.0"
sdks:
dart: ">=3.8.1 <4.0.0"
dart: ">=3.8.0-0 <4.0.0"
flutter: ">=3.29.0"

@ -69,7 +69,6 @@ dependencies:
web: any
flutter_staggered_animations: ^1.1.1
smooth_corner: ^1.1.1
hijri_gregorian_calendar: ^0.0.4
dev_dependencies:
flutter_test:
@ -83,7 +82,6 @@ flutter:
- assets/
- assets/fonts/
- assets/langs/
- assets/json/
- assets/images/
- assets/images/svg/
- assets/images/png/

Loading…
Cancel
Save