patient dashboard completed

master
Sneha 8 months ago
parent 4cb7b6093c
commit e3970641f1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

@ -3,6 +3,7 @@ import 'package:doctor/common/qrcode_display.dart';
import 'package:doctor/common/updateprofile.dart';
import 'package:doctor/connected_patients/connected_patients.dart';
import 'package:doctor/patient_dashboard/patient_dashboard.dart';
import 'package:doctor/resources/resources.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
@ -161,7 +162,7 @@ class _DashboardState extends State<Dashboard> {
shape: BoxShape.circle,
image: DecorationImage(
image: AssetImage(
"images/myconnections.png"), // picked file
"images/patient_dashboard.png"), // picked file
fit: BoxFit.fitWidth)),
),
onTap: () {
@ -181,6 +182,43 @@ class _DashboardState extends State<Dashboard> {
],
),
),
Padding(
padding: EdgeInsets.all(10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .20,
height: MediaQuery.of(context).size.height * .15,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
image: DecorationImage(
image: AssetImage(
"images/resources.png"), // picked file
fit: BoxFit.fitHeight)),
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Resources()),
);
},
),
Text(
'Resources',
style: dashboardTextStyle(),
),
],
),
],
),
),
/*Padding(
padding: EdgeInsets.all(10),
child: Row(

@ -324,6 +324,7 @@ class AppSettings {
static String resetTokenUrl = host + 'reset_token';
static String generateQRCodeUrl = host + 'generate-qrcode-doctor';
static String getAllConectedPatientsDataUrl = host + 'customerDetails';
static String getAllResourcesDataUrl = host + 'getResourceDetails';
static String getRecordsDataUrl = host + 'getAllRecords';
static String deleteRecordUrl = host + 'deleteRecord';
static String getDynamicCodeUrl = host + 'records';
@ -356,6 +357,9 @@ class AppSettings {
static String addRecordsUrl = host + 'add-record';
static String addPrescriptionUrl = host + 'add-prescription-details';
static String getAllReportProblemDetalisUrl = host + 'userreport';
static String addResourceUrl = host + 'resources';
static String resourcesUploadPicUrl = host + 'uploads-resource-picture';
static File? updatedImage;
@ -661,6 +665,30 @@ class AppSettings {
}
}
static Future<String> getAllResources() async {
var uri = Uri.parse(getAllResourcesDataUrl + '/' + doctorId);
//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<String> getAllRecords(customerId) async {
var uri = Uri.parse(getRecordsDataUrl + '/' + customerId);
//uri = uri.replace(query: 'customerId=$customerId');
@ -1499,7 +1527,64 @@ class AppSettings {
}
}
static Future<bool> addResource(payload) async { var uri = Uri.parse(addResourceUrl + '/' + doctorId);
try {
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) {
print(e);
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;
}
} catch (e) {
print(e);
return false;
}
}
static Future<String> uploadResourceCamera(file) async {
var request = http.MultipartRequest('POST', Uri.parse(resourcesUploadPicUrl + '/' + doctorId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send();
var response = await http.Response.fromStream(res);
return response.body;
}
static Future<String> uploadResourcesGallery(file) async {
var request = http.MultipartRequest(
'POST', Uri.parse(resourcesUploadPicUrl + '/' + doctorId));
if (file.length > 0) {
for (var i = 0; i < file.length; i++) {
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
}}
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
var res = await request.send();
var response = await http.Response.fromStream(res);
return response.body;
}
/*Apis ends here*/

@ -0,0 +1,27 @@
class ResourcesModel {
String resource_name='';
String resource_id='';
List dos=[];
List donts=[];
List urls=[];
ResourcesModel();
factory ResourcesModel.fromJson(Map<String, dynamic> json){
ResourcesModel rtvm = new ResourcesModel();
rtvm.resource_name = json['resourceName'] ?? '';
rtvm.resource_id = json['resourceId'] ?? '';
rtvm.dos = json['dos'] ?? '';
rtvm.donts = json['doNots'] ?? '';
rtvm.urls = json['url'] ?? '';
return rtvm;
}
}

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:doctor/common/settings.dart';
import 'package:doctor/patient_dashboard/patient_dshboard_details.dart';
import 'package:flutter/material.dart';
@ -15,6 +17,7 @@ class _PatientDashboardState extends State<PatientDashboard> {
bool isScannerVisible=true;
TextEditingController mobileNumberController = TextEditingController();
String mobileNumber='';
final List<String> images = [
'https://via.placeholder.com/150',
'https://via.placeholder.com/150',
@ -36,7 +39,8 @@ class _PatientDashboardState extends State<PatientDashboard> {
'#ff6666', 'Cancel', true, ScanMode.QR);
print(barcodeScanRes);
setState(() {
mobileNumber=jsonDecode(barcodeScanRes)['contactNumber'];
mobileNumberController.text=mobileNumber;
});
} on PlatformException {
barcodeScanRes = 'Failed to get platform version.';

@ -35,7 +35,7 @@ class _PatientDashboardDetailsState extends State<PatientDashboardDetails> {
'images/medicines.png',
'images/new_problem.png',
'images/get_checkup.png',
'images/resources.png',
'images/myresources.png',
];
final List<String> labels = [
'Bp',
@ -189,6 +189,7 @@ Widget _dashboard(){
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 4.0,
mainAxisSpacing: 4.0,
),
itemBuilder: (BuildContext context, int index) {
@ -202,10 +203,10 @@ Widget _dashboard(){
decoration: BoxDecoration(
color: secondaryColor,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30),
borderRadius: BorderRadius.circular(20),
image: DecorationImage(
image: AssetImage(images[index],) , // picked file
fit: BoxFit.fitWidth)),
fit: BoxFit.fill)),
//color: secondaryColor,
)),

