qr code generator and share completed

master
Sneha 1 year ago
parent eb3d18efa3
commit c331f12bcc

@ -10,6 +10,7 @@ import 'package:healthcare_user/Reports/update_report.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/reports_model.dart'; import 'package:healthcare_user/models/reports_model.dart';
import 'package:healthcare_user/report_problem/all-records_onclick_new.dart';
import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -29,7 +30,11 @@ class _AllReportsState extends State<AllReports> {
bool isSereverIssue = false; bool isSereverIssue = false;
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
TextEditingController dateInput = TextEditingController(); TextEditingController dateInput = TextEditingController();
TextEditingController fromdateController = TextEditingController();
TextEditingController todateController = TextEditingController();
DateTime fromDate=DateTime.now();
String dropdownSearchType = 'Problem'; String dropdownSearchType = 'Problem';
String? searchBy;
var typeOfSearchItems = [ var typeOfSearchItems = [
'Problem', 'Problem',
'Doctor', 'Doctor',
@ -133,9 +138,57 @@ class _AllReportsState extends State<AllReports> {
} }
} }
Future<void> getRecordsByDateRange(var fromDate,var toDate) async {
isReportsDataLoading = true;
try {
var response = await AppSettings.getAllRecords();
setState(() {
reportsListOriginal = ((jsonDecode(response)) as List)
.map((dynamic model) {
return ReportsModel.fromJson(model);
}).toList();
reportsList=reportsListOriginal.reversed.toList();
var dateToCheck = DateTime.now().add(Duration(days: -1));
reportsList = reportsListOriginal.reversed.where((product) {
final date = product.dateForFilter;
final startDate =DateFormat('dd-MM-yyyy').parse(fromDate);
final endDate = DateFormat('dd-MM-yyyy').parse(toDate);
return date.isAfter(startDate) && date.isBefore(endDate);
//reportsList=reportsListOriginal.reversed.toList();
}).toList();
/*if( dateToCheck.isAfter(startDate) && dateToCheck.isBefore(endDate))
{
print("dateToCheck is between now and lastYear");
}
else
{
print("dateToCheck is not between now and lastYear");
}*/
isReportsDataLoading = false;
});
} catch (e) {
setState(() {
isReportsDataLoading = false;
isSereverIssue = true;
});
}
}
@override @override
void initState() { void initState() {
getAllRecords(); getAllRecords();
var now = new DateTime.now();
String formattedDate = DateFormat('dd-MM-yyyy').format(now);
fromdateController.text=formattedDate;
todateController.text=formattedDate;
super.initState(); super.initState();
} }
@ -333,6 +386,7 @@ class _AllReportsState extends State<AllReports> {
Widget _filtereddata(){ Widget _filtereddata(){
if(reportsList.length!=0){ if(reportsList.length!=0){
reportsList.sort((a, b) => b.date.compareTo(a.date));
return ListView.builder( return ListView.builder(
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
itemCount: reportsList.length, itemCount: reportsList.length,
@ -343,7 +397,7 @@ class _AllReportsState extends State<AllReports> {
Navigator.push( Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
getAllRecords(); getAllRecords();
}); });
}, },
@ -470,18 +524,18 @@ class _AllReportsState extends State<AllReports> {
onPrimary: Colors.white, // foreground onPrimary: Colors.white, // foreground
), ),
onPressed: () async { onPressed: () async {
/*Navigator.push( Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) { builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
getAllRecords(); getAllRecords();
});*/ });
Navigator.push( /*Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
getAllRecords(); getAllRecords();
}); });*/
}, },
child: Text('Findings: '+reportsList[index].findingsImages.length.toString(),style:textButtonStyleReports(),), child: Text('Findings: '+reportsList[index].findingsImages.length.toString(),style:textButtonStyleReports(),),
), ),
@ -494,18 +548,18 @@ class _AllReportsState extends State<AllReports> {
onPrimary: Colors.white, // foreground onPrimary: Colors.white, // foreground
), ),
onPressed: () async { onPressed: () async {
/*Navigator.push( Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages,recordId:reportsList[index].recordId ,))).then((value) { builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
getAllRecords(); getAllRecords();
});*/ });
Navigator.push( /*Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 1,))).then((value) { builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 1,))).then((value) {
getAllRecords(); getAllRecords();
}); });*/
}, },
child: Text('Reports: '+reportsList[index].reportImages.length.toString(),style:textButtonStyleReports()), child: Text('Reports: '+reportsList[index].reportImages.length.toString(),style:textButtonStyleReports()),
@ -519,19 +573,19 @@ class _AllReportsState extends State<AllReports> {
onPrimary: Colors.white, // foreground onPrimary: Colors.white, // foreground
), ),
onPressed: () async { onPressed: () async {
/*Navigator.push( Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index],details:reportsList[index] ,))).then((value) { builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
getAllRecords(); getAllRecords();
});*/ });
Navigator.push( /*Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 2,))).then((value) { builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 2,))).then((value) {
getAllRecords(); getAllRecords();
}); });*/
}, },
child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString(),style:textButtonStyleReports()), child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString(),style:textButtonStyleReports()),
@ -596,7 +650,7 @@ class _AllReportsState extends State<AllReports> {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Container( /*Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: DropdownButtonFormField( child: DropdownButtonFormField(
// Initial Value // Initial Value
@ -640,9 +694,69 @@ class _AllReportsState extends State<AllReports> {
}); });
}, },
), ),
),*/
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.fromLTRB(10,10,0,0),
child: Text('Please select search option',style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 16),),),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: RadioListTile(
title: Text("Problem", style: TextStyle(fontSize: 10)),
value: "problem",
groupValue: searchBy,
activeColor: primaryColor,
onChanged: (value) {
setState(() {
searchBy = value.toString();
});
},
),
),
Expanded(
child: RadioListTile(
title: Text(
"Doctor",
style: TextStyle(fontSize: 10),
),
value: "doctor",
groupValue: searchBy,
activeColor: primaryColor,
onChanged: (value) {
setState(() {
searchBy = value.toString();
});
},
),
),
Expanded(
child: RadioListTile(
title:
Text("Date", style: TextStyle(fontSize: 10)),
value: "date",
groupValue: searchBy,
activeColor: primaryColor,
onChanged: (value) {
setState(() {
searchBy = value.toString();
});
},
),
),
],
),
],
)
), ),
Visibility( Visibility(
visible:dropdownSearchType.toString().toLowerCase()=='problem' , visible:searchBy.toString().toLowerCase()=='problem' ,
child: Container( child: Container(
height: MediaQuery.of(context).size.height * .07, height: MediaQuery.of(context).size.height * .07,
padding: EdgeInsets.all(5), padding: EdgeInsets.all(5),
@ -707,7 +821,7 @@ class _AllReportsState extends State<AllReports> {
),) ),)
),), ),),
Visibility( Visibility(
visible:dropdownSearchType.toString().toLowerCase()=='doctor' , visible:searchBy.toString().toLowerCase()=='doctor' ,
child: Container( child: Container(
height: MediaQuery.of(context).size.height * .07, height: MediaQuery.of(context).size.height * .07,
padding: EdgeInsets.all(5), padding: EdgeInsets.all(5),
@ -772,7 +886,204 @@ class _AllReportsState extends State<AllReports> {
),) ),)
),), ),),
Visibility( Visibility(
visible:dropdownSearchType.toString().toLowerCase()=='date' , visible:searchBy.toString().toLowerCase()=='date',
child: Container(
//height: 60,
padding: EdgeInsets.all(5),
child: Row(
children: [
Expanded(
child: TextField(
cursorColor: primaryColor,
controller: fromdateController,
onChanged: (string) {
if(string.length>=1){
//getRecordsByDate(string);
}
else{
getAllRecords();
}
},
onTap: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(1950),
lastDate: DateTime.now(),
builder: (BuildContext context, Widget? child) {
return Theme(
data: ThemeData.dark().copyWith(
colorScheme: ColorScheme.dark(
primary: buttonColors,
onPrimary: Colors.white,
surface: buttonColors,
onSurface: Colors.white,
),
dialogBackgroundColor: primaryColor,
),
child: child!,
);
},
);
if (pickedDate != null) {
print(pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
String formattedDate = DateFormat('dd-MM-yyyy').format(pickedDate);
print(formattedDate); //formatted date output using intl package => 2021-03-16
setState(() {
fromDate=pickedDate;
fromdateController.text = formattedDate; //set output date to TextField value.
});
getRecordsByDateRange(fromdateController.text,todateController.text);
} else {}
},
decoration: InputDecoration(
prefixIcon: Icon(
Icons.calendar_month,
color: primaryColor,
),
suffixIcon: fromdateController.text!=''?IconButton(
icon: Icon(
Icons.clear,
color: Colors.red,
),
onPressed: () {
setState(() {
fromdateController.text='';
});
getAllRecords();
},
):IconButton(
icon: Icon(
Icons.clear,
color: Colors.transparent,
),
onPressed: () {
},
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
//labelText: 'Search by phone number',
hintText: 'From date',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
SizedBox(width: 5),
Expanded(
child: TextField(
cursorColor: primaryColor,
controller: todateController,
onChanged: (string) {
if(string.length>=1){
//getRecordsByDate(string);
}
else{
getAllRecords();
}
},
onTap: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: fromDate,
lastDate: DateTime.now(),
builder: (BuildContext context, Widget? child) {
return Theme(
data: ThemeData.dark().copyWith(
colorScheme: ColorScheme.dark(
primary: buttonColors,
onPrimary: Colors.white,
surface: buttonColors,
onSurface: Colors.white,
),
dialogBackgroundColor: primaryColor,
),
child: child!,
);
},
);
if (pickedDate != null) {
print(
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
String formattedDate =
DateFormat('dd-MM-yyyy').format(pickedDate);
print(
formattedDate); //formatted date output using intl package => 2021-03-16
setState(() {
todateController.text = formattedDate; //set output date to TextField value.
});
getRecordsByDateRange(fromdateController.text,todateController.text);
} else {}
},
decoration: InputDecoration(
prefixIcon: Icon(
Icons.calendar_month,
color: primaryColor,
),
suffixIcon: todateController.text!=''?IconButton(
icon: Icon(
Icons.clear,
color: Colors.red,
),
onPressed: () {
setState(() {
todateController.text='';
});
getAllRecords();
},
):IconButton(
icon: Icon(
Icons.clear,
color: Colors.transparent,
),
onPressed: () {
},
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
//labelText: 'Search by phone number',
hintText: 'To date',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
SizedBox(width: 5),
],
),
),),
/*Visibility(
visible:searchBy.toString().toLowerCase()=='date' ,
child: Container( child: Container(
height: MediaQuery.of(context).size.height * .07, height: MediaQuery.of(context).size.height * .07,
padding: EdgeInsets.all(5), padding: EdgeInsets.all(5),
@ -870,45 +1181,9 @@ class _AllReportsState extends State<AllReports> {
), ),
), ),*/
Expanded(child: _filtereddata()), Expanded(child: _filtereddata()),
Padding(
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
child: CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.white,
),
onPressed: () async{
/*await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddPrescription()),
);*/
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
getAllRecords();
});
//showBoreAddingDialog();
},
),
/* Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
child: Text(
'Add Tanks ',
style: TextStyle(color: Colors.white),
),
)*/
],
),
),
),
]); ]);
@ -961,6 +1236,43 @@ class _AllReportsState extends State<AllReports> {
strokeWidth: 5.0, strokeWidth: 5.0,
), ),
): _allreports(), ): _allreports(),
floatingActionButton: Visibility(
visible:reportsListOriginal.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{
/*await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddPrescription()),
);*/
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
getAllRecords();
});
//showBoreAddingDialog();
},
),
/* Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
child: Text(
'Add Tanks ',
style: TextStyle(color: Colors.white),
),
)*/
],
),
),
),
); );
} }
} }

