pull to refresh for get dynamic code

master
Sneha 1 year ago
parent c331f12bcc
commit 5d846d77eb

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/common/zoom_image.dart'; import 'package:healthcare_user/common/zoom_image.dart';
import 'package:healthcare_user/models/get_connected_doctors_model.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:multi_image_picker/multi_image_picker.dart';
@ -42,7 +43,35 @@ class _AddReportsState extends State<AddReports> {
Map<String,dynamic> reports={}; Map<String,dynamic> reports={};
Map<String,dynamic> prescriptions={}; Map<String,dynamic> prescriptions={};
String? prescriptionFor; String? prescriptionFor;
String? problemCategory;
String? gender; String? gender;
var doctorNameVariable;
List<GetConnectedDoctorsModel> connectedDoctorsListOriginal = [];
Future<void> getAllConnectedDoctors() async {
try {
var response = await AppSettings.getAllConnectedDoctors();
setState(() {
connectedDoctorsListOriginal = ((jsonDecode(response)) as List)
.map((dynamic model) {
return GetConnectedDoctorsModel.fromJson(model);
}).toList();
//connectedDoctorsListOriginal=connectedDoctorsListOriginal.reversed.toList();
//dateItemsVariable=connectedDoctorsListOriginal[0].doctor_name;
});
} catch (e) {
AppSettings.longFailedToast('There is an issue please wait some time');
}
}
@override
void initState() {
getAllConnectedDoctors();
super.initState();
}
Future pickImageFromGallery() async { Future pickImageFromGallery() async {
imageFileList = []; imageFileList = [];
@ -120,39 +149,6 @@ class _AddReportsState extends State<AddReports> {
} }
} }
/*Future pickImageFromGalleryForUpdate() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.updateFindingsGallery(imageFileList,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['findings'];
});
}
Future takeImageFromCameraForUpdate() async {
try {
final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return;
final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.updateFindingsCamera(image,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['findings'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}*/
Future takeImageFromCameraForReports() async { Future takeImageFromCameraForReports() async {
try { try {
final image = await _picker.pickImage(source: ImageSource.camera); final image = await _picker.pickImage(source: ImageSource.camera);
@ -227,8 +223,6 @@ class _AddReportsState extends State<AddReports> {
}); });
} }
Future takeImageFromCameraForPrescriptions() async { Future takeImageFromCameraForPrescriptions() async {
try { try {
final image = await _picker.pickImage(source: ImageSource.camera); final image = await _picker.pickImage(source: ImageSource.camera);
@ -348,7 +342,7 @@ class _AddReportsState extends State<AddReports> {
return WillPopScope( return WillPopScope(
onWillPop: () async => onWillPop(), onWillPop: () async => onWillPop(),
child: Scaffold( child: Scaffold(
appBar: AppSettings.appBar('Reports'), appBar: AppSettings.appBar('Add Record'),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Container( child: Container(
child: Padding( child: Padding(
@ -356,7 +350,57 @@ class _AddReportsState extends State<AddReports> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container( Container(child: DropdownButtonFormField(
// Initial Value
value: doctorNameVariable,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Select Doctor',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Please Select Doctor'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: connectedDoctorsListOriginal.map((items) {
return DropdownMenuItem(
value: items,
child: Text(
items.doctor_name,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: ( newValue) {
setState(() {
doctorNameVariable = newValue;
});
},
),),
SizedBox(
height: MediaQuery.of(context).size.height * .02,
),
/* Container(
child: TextFormField( child: TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
controller: doctorNameController, controller: doctorNameController,
@ -379,7 +423,7 @@ class _AddReportsState extends State<AddReports> {
), ),
SizedBox( SizedBox(
height: MediaQuery.of(context).size.height * .02, height: MediaQuery.of(context).size.height * .02,
), ),*/
Container( Container(
child: TextFormField( child: TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
@ -436,6 +480,41 @@ class _AddReportsState extends State<AddReports> {
}, },
), ),
), ),
SizedBox(
height: MediaQuery.of(context).size.height * .02,
),
Text('Select Problem Category',style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 14),),
Row(
children: [
Expanded(
child: RadioListTile(
title: Text("General"),
value: "general",
groupValue: problemCategory,
activeColor: primaryColor,
onChanged: (value) {
setState(() {
problemCategory = value.toString();
});
},
),
),
Expanded(
child: RadioListTile(
title: Text("Confidential"),
value: "confidential",
groupValue: problemCategory,
activeColor: primaryColor,
onChanged: (value) {
setState(() {
problemCategory = value.toString();
});
},
),
),
],
),
Text('Select Problem For',style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 14),),
Row( Row(
children: [ children: [
Expanded( Expanded(
@ -466,6 +545,7 @@ class _AddReportsState extends State<AddReports> {
), ),
], ],
), ),
Visibility( Visibility(
visible: visible:
prescriptionFor.toString().toLowerCase() == 'others', prescriptionFor.toString().toLowerCase() == 'others',
@ -1107,10 +1187,9 @@ class _AddReportsState extends State<AddReports> {
onPrimary: Colors.black, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () async { onPressed: () async {
if (doctorNameController.text != '' && if (problemController.text != '' &&
problemController.text != '' &&
dateInput.text != '' && dateInput.text != '' &&
prescriptionFor != '') { prescriptionFor != ''&&problemCategory!='') {
String _name = ''; String _name = '';
String _age = ''; String _age = '';
String? _gender = ''; String? _gender = '';
@ -1139,16 +1218,15 @@ class _AddReportsState extends State<AddReports> {
var payload = new Map<String, dynamic>(); var payload = new Map<String, dynamic>();
payload["problem"] = payload["problem"] =
problemController.text.toString(); problemController.text.toString();
payload["doctorName"] = payload["doctorName"] = doctorNameVariable.doctor_name.toString();
doctorNameController.text.toString(); payload["hospitalName"] = doctorNameVariable.hospital_name.toString();
payload["hospitalName"] = payload["doctorId"] = doctorNameVariable.doctor_id.toString();
hospitalNameController.text.toString();
payload["date"] = dateInput.text.toString(); payload["date"] = dateInput.text.toString();
payload["findings_date"] = ''; payload["findings_date"] = '';
payload["reports_date"] = ''; payload["reports_date"] = '';
payload["prescription_date"] = ''; payload["prescription_date"] = '';
payload["patientType"] = payload["patientType"] = prescriptionFor.toString();
prescriptionFor.toString(); payload["problemCategory"] = problemCategory.toString();
payload["others"] = { payload["others"] = {
"name": _name, "name": _name,
"age": int.parse(_age), "age": int.parse(_age),

@ -159,8 +159,7 @@ class _AllReportsTabState extends State<AllReportsTab>
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Expanded( Expanded(child: GridView.builder(
child: GridView.builder(
itemCount: widget.recordDetails.findingsImages.length, itemCount: widget.recordDetails.findingsImages.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, crossAxisCount: 3,

@ -9,6 +9,7 @@ import 'package:healthcare_user/howareufeeling_today.dart';
import 'package:healthcare_user/invitations/invitations.dart'; import 'package:healthcare_user/invitations/invitations.dart';
import 'package:healthcare_user/medicines.dart'; import 'package:healthcare_user/medicines.dart';
import 'package:healthcare_user/my_connections/all_connections.dart'; import 'package:healthcare_user/my_connections/all_connections.dart';
import 'package:healthcare_user/my_connections/dynamic_code_doctor.dart';
import 'package:healthcare_user/my_health.dart'; import 'package:healthcare_user/my_health.dart';
import 'package:healthcare_user/my_medicine_timings.dart'; import 'package:healthcare_user/my_medicine_timings.dart';
import 'package:healthcare_user/prescriptions/prescriptions.dart'; import 'package:healthcare_user/prescriptions/prescriptions.dart';
@ -641,8 +642,6 @@ class _DashboardState extends State<Dashboard> {
), ),
Container( Container(
/*height:MediaQuery.of(context).size.height * 2.500,
width: MediaQuery.of(context).size.height * .05,*/
child: AppSettings.qrCode==''?TextButton( child: AppSettings.qrCode==''?TextButton(
child: Text( child: Text(
'GetQR', 'GetQR',
@ -660,13 +659,11 @@ class _DashboardState extends State<Dashboard> {
var valueResponse = jsonDecode(value); var valueResponse = jsonDecode(value);
String dataUri = jsonDecode(value)['qrCodeData']; String dataUri = jsonDecode(value)['qrCodeData'];
// Split the data URI at the comma to extract the Base64 part
List<String> parts = dataUri.split(","); List<String> parts = dataUri.split(",");
String? base64String = parts.length == 2 ? parts[1] : null; String? base64String = parts.length == 2 ? parts[1] : null;
if (base64String != null) { if (base64String != null) {
// Now, you have the Base64-encoded image data in the 'base64String' variable
// You can use this 'base64String' in your Flutter code as needed
print(base64String); print(base64String);
AppSettings.qrCode=base64String; AppSettings.qrCode=base64String;
} else { } else {
@ -978,6 +975,35 @@ class _DashboardState extends State<Dashboard> {
Divider( Divider(
color: Colors.grey, color: Colors.grey,
), ),
ListTile(
title: Row(
children: [
Image(
image: const AssetImage('images/updatemylocation.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('Dynamic Code',
style: drawerListItemsTextStyle()),
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DynamicCode()),
);
},
),
Divider(
color: Colors.grey,
),
ListTile( ListTile(
title: Row( title: Row(
children: [ children: [

@ -311,6 +311,10 @@ class AppSettings {
static String addReportMySelfProblemUrl = host + 'insertReport'; static String addReportMySelfProblemUrl = host + 'insertReport';
static String getAllReportProblemDetalisUrl = host + 'userreport'; static String getAllReportProblemDetalisUrl = host + 'userreport';
static String deleteReportMySelfProblemUrl = host + 'deleteReportProblem'; static String deleteReportMySelfProblemUrl = host + 'deleteReportProblem';
static String getAllConnectedDoctorsDataUrl = host + 'connected-doctors';
static String addDoctorUrl = host + 'user/connect-doctors';
static String getDynamicCodeDataUrl = host + 'getDoctorInfo';
@ -1103,8 +1107,6 @@ class AppSettings {
} }
static Future<String> uploadVideoInReportMySelf(file) async { static Future<String> uploadVideoInReportMySelf(file) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
'POST', Uri.parse(reportMySelfVideoUploadUrl + '/' + customerId)); 'POST', Uri.parse(reportMySelfVideoUploadUrl + '/' + customerId));
@ -1801,6 +1803,86 @@ class AppSettings {
} }
} }
static Future<String> getAllConnectedDoctors() async {
var uri = Uri.parse(getAllConnectedDoctorsDataUrl + '/' + customerId);
//uri = uri.replace(query: 'customerId=$customerId');
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<bool> addDoctor(payload) async {
var uri = Uri.parse(addDoctorUrl + '/' + customerId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
try {
var _response = json.decode(response.body);
print(_response);
return true;
} catch (e) {
// display error toast
return false;
}
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
static Future<String> getDynamicCode() async {
var uri = Uri.parse(getDynamicCodeDataUrl + '/' + customerId);
//uri = uri.replace(query: 'customerId=$customerId');
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
/*Apis ends here*/ /*Apis ends here*/

@ -0,0 +1,18 @@
class DynamicCodeModel {
String doctorId = '';
String dynamicCode = '';
String recordId = '';
DynamicCodeModel();
factory DynamicCodeModel.fromJson(Map<String, dynamic> json){
DynamicCodeModel rtvm = new DynamicCodeModel();
rtvm.doctorId = json['doctorId'] ?? '';
rtvm.dynamicCode= json['dynamicCode']??'';
rtvm.recordId= json['recordId']??'';
return rtvm;
}
}

@ -0,0 +1,30 @@
class GetConnectedDoctorsModel {
String doctor_name='';
String doctor_id='';
String specialization='';
String qualification='';
String practiceplace1='';
String practiceplace2='';
String practiceplace3='';
String hospital_name='';
GetConnectedDoctorsModel();
factory GetConnectedDoctorsModel.fromJson(Map<String, dynamic> json){
GetConnectedDoctorsModel rtvm = new GetConnectedDoctorsModel();
rtvm.doctor_name = json['doctorName'] ?? '';
rtvm.specialization = json['specialization'] ?? '';
rtvm.qualification = json['qualification'] ?? '';
rtvm.doctor_id = json['doctorId'] ?? '';
rtvm.hospital_name = json['placeOfPractice'][0]['hospitalName'] ?? '';
return rtvm;
}
}

@ -0,0 +1,161 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
class AddDoctor extends StatefulWidget {
const AddDoctor({Key? key}) : super(key: key);
@override
State<AddDoctor> createState() => _AddDoctorState();
}
class _AddDoctorState extends State<AddDoctor> {
bool isPwdObscureText=true;
bool isFirstAddButtonShow=false;
bool isSecondAddButtonShow=false;
bool is2ndPlaceOfPracticeControllerVisible=false;
bool is3rdPlaceOfPracticeControllerVisible=false;
bool isConfirmPwdObscureText=true;
TextEditingController doctorIdController = TextEditingController();
String? gender;
List placeOfPractices=[];
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
bool isQrScannerVisible=false;
String doctorId='';
@override
void initState() {
super.initState();
}
Future<void> scanQR() async {
String barcodeScanRes;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
'#ff6666', 'Cancel', true, ScanMode.QR);
print(barcodeScanRes);
setState(() {
doctorId=jsonDecode(barcodeScanRes)['doctorId'];
doctorIdController.text=doctorId;
});
} on PlatformException {
barcodeScanRes = 'Failed to get platform version.';
}}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppSettings.appBar('Add Doctor'),
body: Stack(children: <Widget>[
GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
},
child: SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
SizedBox(
height:MediaQuery.of(context).size.height * .02,
),
Container(
child: Column(
children: [
IconButton(
onPressed: (){
scanQR();
},
icon: Icon(
Icons.qr_code_scanner,
color: primaryColor,
),
),
Text('Scan Qr Code',style: TextStyle(fontSize: 12,color: secondaryColor),)
],
)
),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Container(
child: TextFormField(
cursorColor: greyColor,
controller: doctorIdController,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Doctor Id',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),//name
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Container(
width:double.infinity,
height: MediaQuery.of(context).size.height * .06,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () async{
if(doctorIdController.text!=''){
AppSettings.preLoaderDialog(context);
var payload = new Map<String, dynamic>();
payload["doctorId"] =doctorIdController.text.toString();
bool status = await AppSettings.addDoctor(payload);
if(status){
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longSuccessToast('Doctor added successfully');
Navigator.pop(context);
}
else{
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('There is a problem for adding doctor');
}
}
else{
AppSettings.longFailedToast('Please enter valid details');
}
},
child: Text('Add Doctor'),
)
),
],
),
)
)),
),
]));
}
}

@ -1,5 +1,8 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/models/get_connected_doctors_model.dart';
import 'package:healthcare_user/my_connections/add-doctor.dart';
class AllConnections extends StatefulWidget { class AllConnections extends StatefulWidget {
const AllConnections({Key? key}) : super(key: key); const AllConnections({Key? key}) : super(key: key);
@ -8,12 +11,273 @@ class AllConnections extends StatefulWidget {
State<AllConnections> createState() => _AllConnectionsState(); State<AllConnections> createState() => _AllConnectionsState();
} }
class _AllConnectionsState extends State<AllConnections> { class _AllConnectionsState extends State<AllConnections>
with TickerProviderStateMixin {
late TabController _controller;
bool isConnectedDoctorsDataLoading=false;
bool isSereverIssue=false;
final List<Tab> topTabs = <Tab>[
Tab(
child: Text(
'Doctors',
style: TextStyle(fontSize: 14),
)),
Tab(
child: Text(
'Pharmacies',
style: TextStyle(fontSize: 14),
)),
];
List<GetConnectedDoctorsModel> connectedDoctorsListOriginal = [];
@override
void initState() {
_controller = TabController(vsync: this, length: topTabs.length);
getAllConnectedDoctors();
super.initState();
}
Future<void> getAllConnectedDoctors() async {
isConnectedDoctorsDataLoading=true;
try {
var response = await AppSettings.getAllConnectedDoctors();
setState(() {
connectedDoctorsListOriginal = ((jsonDecode(response)) as List)
.map((dynamic model) {
return GetConnectedDoctorsModel.fromJson(model);
}).toList();
connectedDoctorsListOriginal=connectedDoctorsListOriginal.reversed.toList();
isConnectedDoctorsDataLoading = false;
});
} catch (e) {
setState(() {
isConnectedDoctorsDataLoading = false;
isSereverIssue = true;
});
}
}
Widget _doctors(){
if(connectedDoctorsListOriginal.length!=0){
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: connectedDoctorsListOriginal.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: (){
},
child: Card(
//color: prescriptionsList[index].cardColor,
child: Padding(
padding:EdgeInsets.all(8) ,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
child: Row(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Doctor Name',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
'Hospital',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
'Specialization',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
'Qualification',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
],
),
SizedBox(width:MediaQuery.of(context).size.width * .01,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
':',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
':',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
':',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
':',
style: labelTextStyle(),
),
],
),
SizedBox(width:MediaQuery.of(context).size.width * .01,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(connectedDoctorsListOriginal[index].doctor_name.toString().toUpperCase(),style: valuesTextStyle()),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
connectedDoctorsListOriginal[index].hospital_name,
style: valuesTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
connectedDoctorsListOriginal[index].specialization,
style: valuesTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
connectedDoctorsListOriginal[index].qualification,
style: valuesTextStyle(),
),
],
),
],
),
),
],
),
],
),
),
),
);
});
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('Click below icon to add new doctor'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.white,
),
onPressed: () async {
Navigator.push(context, MaterialPageRoute(builder: (context) => AddDoctor())).then((value) {
getAllConnectedDoctors();
});
},
),
)
],
),
)
);
}
}
Widget _pharmacies(){
return Container();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppSettings.appBar('My Connections'), appBar: AppBar(
body: Container(), title: Text('My Connections'),
backgroundColor: primaryColor,
bottom: TabBar(
controller: _controller,
tabs: topTabs,
indicatorColor: buttonColors,
unselectedLabelColor: Colors.white60,
indicatorWeight: 2,
),
),
body: Container(
child: TabBarView(controller: _controller, children: [
Padding(padding: EdgeInsets.all(10),
child:isConnectedDoctorsDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
): _doctors(),
),
Padding(
padding: EdgeInsets.all(10),
)
]),
),
floatingActionButton: Visibility(
visible:connectedDoctorsListOriginal.length!=0,
child: CircleAvatar(
backgroundColor: buttonColors,
radius: 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.black,
),
onPressed: () async{
Navigator.push(context, MaterialPageRoute(builder: (context) => AddDoctor())).then((value) {
getAllConnectedDoctors();
});
},
),
],
),
),
),
); );
} }
} }

@ -0,0 +1,281 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/models/dynamic_code_model.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class DynamicCode extends StatefulWidget {
const DynamicCode({Key? key}) : super(key: key);
@override
State<DynamicCode> createState() => _DynamicCodeState();
}
class _DynamicCodeState extends State<DynamicCode> {
bool isDataLoading=false;
bool isSereverIssue = false;
List<DynamicCodeModel> originalList = [];
List<String> items = ["1", "2", "3", "4", "5", "6", "7", "8"];
RefreshController _refreshController =
RefreshController(initialRefresh: true);
@override
void initState() {
getAllDynamicCodes();
super.initState();
}
Future<void> getAllDynamicCodes() async {
isDataLoading=true;
try {
var response = await AppSettings.getDynamicCode();
setState(() {
originalList = ((jsonDecode(response)) as List)
.map((dynamic model) {
return DynamicCodeModel.fromJson(model);
}).toList();
originalList=originalList.reversed.toList();
isDataLoading = false;
});
} catch (e) {
setState(() {
isDataLoading = false;
isSereverIssue = true;
});
}
}
void _onRefresh() async{
// monitor network fetch
await Future.delayed(Duration(milliseconds: 1000));
// if failed,use refreshFailed()
/*items.remove((items.length-1).toString());
if(mounted)
setState(() {
});*/
await getAllDynamicCodes();
_refreshController.refreshCompleted(
resetFooterState: true,
);
}
void _onLoading() async{
// monitor network fetch
await Future.delayed(Duration(milliseconds: 1000));
// if failed,use loadFailed(),if no data return,use LoadNodata()
items.add((items.length+1).toString());
if(mounted)
setState(() {
});
_refreshController.loadComplete();
}
Widget _renderUi(){
if(originalList.length!=0){
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: originalList.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: (){
},
child: Card(
//color: prescriptionsList[index].cardColor,
child: Padding(
padding:EdgeInsets.all(8) ,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
child: Row(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Doctor Id',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
'Dynamic code',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
'Record Id',
style: labelTextStyle(),
),
],
),
SizedBox(width:MediaQuery.of(context).size.width * .01,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
':',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
':',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
':',
style: labelTextStyle(),
),
],
),
SizedBox(width:MediaQuery.of(context).size.width * .01,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(originalList[index].doctorId.toString().toUpperCase(),style: valuesTextStyle()),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
originalList[index].dynamicCode,
style: valuesTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Text(
originalList[index].recordId,
style: valuesTextStyle(),
),
],
),
],
),
),
],
),
],
),
),
),
);
});
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('No Dynamic Codes available'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.info,
color: Colors.white,
),
onPressed: () async {
},
),
)
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Dynamic Code'),
body: SmartRefresher(
enablePullDown: true,
enablePullUp: false,
/* header: WaterDropHeader(
waterDropColor: primaryColor,
),*/
header: CustomHeader(
builder: (BuildContext context, RefreshStatus? mode) {
return Container(
child: Center(
child: CircularProgressIndicator(
// Set the color of the circular progress indicator
valueColor: AlwaysStoppedAnimation<Color>(primaryColor),
),
),
);
},
),
footer: CustomFooter(
builder: (BuildContext context,LoadStatus? mode){
Widget body ;
if(mode==LoadStatus.idle){
body = Text("pull up load");
}
else if(mode==LoadStatus.loading){
body = Container();
}
else if(mode == LoadStatus.failed){
body = Text("Load Failed!Click retry!");
}
else if(mode == LoadStatus.canLoading){
body = Text("release to load more");
}
else{
body = Text("No more Data");
}
return Container(
height: 55.0,
child: Center(child:body),
);
},
),
controller: _refreshController,
onRefresh: _onRefresh,
onLoading: _onLoading,
child:_renderUi()
/*ListView.builder(
itemBuilder: (c, i) => Card(child: Center(child: Text(items[i]))),
itemExtent: 100.0,
itemCount: items.length,
),*/
),
);
}
}

@ -370,6 +370,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_barcode_scanner:
dependency: "direct main"
description:
name: flutter_barcode_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter_cupertino_datetime_picker: flutter_cupertino_datetime_picker:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1052,6 +1059,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.5" version: "6.0.5"
pull_to_refresh:
dependency: "direct main"
description:
name: pull_to_refresh
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
qr: qr:
dependency: transitive dependency: transitive
description: description:
@ -1059,6 +1073,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
qr_code_scanner:
dependency: "direct main"
description:
name: qr_code_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
qr_flutter: qr_flutter:
dependency: "direct main" dependency: "direct main"
description: description:

@ -64,6 +64,10 @@ dependencies:
flutter_share: ^2.0.0 flutter_share: ^2.0.0
share: ^2.0.4 share: ^2.0.4
qr_flutter: ^4.0.0 qr_flutter: ^4.0.0
qr_code_scanner: ^1.0.1
flutter_barcode_scanner: ^2.0.0
pull_to_refresh: ^2.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save