@ -0,0 +1,880 @@
import 'dart:convert';
import 'dart:io';
import 'package:doctor/common/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:multi_image_picker/multi_image_picker.dart';
class AddResources extends StatefulWidget {
const AddResources({Key? key}) : super(key: key);
@override
State<AddResources> createState() => _AddResourcesState();
}
class _AddResourcesState extends State<AddResources> {
TextEditingController nameController = TextEditingController();
TextEditingController youtubeLinkUrlController = TextEditingController();
TextEditingController dosController1 = TextEditingController();
TextEditingController dosController2 = TextEditingController();
TextEditingController dosController3 = TextEditingController();
TextEditingController donotsController1 = TextEditingController();
TextEditingController donotsController2 = TextEditingController();
TextEditingController donotsController3 = TextEditingController();
TextEditingController urlController1 = TextEditingController();
TextEditingController urlController2 = TextEditingController();
TextEditingController urlController3 = TextEditingController();
bool isSecondAddButtonShow=false;
bool is2nddosControllerVisible=false;
bool is3rddosControllerVisible=false;
bool is4thdosControllerVisible=false;
bool is5thdosControllerVisible=false;
bool is2nddonotsControllerVisible=false;
bool is3rddonotsControllerVisible=false;
bool is4thdonotsControllerVisible=false;
bool is5thdonotsControllerVisible=false;
bool is2ndurlControllerVisible=false;
bool is3rdurlControllerVisible=false;
bool is4thurlControllerVisible=false;
bool is5thurlControllerVisible=false;
List dos=[];
List donots=[];
List urls=[];
List images=[];
List videos=[];
List uiImages = [];
List imageFileListResources = [];
final ImagePicker _picker = ImagePicker();
String Url = '';
final ImagePicker imagePicker = ImagePicker();
Future takeImageFromCameraForReports() 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.uploadResourceCamera(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiImages = jsonDecode(res)['pictures'];
images= jsonDecode(res)['pictures'];
//reports=jsonDecode(res)['reportsPictureUpload'];
//reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
Future pickImageFromGalleryForReports() async {
imageFileListResources = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileListResources.addAll(selectedImages);
}
var res = await AppSettings.uploadResourcesGallery(imageFileListResources);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiImages = jsonDecode(res)['pictures'];
images= jsonDecode(res)['pictures'];
//reports=jsonDecode(res)['reportsPictureUpload'];
//reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId'];
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppSettings.appBar('Add Resources'),
body: Stack(children: <Widget>[
Container(
decoration: const BoxDecoration(
/* image: DecorationImage(
image: AssetImage("images/backgroundimage.png"),
fit: BoxFit.cover,
),*/
),
),
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,
),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Container(
child: TextFormField(
cursorColor: greyColor,
controller: nameController,
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: 'Resource name',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),//name
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Text('Dos',style: TextStyle(color: primaryColor,fontSize: 14,fontWeight: FontWeight.bold),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: dosController1,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.location_city,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
Visibility(
visible: dosController1.text!='',
child: IconButton(
onPressed: (){
setState(() {
is2nddosControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))
],
),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility(
visible:dosController2.text!=''&&dosController2.text!='null'||is2nddosControllerVisible,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: dosController2,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.location_city,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
Visibility(
visible: dosController2.text!='',
child: IconButton(
onPressed: (){
setState(() {
is3rddosControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))
],
),
),
),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility(
visible: dosController3.text!=''&&dosController3.text!='null'||is3rddosControllerVisible,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: dosController3,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.location_city,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
/*Visibility(
visible: dosController3.text!='',
child: IconButton(
onPressed: (){
setState(() {
is4thdosControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))*/
],
),
),
),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Text('Donts',style: TextStyle(color: primaryColor,fontSize: 14,fontWeight: FontWeight.bold),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: donotsController1,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.location_city,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
Visibility(
visible: donotsController1.text!='',
child: IconButton(
onPressed: (){
setState(() {
is2nddonotsControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))
],
),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility(
visible:donotsController2.text!=''&&donotsController2.text!='null'||is2nddonotsControllerVisible,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: donotsController2,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.location_city,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
Visibility(
visible: donotsController2.text!='',
child: IconButton(
onPressed: (){
setState(() {
is3rddonotsControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))
],
),
),
),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility(
visible: donotsController3.text!=''&&donotsController3.text!='null'||is3rddonotsControllerVisible,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: donotsController3,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.location_city,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
/*Visibility(
visible: dosController3.text!='',
child: IconButton(
onPressed: (){
setState(() {
is4thdosControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))*/
],
),
),
),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Text('Urls',style: TextStyle(color: primaryColor,fontSize: 14,fontWeight: FontWeight.bold),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: urlController1,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.link,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter video link url if any',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
Visibility(
visible: urlController1.text!='',
child: IconButton(
onPressed: (){
setState(() {
is2ndurlControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))
],
),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility(
visible:urlController2.text!=''&&urlController2.text!='null'||is2ndurlControllerVisible,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: urlController2,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.link,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter video link url if any',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
Visibility(
visible: urlController2.text!='',
child: IconButton(
onPressed: (){
setState(() {
is3rdurlControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))
],
),
),
),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility(
visible: urlController3.text!=''&&urlController3.text!='null'||is3rdurlControllerVisible,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: secondaryColor,
border: Border.all(
//width: 10,
color: Colors.white,
),
borderRadius: BorderRadius.circular(
20,
)),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextFormField(
cursorColor: greyColor,
controller: urlController3,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.link,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter video link url if any',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
/*Visibility(
visible: dosController3.text!='',
child: IconButton(
onPressed: (){
setState(() {
is4thdosControllerVisible=true;
});
},
icon: Icon(Icons.add_box, color: primaryColor,)))*/
],
),
),
),),
Visibility(
visible: uiImages.length == 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () async {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return SizedBox(
height: 200,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
child: Icon(
Icons.camera_alt_outlined,
size: 100,
color: primaryColor,
),
onTap: () async {
await takeImageFromCameraForReports();
Navigator.pop(context);
},
),
SizedBox(
width:
MediaQuery.of(context).size.width *
.20,
),
GestureDetector(
child: Icon(
Icons.photo,
size: 100,
color: primaryColor,
),
onTap: () async {
await pickImageFromGalleryForReports();
Navigator.pop(context);
},
),
],
),
),
);
});
},
child: const Text('Select Image'),
),
),
Visibility(
visible: uiImages.length > 0,
child: Container(
width: double.infinity,
height: MediaQuery.of(context).size.height * .20,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: uiImages.length,
itemBuilder: (context, index) {
return Column(
children: [
Card(
child: GestureDetector(
onTap: () {
/* Navigator.push(
context,
new MaterialPageRoute(
builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:uiReportsImages[index]['url'])));
*/
},
child: Container(
width: MediaQuery.of(context).size.width *
.30,
height:
MediaQuery.of(context).size.height *
.15,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
image: DecorationImage(
image: NetworkImage(
uiImages[0])
as ImageProvider, // picked file
fit: BoxFit.fill)),
child: Stack(children: [
/*Positioned(
right: 0,
child: Container(
child: IconButton(
iconSize: 30,
icon: const Icon(
Icons.cancel,
color: Colors.red,
),
onPressed: () async {
AppSettings.preLoaderDialog(context);
String fileName = uiReportsImages[index]['url'].split('/').last;
var response = await AppSettings.deleteReports(fileName,reportsPictureId);
print(jsonDecode(response));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiReportsImages = jsonDecode(response)['reportsPictureUpload']['reports'];
});
},
),
),
)*/
]),
),
)
),
/*Expanded(child:IconButton(
icon: const Icon(Icons.remove,color: Colors.red,),
onPressed: () async{
},
),)*/
],
);
}),
)),
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(dosController1!=''){
dos.add({
'dos': dosController1.text,
});
}
if(dosController2!=''){
dos.add({
'dos': dosController2.text,
});
}
if(dosController3!=''){
dos.add({
'dos': dosController3.text,
});
}
if(donotsController1!=''){
donots.add({
'doNots': donotsController1.text,
});
}
if(donotsController2!=''){
donots.add({
'doNots': donotsController2.text,
});
}
if(donotsController3!=''){
donots.add({
'doNots': donotsController3.text,
});
}
if(urlController1!=''){
urls.add({
'url': urlController1.text,
});
}
if(urlController2!=''){
urls.add({
'url': urlController2.text,
});
}
if(urlController3!=''){
urls.add({
'url': urlController3.text,
});
}
AppSettings.preLoaderDialog(context);
var payload = new Map<String, dynamic>();
payload["resourceName"] = nameController.text.toString();
payload["dos"] =dos ;
payload["doNots"] =donots ;
payload["url"] =urls ;
payload["image"] =images;
payload["createdBy"] =AppSettings.doctorName ;
payload["updatedBy"] =AppSettings.doctorName ;
bool addResourcesState = await AppSettings.addResource(payload);
try{
if(addResourcesState){
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longSuccessToast('Resource added successfully');
Navigator.pop(context);
}
else{
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('Fail to add Resource details');
}
}
catch(e){
print(e);
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('Fail to add Resource details');
}
},
child: Text('Add Resource'),
)
),
],
),
)
)),
),
]));
}
}