@ -2,11 +2,13 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:healthcare_user/Reports/allreports.dart'; import 'package:healthcare_user/Reports/allreports.dart';
import 'package:healthcare_user/common/qrcode_display.dart';
import 'package:healthcare_user/common/updateprofile.dart'; import 'package:healthcare_user/common/updateprofile.dart';
import 'package:healthcare_user/emergency.dart'; import 'package:healthcare_user/emergency.dart';
import 'package:healthcare_user/howareufeeling_today.dart'; 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_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';
@ -376,7 +378,11 @@ class _DashboardState extends State<Dashboard> {
fit: BoxFit.fitWidth)), fit: BoxFit.fitWidth)),
), ),
onTap: () { onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const AllConnections()),
);
}, },
), ),
Text( Text(
@ -556,18 +562,21 @@ class _DashboardState extends State<Dashboard> {
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: buttonColors, color: buttonColors,
), ),
child: Row( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Column( Expanded(child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Expanded( GestureDetector(
child: GestureDetector(
child: Container( child: Container(
width: MediaQuery.of(context).size.width * .20, width: MediaQuery.of(context).size.width * .20,
height: height:
MediaQuery.of(context).size.height * .15, MediaQuery.of(context).size.height * .15,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
image: DecorationImage( image: DecorationImage(
image: (AppSettings.profilePictureUrl != image: (AppSettings.profilePictureUrl !=
@ -578,8 +587,11 @@ class _DashboardState extends State<Dashboard> {
.profilePictureUrl) .profilePictureUrl)
as ImageProvider as ImageProvider
: AssetImage( : AssetImage(
"images/profile_pic.png"), // picked file "images/profile_pic.png"),
fit: BoxFit.fitWidth)),
fit:BoxFit.fitWidth // picked file
),
),
), ),
onTap: () { onTap: () {
showModalBottomSheet<void>( showModalBottomSheet<void>(
@ -627,7 +639,66 @@ class _DashboardState extends State<Dashboard> {
}); });
}, },
), ),
Container(
/*height:MediaQuery.of(context).size.height * 2.500,
width: MediaQuery.of(context).size.height * .05,*/
child: AppSettings.qrCode==''?TextButton(
child: Text(
'GetQR',
style: TextStyle(
fontSize: 15,
color: Colors.white,
decoration: TextDecoration.underline,
),
), ),
onPressed: () async{
AppSettings.preLoaderDialog(context);
try{
var value = await AppSettings.generateQRCode();
var valueResponse = jsonDecode(value);
String dataUri = jsonDecode(value)['qrCodeData'];
// Split the data URI at the comma to extract the Base64 part
List<String> parts = dataUri.split(",");
String? base64String = parts.length == 2 ? parts[1] : 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);
AppSettings.qrCode=base64String;
} else {
print("Invalid data URI");
}
Navigator.of(context, rootNavigator: true).pop();
}
catch(e){
Navigator.of(context, rootNavigator: true).pop();
}
},
):GestureDetector(
onTap: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DisplayQrCode()),
);
},
child: Container(
height:MediaQuery.of(context).size.height * .20,
width:MediaQuery.of(context).size.width * .1,
child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode))),
),
),
)
],
),),
Text( Text(
AppSettings.userName, AppSettings.userName,
style: drawerHeaderTextStyleNew(), style: drawerHeaderTextStyleNew(),
@ -662,10 +733,7 @@ class _DashboardState extends State<Dashboard> {
], ],
) )
], ],
), ),),
Container()
],
)),
ListTile( ListTile(
title: Row( title: Row(
children: [ children: [

@ -0,0 +1,124 @@
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:flutter_share/flutter_share.dart';
import 'package:share/share.dart';
import 'dart:typed_data';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;
import 'package:qr_flutter/qr_flutter.dart';
class DisplayQrCode extends StatefulWidget {
const DisplayQrCode({Key? key}) : super(key: key);
@override
State<DisplayQrCode> createState() => _DisplayQrCodeState();
}
class _DisplayQrCodeState extends State<DisplayQrCode> {
Future<void> share(var qr) async {
await FlutterShare.share(
title: 'Example share',
text: 'Example share text',
linkUrl: qr,
chooserTitle: 'Example Chooser Title');
}
Future<void> shareQRCodeImage1(qrData) async {
final tempDir = await getTemporaryDirectory();
final file = File('${tempDir.path}/qr_code.png');
await file.writeAsBytes(Uint8List.fromList(base64.decode(qrData)));
// Share the image using the share package
Share.shareFiles([file.path], text: 'Check out this QR code');
}
String imagePath = '';
Future<void> downloadQRImage() async {
final response = await http.get(Uri.parse(AppSettings.qrCode));
if (response.statusCode == 200) {
final directory = await getApplicationDocumentsDirectory();
final filePath = '${directory.path}/qr_image.png';
final File file = File(filePath);
await file.writeAsBytes(response.bodyBytes);
setState(() {
imagePath = filePath;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Qr Code'),
body: Container(
child: Padding(padding: EdgeInsets.all(10),
child: Column(
children: [
Center(
child: Container(
padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
width: MediaQuery.of(context).size.width * .60, // Set the desired width
height: MediaQuery.of(context).size.height * .35, // Set the desired height
child:
Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),),
fit: BoxFit.fill),
),
),
SizedBox(
height:MediaQuery.of(context).size.height * .05,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () {
//share(AppSettings.qrCode);
shareQRCodeImage1(AppSettings.qrCode);
},
icon: Icon(
Icons.share,
color: primaryColor,
size: 40,
),
),
/*IconButton(
onPressed: () {
downloadQRImage();
},
icon: Icon(
Icons.download,
color: primaryColor,
size: 40,
),
),*/
],
)
/*Container(
padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
child: Center(child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),),),),
)*/
],
),),
),
);
}
}

@ -228,6 +228,7 @@ class AppSettings {
SharedPreferences.getInstance() as SharedPreferences; SharedPreferences.getInstance() as SharedPreferences;
static String userName = ''; static String userName = '';
static String userAddress = ''; static String userAddress = '';
static String detailedAddress = '';
static String email = ''; static String email = '';
static String age = ''; static String age = '';
static String gender = ''; static String gender = '';
@ -249,6 +250,8 @@ class AppSettings {
static String long = "", lat = ""; static String long = "", lat = "";
late StreamSubscription<Position> positionStream; late StreamSubscription<Position> positionStream;
static String fcmId = ''; static String fcmId = '';
static String originalQrCode = '';
static String qrCode = '';
static String serverToken = static String serverToken =
'AAAAA66BLaA:APA91bHcmbyiNN8hCL-t-M9oH-u7ZMOl74fcImMM2DQZLgdyY98Wu9XxME-CTPcjpjU6Yy48ouxISrOMb9lpa3PJofh8qciUKMNxV2al-bDvGvPP_VVaH0mrTHzR56hdkGy1Zl-0frDO'; 'AAAAA66BLaA:APA91bHcmbyiNN8hCL-t-M9oH-u7ZMOl74fcImMM2DQZLgdyY98Wu9XxME-CTPcjpjU6Yy48ouxISrOMb9lpa3PJofh8qciUKMNxV2al-bDvGvPP_VVaH0mrTHzR56hdkGy1Zl-0frDO';
@ -256,6 +259,7 @@ class AppSettings {
static String host = 'http://35.200.129.165:4000/api/'; static String host = 'http://35.200.129.165:4000/api/';
static String loginUrl = host + 'login'; static String loginUrl = host + 'login';
static String signUpUrl = host + 'users'; static String signUpUrl = host + 'users';
static String generateQRCodeUrl = host + 'generate-qrcode';
static String sendSmsUrl = host + 'sendSms'; static String sendSmsUrl = host + 'sendSms';
static String phoneVerificationUrl = host + 'phone'; static String phoneVerificationUrl = host + 'phone';
static String verifyPhnUrl = host + 'phone'; static String verifyPhnUrl = host + 'phone';
@ -471,6 +475,30 @@ class AppSettings {
} }
} }
static Future<String> generateQRCode() async {
var uri = Uri.parse(generateQRCodeUrl + '/' + customerId);
var response = await http.post(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<bool> sendSms(payload) async { static Future<bool> sendSms(payload) async {
var response = await http.post(Uri.parse(sendSmsUrl), var response = await http.post(Uri.parse(sendSmsUrl),
body: json.encode(payload), body: json.encode(payload),
@ -481,7 +509,6 @@ class AppSettings {
return false; return false;
} }
} }
static Future<bool> phoneVerification(payload) async { static Future<bool> phoneVerification(payload) async {
var response = await http.post(Uri.parse(phoneVerificationUrl), var response = await http.post(Uri.parse(phoneVerificationUrl),
body: json.encode(payload), body: json.encode(payload),
@ -1789,11 +1816,13 @@ class AppSettings {
await saveData('customerId', input['simplydata']['customerId'], 'STRING'); await saveData('customerId', input['simplydata']['customerId'], 'STRING');
await saveData('profile', input['simplydata']['picture'], 'STRING'); await saveData('profile', input['simplydata']['picture'], 'STRING');
await saveData('user_address', input['simplydata']['address1'], 'STRING'); await saveData('user_address', input['simplydata']['address1'], 'STRING');
await saveData('detailedAddress', input['simplydata']['address2'], 'STRING');
await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE'); await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE');
await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE'); await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE');
await saveData('fcmId', input['simplydata']['fcmId'], 'STRING'); await saveData('fcmId', input['simplydata']['fcmId'], 'STRING');
await saveData('age', input['simplydata']['age'], 'STRING'); await saveData('age', input['simplydata']['age'], 'STRING');
await saveData('gender', input['simplydata']['gender'], 'STRING'); await saveData('gender', input['simplydata']['gender'], 'STRING');
await saveData('qrCode', input['simplydata']['qrCode'], 'STRING');
//await saveData('age', input['simplydata']['age'], 'STRING'); //await saveData('age', input['simplydata']['age'], 'STRING');
//latitude,longitude //latitude,longitude
await loadDataFromMemory(); await loadDataFromMemory();
@ -1814,6 +1843,7 @@ class AppSettings {
accessToken = await getData('access_token', 'STRING'); accessToken = await getData('access_token', 'STRING');
email = await getData('email', 'STRING'); email = await getData('email', 'STRING');
userAddress = await getData('user_address', 'STRING'); userAddress = await getData('user_address', 'STRING');
detailedAddress= await getData('detailedAddress', 'STRING');
phoneNumber = await getData('phone', 'STRING'); phoneNumber = await getData('phone', 'STRING');
customerId = await getData('customerId', 'STRING'); customerId = await getData('customerId', 'STRING');
userLatitude = await getData('latitude', 'DOUBLE'); userLatitude = await getData('latitude', 'DOUBLE');
@ -1822,6 +1852,18 @@ class AppSettings {
fcmId = await getData('fcmId', 'STRING'); fcmId = await getData('fcmId', 'STRING');
age = await getData('age', 'STRING'); age = await getData('age', 'STRING');
gender = await getData('gender', 'STRING'); gender = await getData('gender', 'STRING');
originalQrCode = await getData('qrCode', 'STRING');
String dataUri = originalQrCode;
// Split the data URI at the comma to extract the Base64 part
List<String> parts = dataUri.split(",");
String? base64String = parts.length == 2 ? parts[1] : null;
if (base64String != null) {
qrCode=base64String;
} else {
print("Invalid data URI");
}
} }

@ -441,7 +441,7 @@ class _SignUpState extends State<SignUp> {
]; ];
payload["lastName"] = ''; payload["lastName"] = '';
payload["address1"] = userAddressCapturingController.text; payload["address1"] = userAddressCapturingController.text;
payload["address2"] = ''; payload["address2"] = userAddressDescriptionController.text;
payload["city"] = ''; payload["city"] = '';
payload["state"] = ''; payload["state"] = '';
payload["zip"] = ''; payload["zip"] = '';

@ -284,34 +284,24 @@ class _EditMedicineTimingsState extends State<EditMedicineTimings> {
child: ListView.separated( child: ListView.separated(
separatorBuilder: (context, index) => const Divider( separatorBuilder: (context, index) => const Divider(
height: 4.0, height: 4.0,
color: primaryColor, color: Colors.transparent,
), ),
//padding: EdgeInsets.all(8), //padding: EdgeInsets.all(8),
itemCount: timings.length, itemCount: timings.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return GestureDetector(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width:
MediaQuery.of(context).size.width * .40,
child: Text(
timings[index]['name'],
style: wrapTextStyle(),
),
),
GestureDetector(
onTap: () { onTap: () {
Navigator.of(context).push( Navigator.of(context).push(
showPicker( showPicker(
showSecondSelector: true, showSecondSelector: true,
accentColor: primaryColor,
okStyle: TextStyle(color: primaryColor,fontWeight: FontWeight.bold),
cancelStyle: TextStyle(color: Colors.red,fontWeight: FontWeight.bold),
barrierDismissible: false,
blurredBackground: true,
borderRadius: 20,
disableAutoFocusToNextInput: true,
displayHeader: true,
context: context, context: context,
value: _time, value: _time,
//onChange: onTimeChanged, //onChange: onTimeChanged,
@ -331,17 +321,37 @@ class _EditMedicineTimingsState extends State<EditMedicineTimings> {
), ),
); );
}, },
child: Image( child: Card(
child: Padding(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width:
MediaQuery.of(context).size.width * .40,
child: Text(
timings[index]['name'],
style: wrapTextStyle(),
),
),
Image(
image: AssetImage('images/time.png'), image: AssetImage('images/time.png'),
width: 30, width: 30,
height: 30, height: 30,
), ),
),
textForSelectedTime(index) textForSelectedTime(index)
], ],
), ),
], ],
)), )),
),
),
); );
})), })),
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40), Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40),
@ -400,16 +410,54 @@ class _EditMedicineTimingsState extends State<EditMedicineTimings> {
); );
} }
Future<bool> onWillPop() async {
final shouldPop = await showDialog<bool>(context: context, builder: (context) {
return AlertDialog(
title: const Text('Do you want to leave this page',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
},
child: const Text('Yes',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: const Text('No',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
),
],
);
},
);
return shouldPop!;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
onWillPop: () async => onWillPop(),
child:Scaffold(
appBar: AppSettings.appBar('Edit Medicine Timings'), appBar: AppSettings.appBar('Edit Medicine Timings'),
body: Container( body: Container(
child: //Text(widget.medicineTimings.toString()) child: //Text(widget.medicineTimings.toString())
renderTimings(), renderTimings(),
) )
//medicineTimings.length==0?renderUi():renderTimings(), //medicineTimings.length==0?renderUi():renderTimings(),
); ) ,);
} }
} }

