diff --git a/Frontend/lib/mih_packages/patient_profile/pat_profile/list_builders/build_med_list.dart b/Frontend/lib/mih_packages/patient_profile/pat_profile/list_builders/build_med_list.dart new file mode 100644 index 00000000..f43124ae --- /dev/null +++ b/Frontend/lib/mih_packages/patient_profile/pat_profile/list_builders/build_med_list.dart @@ -0,0 +1,69 @@ +import 'package:Mzansi_Innovation_Hub/main.dart'; +import 'package:Mzansi_Innovation_Hub/mih_objects/medicine.dart'; +import 'package:flutter/material.dart'; + +class BuildMedicinesList extends StatefulWidget { + final TextEditingController contoller; + final List medicines; + //final searchString; + + const BuildMedicinesList({ + super.key, + required this.contoller, + required this.medicines, + //required this.searchString, + }); + + @override + State createState() => _BuildMedicinesListState(); +} + +class _BuildMedicinesListState extends State { + int indexOn = 0; + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ListView.separated( + separatorBuilder: (BuildContext context, int index) { + return Divider( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ); + }, + itemCount: widget.medicines.length, + itemBuilder: (context, index) { + //final patient = widget.patients[index].id_no.contains(widget.searchString); + return ListTile( + title: Text( + widget.medicines[index].name, + style: TextStyle( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ), + ), + subtitle: Text( + "${widget.medicines[index].unit} - ${widget.medicines[index].form}", + style: TextStyle( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ), + ), + onTap: () { + setState(() { + widget.contoller.text = + "${widget.medicines[index].name}%t${widget.medicines[index].unit}%t${widget.medicines[index].form}"; + Navigator.of(context).pop(); + }); + }, + trailing: Icon( + Icons.arrow_forward, + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ), + ); + }, + ); + } +}