@ -0,0 +1,323 @@
import 'dart:convert';
import 'package:doctor/common/settings.dart';
import 'package:doctor/models/resources_model.dart';
import 'package:doctor/resources/add_resurces.dart';
import 'package:flutter/material.dart';
class Resources extends StatefulWidget {
const Resources({Key? key}) : super(key: key);
@override
State<Resources> createState() => _ResourcesState();
}
class _ResourcesState extends State<Resources> {
bool isDataLoading=false;
bool isSereverIssue=false;
List<ResourcesModel> resourcecList = [];
Future<void> getAllResources() async {
isDataLoading=true;
try {
var response = await AppSettings.getAllResources();
setState(() {
resourcecList = ((jsonDecode(response)) as List)
.map((dynamic model) {
return ResourcesModel.fromJson(model);
}).toList();
resourcecList=resourcecList.reversed.toList();
isDataLoading = false;
});
} catch (e) {
setState(() {
isDataLoading = false;
isSereverIssue = true;
});
}
}
@override
void initState() {
getAllResources();
super.initState();
}
Widget _dos(dos){
if(dos.length!=0){
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: dos.length,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Text(dos[index]['dos'].toString(),style: valuesTextStyle()),
);
});
}
else{
return Text('No dos found for this resource',style: valuesTextStyle());
}
}
Widget _donots(donots){
if(donots.length!=0){
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: donots.length,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Text(donots[index]['doNots'].toString(),style: valuesTextStyle()),
);
});
}
else{
return Text('No doNots found for this resource',style: valuesTextStyle());
}
}
Widget _urls(urls){
if(urls.length!=0){
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: urls.length,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Text(urls[index]['url'].toString(),style: valuesTextStyle()),
);
});
}
else{
return Text('No urls found for this resource',style: valuesTextStyle());
}
}
Widget _resources(){
if(resourcecList.length!=0){
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: resourcecList.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,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Resource Name',
style: labelTextStyle(),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
child: Text(
'Dos',
style: labelTextStyle(),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
child: Text(
'DoNots',
style: labelTextStyle(),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
child: Text(
'Urls',
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,),
Container(
height:MediaQuery.of(context).size.height * .10,
child: Text(
':',
style: labelTextStyle(),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
child: Text(
':',
style: labelTextStyle(),
),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
child: Text(
':',
style: labelTextStyle(),
),
),
],
),
SizedBox(width:MediaQuery.of(context).size.width * .01,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(resourcecList[index].resource_name.toString().toUpperCase(),style: valuesTextStyle()),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
width:MediaQuery.of(context).size.width * .80,
child: _dos(resourcecList[index].dos),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
width:MediaQuery.of(context).size.width * .80,
child: _donots(resourcecList[index].donts),
),
SizedBox(height:MediaQuery.of(context).size.height * .01,),
Container(
height:MediaQuery.of(context).size.height * .10,
width:MediaQuery.of(context).size.width * .80,
child: _urls(resourcecList[index].urls),
)
],
),
],
),
),
],
),
],
),
),
),
);
});
}
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 resource'),
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) => AddResources())).then((value) {
getAllResources();
});
},
),
)
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Resources'),
body: Container(
child: isDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
): _resources(),
),
floatingActionButton: Visibility(
visible:resourcecList.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) => AddResources())).then((value) {
getAllResources();
});
},
),
],
),
),
),
);
}
}
Loading…
Cancel
Save