@ -36,7 +36,7 @@ class _InvitationsState extends State<Invitations> {
cursorColor: greyColor, cursorColor: greyColor,
controller: nameController, controller: nameController,
decoration: textFormFieldDecoration( decoration: textFormFieldDecoration(
Icons.phone, 'Enter Name'), Icons.person, 'Enter Name'),
), ),
), ),
SizedBox( SizedBox(

@ -1,5 +1,6 @@
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:intl/intl.dart';
class ReportsModel { class ReportsModel {
String patient_name=''; String patient_name='';
@ -14,6 +15,7 @@ class ReportsModel {
List findingsImages = []; List findingsImages = [];
List reportImages = []; List reportImages = [];
List prescriptionImages = []; List prescriptionImages = [];
DateTime dateForFilter=new DateTime.now();
ReportsModel(); ReportsModel();
@ -29,6 +31,7 @@ class ReportsModel {
rtvm.findingsImages = json['findings'] ?? []; rtvm.findingsImages = json['findings'] ?? [];
rtvm.reportImages = json['reports'] ?? []; rtvm.reportImages = json['reports'] ?? [];
rtvm.prescriptionImages = json['prescription'] ?? []; rtvm.prescriptionImages = json['prescription'] ?? [];
rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.date);
if(rtvm.patient_type.toString().toLowerCase()=='self'){ if(rtvm.patient_type.toString().toLowerCase()=='self'){
rtvm.age=AppSettings.age; rtvm.age=AppSettings.age;

@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:healthcare_user/common/settings.dart';
class AllConnections extends StatefulWidget {
const AllConnections({Key? key}) : super(key: key);
@override
State<AllConnections> createState() => _AllConnectionsState();
}
class _AllConnectionsState extends State<AllConnections> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('My Connections'),
body: Container(),
);
}
}

@ -317,15 +317,18 @@ class _MyMedicineTimingsState extends State<MyMedicineTimings> {
child: ListView.separated( child: ListView.separated(
separatorBuilder: (context, index) => const Divider( separatorBuilder: (context, index) => const Divider(
height: 4.0, height: 4.0,
color: primaryColor, color: Colors.transparent,
), ),
//padding: EdgeInsets.all(8), //padding: EdgeInsets.all(8),
itemCount: timings.length, itemCount: timings.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return GestureDetector( return GestureDetector(
onTap: (){ onTap: (){
AppSettings.longSuccessToast('Please click on edit button'); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Please click on edit button'),));
//AppSettings.longSuccessToast('');
}, },
child: Card(
child: Padding( child: Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: Container( child: Container(
@ -344,7 +347,7 @@ class _MyMedicineTimingsState extends State<MyMedicineTimings> {
style: wrapTextStyle(), style: wrapTextStyle(),
), ),
), ),
GestureDetector( /* GestureDetector(
onTap: () { onTap: () {
}, },
child: Image( child: Image(
@ -352,13 +355,14 @@ class _MyMedicineTimingsState extends State<MyMedicineTimings> {
width: 30, width: 30,
height: 30, height: 30,
), ),
), ),*/
textForSelectedTime(index) textForSelectedTime(index)
], ],
), ),
], ],
)), )),
), ),
),
); );
})), })),
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40), Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40),
@ -389,57 +393,31 @@ class _MyMedicineTimingsState extends State<MyMedicineTimings> {
); );
} }
editTimingsDialog(){ Widget renderUi() {
return Column(
return showDialog( children: [
context: context, Expanded(
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('Edit Timings'),
content: SingleChildScrollView(
child: Container(
width: double.maxFinite,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.4,
),
child: ListView.separated( child: ListView.separated(
separatorBuilder: (context, index) => const Divider( separatorBuilder: (context, index) => const Divider(
height: 4.0, height: 4.0,
color: primaryColor, color: Colors.transparent,
), ),
//padding: EdgeInsets.all(8), //padding: EdgeInsets.all(8),
itemCount: timings.length, itemCount: timings.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return GestureDetector(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width:
MediaQuery.of(context).size.width * .25,
child: Text(
timings[index]['name'],
style: wrapTextStyle(),
),
),
GestureDetector(
onTap: () { onTap: () {
Navigator.of(context).push( Navigator.of(context).push(
showPicker( showPicker(
showSecondSelector: true, showSecondSelector: true,
accentColor: primaryColor,
okStyle: TextStyle(color: primaryColor,fontWeight: FontWeight.bold),
cancelStyle: TextStyle(color: Colors.red,fontWeight: FontWeight.bold),
barrierDismissible: false,
blurredBackground: true,
borderRadius: 20,
disableAutoFocusToNextInput: true,
displayHeader: true,
context: context, context: context,
value: _time, value: _time,
//onChange: onTimeChanged, //onChange: onTimeChanged,
@ -459,55 +437,8 @@ class _MyMedicineTimingsState extends State<MyMedicineTimings> {
), ),
); );
}, },
child: Image( child: Card(
image: AssetImage('images/time.png'), child: Padding(
width: 30,
height: 30,
),
),
textForSelectedTime(index)
],
),
],
)),
);
})
),
]),
)),
actions: <Widget>[
TextButton(
child: Text('Cancel', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Save', style: textButtonStyle()),
onPressed: () async {
},
),
],
);
});
},
);
}
Widget renderUi() {
return Column(
children: [
Expanded(
child: ListView.separated(
separatorBuilder: (context, index) => const Divider(
height: 4.0,
color: primaryColor,
),
//padding: EdgeInsets.all(8),
itemCount: timings.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: Container( child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0), padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
@ -525,41 +456,18 @@ class _MyMedicineTimingsState extends State<MyMedicineTimings> {
style: wrapTextStyle(), style: wrapTextStyle(),
), ),
), ),
GestureDetector( Image(
onTap: () {
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
//onChange: onTimeChanged,
onChange: (val) {
onTimeChanged(val, index);
},
is24HrFormat: false,
sunrise: TimeOfDay(
hour: 6, minute: 0), // optional
sunset: TimeOfDay(hour: 18, minute: 0),
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
_selectedDateWithTime(dateTime,index);
},
),
);
},
child: Image(
image: AssetImage('images/time.png'), image: AssetImage('images/time.png'),
width: 30, width: 30,
height: 30, height: 30,
), ),
),
textForSelectedTime(index) textForSelectedTime(index)
], ],
), ),
], ],
)), )),
),
),
); );
})), })),
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40), Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40),

@ -545,6 +545,7 @@ class _PrescriptionsState extends State<Prescriptions> {
)); ));
} }
} }
showPicDialog(var imageUrl){ showPicDialog(var imageUrl){
return showDialog( return showDialog(
context: context, context: context,

File diff suppressed because it is too large Load Diff

@ -447,6 +447,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
flutter_share:
dependency: "direct main"
description:
name: flutter_share
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter_slidable: flutter_slidable:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1045,6 +1052,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.5" version: "6.0.5"
qr:
dependency: transitive
description:
name: qr
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
qr_flutter:
dependency: "direct main"
description:
name: qr_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
recase: recase:
dependency: transitive dependency: transitive
description: description:
@ -1066,6 +1087,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:

@ -61,6 +61,9 @@ dependencies:
assets_audio_player: ^3.0.3+3 assets_audio_player: ^3.0.3+3
path: ^1.8.0 path: ^1.8.0
visibility_detector: ^0.4.0+2 visibility_detector: ^0.4.0+2
flutter_share: ^2.0.0
share: ^2.0.4
qr_flutter: ^4.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save