diff --git a/images/bmi.png b/images/bmi.png index abc2075..ad1f59a 100644 Binary files a/images/bmi.png and b/images/bmi.png differ diff --git a/images/bp.png b/images/bp.png index fb6f13c..b42da6a 100644 Binary files a/images/bp.png and b/images/bp.png differ diff --git a/images/get_checkup.png b/images/get_checkup.png index ce84c7c..f366b2a 100644 Binary files a/images/get_checkup.png and b/images/get_checkup.png differ diff --git a/images/health_records.png b/images/health_records.png index 1776224..d984d2e 100644 Binary files a/images/health_records.png and b/images/health_records.png differ diff --git a/images/medicines.png b/images/medicines.png index ebd77fc..ae606ec 100644 Binary files a/images/medicines.png and b/images/medicines.png differ diff --git a/images/myconnections.png b/images/myconnections.png index b22e6af..6cf4755 100644 Binary files a/images/myconnections.png and b/images/myconnections.png differ diff --git a/images/myresources.png b/images/myresources.png new file mode 100644 index 0000000..8e1da64 Binary files /dev/null and b/images/myresources.png differ diff --git a/images/new_problem.png b/images/new_problem.png index 2766b1c..49a2071 100644 Binary files a/images/new_problem.png and b/images/new_problem.png differ diff --git a/images/patient_dashboard.png b/images/patient_dashboard.png new file mode 100644 index 0000000..ce90719 Binary files /dev/null and b/images/patient_dashboard.png differ diff --git a/images/prescriptions.png b/images/prescriptions.png index a0b3dee..a58ebad 100644 Binary files a/images/prescriptions.png and b/images/prescriptions.png differ diff --git a/images/resources.png b/images/resources.png index ddc8acb..a28da8f 100644 Binary files a/images/resources.png and b/images/resources.png differ diff --git a/images/sugar.png b/images/sugar.png index 34c9b37..714ba95 100644 Binary files a/images/sugar.png and b/images/sugar.png differ diff --git a/lib/common/dashboard.dart b/lib/common/dashboard.dart index 20f7ad8..7f76183 100644 --- a/lib/common/dashboard.dart +++ b/lib/common/dashboard.dart @@ -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 { 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 { ], ), ), + 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( diff --git a/lib/common/settings.dart b/lib/common/settings.dart index 367008d..a6feeac 100644 --- a/lib/common/settings.dart +++ b/lib/common/settings.dart @@ -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 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 getAllRecords(customerId) async { var uri = Uri.parse(getRecordsDataUrl + '/' + customerId); //uri = uri.replace(query: 'customerId=$customerId'); @@ -1499,7 +1527,64 @@ class AppSettings { } } + static Future 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 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 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*/ diff --git a/lib/models/resources_model.dart b/lib/models/resources_model.dart new file mode 100644 index 0000000..486c0cf --- /dev/null +++ b/lib/models/resources_model.dart @@ -0,0 +1,27 @@ + + +class ResourcesModel { + String resource_name=''; + String resource_id=''; + List dos=[]; + List donts=[]; + List urls=[]; + + + + + ResourcesModel(); + + factory ResourcesModel.fromJson(Map 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; + } + +} \ No newline at end of file diff --git a/lib/patient_dashboard/patient_dashboard.dart b/lib/patient_dashboard/patient_dashboard.dart index cbdf2f6..24cd010 100644 --- a/lib/patient_dashboard/patient_dashboard.dart +++ b/lib/patient_dashboard/patient_dashboard.dart @@ -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 { bool isScannerVisible=true; TextEditingController mobileNumberController = TextEditingController(); + String mobileNumber=''; final List images = [ 'https://via.placeholder.com/150', 'https://via.placeholder.com/150', @@ -36,7 +39,8 @@ class _PatientDashboardState extends State { '#ff6666', 'Cancel', true, ScanMode.QR); print(barcodeScanRes); setState(() { - + mobileNumber=jsonDecode(barcodeScanRes)['contactNumber']; + mobileNumberController.text=mobileNumber; }); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; diff --git a/lib/patient_dashboard/patient_dshboard_details.dart b/lib/patient_dashboard/patient_dshboard_details.dart index 2a571ef..73a750e 100644 --- a/lib/patient_dashboard/patient_dshboard_details.dart +++ b/lib/patient_dashboard/patient_dshboard_details.dart @@ -35,7 +35,7 @@ class _PatientDashboardDetailsState extends State { 'images/medicines.png', 'images/new_problem.png', 'images/get_checkup.png', - 'images/resources.png', + 'images/myresources.png', ]; final List 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, )), diff --git a/lib/resources/add_resurces.dart b/lib/resources/add_resurces.dart new file mode 100644 index 0000000..e10648c --- /dev/null +++ b/lib/resources/add_resurces.dart @@ -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 createState() => _AddResourcesState(); +} + +class _AddResourcesState extends State { + + 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? 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: [ + 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: [ + 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( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + 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(); + 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'), + ) + ), + + + ], + ), + ) + )), + ), + ])); + } +} diff --git a/lib/resources/resources.dart b/lib/resources/resources.dart new file mode 100644 index 0000000..9239b94 --- /dev/null +++ b/lib/resources/resources.dart @@ -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 createState() => _ResourcesState(); +} + +class _ResourcesState extends State { + + bool isDataLoading=false; + bool isSereverIssue=false; + List resourcecList = []; + + Future 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: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.black, + ), + onPressed: () async { + Navigator.push(context, MaterialPageRoute(builder: (context) => AddResources())).then((value) { + getAllResources(); + }); + }, + ), + ], + ), + ), + ), + ); + } +}