Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 7.3 KiB |
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|