Enable search function on patient manager
This commit is contained in:
@@ -3,9 +3,11 @@ import 'package:patient_manager/objects/patients.dart';
|
||||
|
||||
class BuildPatientsList extends StatefulWidget {
|
||||
final List<Patient> patients;
|
||||
final searchString;
|
||||
const BuildPatientsList({
|
||||
super.key,
|
||||
required this.patients,
|
||||
required this.searchString,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -18,11 +20,15 @@ class _BuildPatientsListState extends State<BuildPatientsList> {
|
||||
return ListView.builder(
|
||||
itemCount: widget.patients.length,
|
||||
itemBuilder: (context, index) {
|
||||
final patient = widget.patients[index];
|
||||
return ListTile(
|
||||
title: Text(patient.first_name + " " + patient.last_name),
|
||||
subtitle: Text(patient.id_no),
|
||||
);
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
return widget.patients[index].id_no.contains(widget.searchString)
|
||||
? ListTile(
|
||||
title: Text(widget.patients[index].first_name +
|
||||
" " +
|
||||
widget.patients[index].last_name),
|
||||
subtitle: Text(widget.patients[index].id_no),
|
||||
)
|
||||
: Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
42
Frontend/patient_manager/lib/components/mySearchInput.dart
Normal file
42
Frontend/patient_manager/lib/components/mySearchInput.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MySearchField extends StatelessWidget {
|
||||
final controller;
|
||||
final String hintText;
|
||||
final void Function(String)? onChanged;
|
||||
|
||||
const MySearchField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||
child: TextField(
|
||||
onChanged: onChanged,
|
||||
controller: controller,
|
||||
obscureText: false,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
filled: true,
|
||||
hintText: hintText,
|
||||
hintStyle: TextStyle(color: Colors.blueGrey[400]),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.blueAccent,
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.blue),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user