clean code & change look and feel
This commit is contained in:
@@ -25,8 +25,7 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
TextEditingController searchController = TextEditingController();
|
TextEditingController searchController = TextEditingController();
|
||||||
String endpoint = "http://localhost:80/patients/user/";
|
String endpoint = "http://localhost:80/patients/user/";
|
||||||
late Future<List<Patient>> futurePatients;
|
late Future<List<Patient>> futurePatients;
|
||||||
// late Widget displayWidget;
|
|
||||||
//List<Patient> tempList;
|
|
||||||
String searchString = "";
|
String searchString = "";
|
||||||
|
|
||||||
Future<List<Patient>> fetchPatients(String endpoint) async {
|
Future<List<Patient>> fetchPatients(String endpoint) async {
|
||||||
@@ -51,20 +50,90 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
|
|
||||||
Widget displayList(List<Patient> patientsList, String searchString) {
|
Widget displayList(List<Patient> patientsList, String searchString) {
|
||||||
if (searchString.isNotEmpty && searchString != "") {
|
if (searchString.isNotEmpty && searchString != "") {
|
||||||
return BuildPatientsList(
|
return Padding(
|
||||||
patients: patientsList,
|
padding: const EdgeInsets.only(
|
||||||
searchString: searchString,
|
left: 25,
|
||||||
|
right: 25,
|
||||||
|
bottom: 25,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
border: Border.all(color: Colors.blueAccent, width: 3.0),
|
||||||
|
),
|
||||||
|
child: BuildPatientsList(
|
||||||
|
patients: patientsList,
|
||||||
|
searchString: searchString,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const Center(
|
return Padding(
|
||||||
child: Text(
|
padding: const EdgeInsets.only(
|
||||||
"Please search for a Patient.",
|
left: 25,
|
||||||
style: TextStyle(fontSize: 25, color: Colors.grey),
|
right: 25,
|
||||||
textAlign: TextAlign.center,
|
bottom: 25,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
border: Border.all(color: Colors.blueAccent, width: 3.0),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: Text(
|
||||||
|
"Enter ID of Patient",
|
||||||
|
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget patientSearch() {
|
||||||
|
return Column(children: [
|
||||||
|
//spacer
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MySearchField(
|
||||||
|
controller: searchController,
|
||||||
|
hintText: "ID Search",
|
||||||
|
required: false,
|
||||||
|
editable: true,
|
||||||
|
onTap: () {},
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
searchString = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
//spacer
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
FutureBuilder(
|
||||||
|
future: futurePatients,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
} else if (snapshot.hasData) {
|
||||||
|
List<Patient> patientsList;
|
||||||
|
if (searchString == "") {
|
||||||
|
patientsList = snapshot.data!;
|
||||||
|
} else {
|
||||||
|
patientsList = filterSearchResults(snapshot.data!, searchString);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Expanded(
|
||||||
|
child: displayList(patientsList, searchString),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const PatManAppDrawer(userEmail: "Error pulling email");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
futurePatients = fetchPatients(endpoint + widget.userEmail);
|
futurePatients = fetchPatients(endpoint + widget.userEmail);
|
||||||
@@ -76,69 +145,32 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const MyAppBar(barTitle: "Patient Manager"),
|
appBar: const MyAppBar(barTitle: "Patient Manager"),
|
||||||
drawer: PatManAppDrawer(userEmail: widget.userEmail),
|
drawer: PatManAppDrawer(userEmail: widget.userEmail),
|
||||||
//floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: Padding(
|
||||||
label: const Text(
|
padding: const EdgeInsets.only(top: 65, right: 5),
|
||||||
"Add Patient",
|
child: FloatingActionButton.extended(
|
||||||
style: TextStyle(
|
label: const Text(
|
||||||
fontWeight: FontWeight.bold,
|
"Add Patient",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.blueAccent,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed('/patient-manager/add', arguments: widget.userEmail);
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.add,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.blueAccent,
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamed('/patient-manager/add', arguments: widget.userEmail);
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Row(
|
body: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(children: [
|
child: patientSearch(),
|
||||||
//spacer
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MySearchField(
|
|
||||||
controller: searchController,
|
|
||||||
hintText: "ID Search",
|
|
||||||
required: false,
|
|
||||||
editable: true,
|
|
||||||
onTap: () {},
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
searchString = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
//spacer
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
FutureBuilder(
|
|
||||||
future: futurePatients,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
} else if (snapshot.hasData) {
|
|
||||||
List<Patient> patientsList;
|
|
||||||
if (searchString == "") {
|
|
||||||
patientsList = snapshot.data!;
|
|
||||||
} else {
|
|
||||||
patientsList =
|
|
||||||
filterSearchResults(snapshot.data!, searchString);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Expanded(
|
|
||||||
child: displayList(patientsList, searchString),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const PatManAppDrawer(
|
|
||||||
userEmail: "Error pulling email");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user