Add note functionality added & multi Line text input compoment added
This commit is contained in:
@@ -17,38 +17,41 @@ int indexOn = 0;
|
|||||||
class _BuildNotesListState extends State<BuildNotesList> {
|
class _BuildNotesListState extends State<BuildNotesList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.separated(
|
return Container(
|
||||||
shrinkWrap: true,
|
height: 290.0,
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
child: ListView.separated(
|
||||||
return const Divider();
|
shrinkWrap: true,
|
||||||
},
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
itemCount: widget.notes.length,
|
return const Divider();
|
||||||
itemBuilder: (context, index) {
|
},
|
||||||
return ListTile(
|
itemCount: widget.notes.length,
|
||||||
title: Text(
|
itemBuilder: (context, index) {
|
||||||
widget.notes[index].note_name,
|
return ListTile(
|
||||||
),
|
title: Text(
|
||||||
subtitle: Text(widget.notes[index].note_text),
|
widget.notes[index].note_name,
|
||||||
trailing: const Icon(Icons.arrow_forward),
|
),
|
||||||
onTap: () {
|
subtitle: Text(widget.notes[index].note_text),
|
||||||
showDialog(
|
trailing: const Icon(Icons.arrow_forward),
|
||||||
context: context,
|
onTap: () {
|
||||||
builder: (context) => AlertDialog(
|
showDialog(
|
||||||
title: Text(widget.notes[index].note_name),
|
context: context,
|
||||||
content: Text(
|
builder: (context) => AlertDialog(
|
||||||
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}"),
|
title: Text(widget.notes[index].note_name),
|
||||||
actions: [
|
content: Text(
|
||||||
TextButton(
|
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}"),
|
||||||
onPressed: () {
|
actions: [
|
||||||
Navigator.pop(context);
|
TextButton(
|
||||||
},
|
onPressed: () {
|
||||||
child: const Text("Close"))
|
Navigator.pop(context);
|
||||||
],
|
},
|
||||||
),
|
child: const Text("Close"))
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
Frontend/patient_manager/lib/components/myMLTextInput.dart
Normal file
53
Frontend/patient_manager/lib/components/myMLTextInput.dart
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MyMLTextField extends StatelessWidget {
|
||||||
|
final controller;
|
||||||
|
final String hintText;
|
||||||
|
final bool editable;
|
||||||
|
|
||||||
|
const MyMLTextField({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
required this.hintText,
|
||||||
|
required this.editable,
|
||||||
|
});
|
||||||
|
|
||||||
|
bool makeEditable() {
|
||||||
|
if (editable) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||||
|
child: TextField(
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
textAlignVertical: TextAlignVertical.top,
|
||||||
|
expands: true,
|
||||||
|
maxLines: null,
|
||||||
|
controller: controller,
|
||||||
|
readOnly: makeEditable(),
|
||||||
|
obscureText: false,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
fillColor: Colors.white,
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:patient_manager/components/buildNotesList.dart';
|
import 'package:patient_manager/components/buildNotesList.dart';
|
||||||
|
import 'package:patient_manager/components/myMLTextInput.dart';
|
||||||
|
import 'package:patient_manager/components/myTextInput.dart';
|
||||||
import 'package:patient_manager/objects/notes.dart';
|
import 'package:patient_manager/objects/notes.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
@@ -26,8 +28,47 @@ class PatientNotes extends StatefulWidget {
|
|||||||
|
|
||||||
class _PatientNotesState extends State<PatientNotes> {
|
class _PatientNotesState extends State<PatientNotes> {
|
||||||
String endpoint = "http://localhost:80/notes/patients/";
|
String endpoint = "http://localhost:80/notes/patients/";
|
||||||
|
String apiUrlAddNote = "http://localhost:80/notes/insert/";
|
||||||
|
final titleController = TextEditingController();
|
||||||
|
final noteTextController = TextEditingController();
|
||||||
late Future<List<Note>> futueNotes;
|
late Future<List<Note>> futueNotes;
|
||||||
|
|
||||||
|
Future<void> addPatientNoteAPICall() async {
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse(apiUrlAddNote),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"note_name": titleController.text,
|
||||||
|
"note_text": noteTextController.text,
|
||||||
|
"patient_id": widget.patientIndex,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 201) {
|
||||||
|
setState(() {
|
||||||
|
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
|
||||||
|
});
|
||||||
|
// Navigator.of(context)
|
||||||
|
// .pushNamed('/patient-manager', arguments: widget.userEmail);
|
||||||
|
String message = "Successfully added Note";
|
||||||
|
messagePopUp(message);
|
||||||
|
} else {
|
||||||
|
messagePopUp("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void messagePopUp(error) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(error),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
|
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
|
||||||
@@ -43,13 +84,13 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
return const CircularProgressIndicator();
|
return const CircularProgressIndicator();
|
||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData) {
|
||||||
final notesList = snapshot.data!;
|
final notesList = snapshot.data!;
|
||||||
return Expanded(
|
return Flexible(
|
||||||
flex: 1,
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 20.0,
|
elevation: 20.0,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
//height: 300.0,
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Color.fromARGB(255, 219, 218, 218),
|
color: Color.fromARGB(255, 219, 218, 218),
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
@@ -58,22 +99,88 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 5.0),
|
padding: const EdgeInsets.only(top: 5.0),
|
||||||
child: Column(children: [
|
child: Expanded(
|
||||||
const Text(
|
child: Column(children: [
|
||||||
"Notes",
|
Row(
|
||||||
textAlign: TextAlign.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
style: TextStyle(
|
children: [
|
||||||
fontSize: 35,
|
const Text(
|
||||||
fontWeight: FontWeight.bold,
|
"Notes",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 35,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text("Add Note"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: MyTextField(
|
||||||
|
controller: titleController,
|
||||||
|
hintText: "Title of Note",
|
||||||
|
editable: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 25.0,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: MyMLTextField(
|
||||||
|
controller: noteTextController,
|
||||||
|
hintText: "Note Details",
|
||||||
|
editable: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
addPatientNoteAPICall();
|
||||||
|
Navigator.pop(context);
|
||||||
|
//print(widget.patientIndex);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
"Submit",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
const Padding(
|
||||||
const Padding(
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
child: Divider(),
|
||||||
child: Divider(),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
const SizedBox(height: 10),
|
BuildNotesList(notes: notesList),
|
||||||
BuildNotesList(notes: notesList),
|
]),
|
||||||
]),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -207,7 +207,12 @@ class _EditPatientState extends State<EditPatient> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
deletePatientApiCall();
|
deletePatientApiCall();
|
||||||
},
|
},
|
||||||
child: const Text("Yes"),
|
child: const Text(
|
||||||
|
"Yes",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
database/ibdata1
BIN
database/ibdata1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user