You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1080 lines
44 KiB
1080 lines
44 KiB
import 'dart:convert';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:healthcare_user/common/settings.dart';
|
|
import 'package:healthcare_user/common/zoom_image.dart';
|
|
import 'package:healthcare_user/models/all_problems_model.dart';
|
|
import 'package:healthcare_user/report_problem/report_my_self.dart';
|
|
import 'package:healthcare_user/report_problem/video_file.dart';
|
|
import 'package:photo_view/photo_view.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:flutter_sound/flutter_sound.dart';
|
|
import 'package:assets_audio_player/assets_audio_player.dart';
|
|
|
|
class AllProblemsReportMyself extends StatefulWidget {
|
|
const AllProblemsReportMyself({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<AllProblemsReportMyself> createState() => _AllProblemsReportMyselfState();
|
|
}
|
|
|
|
class _AllProblemsReportMyselfState extends State<AllProblemsReportMyself> {
|
|
|
|
|
|
List<AllProblemsModel> allProblemsList = [];
|
|
List<AllProblemsModel> allProblemsListOriginal = [];
|
|
bool isProblemDataLoading = false;
|
|
bool isSereverIssue = false;
|
|
TextEditingController searchController = TextEditingController();
|
|
TextEditingController dateInput = TextEditingController();
|
|
TextEditingController fromdateController = TextEditingController();
|
|
TextEditingController todateController = TextEditingController();
|
|
String dropdownSearchType = 'All';
|
|
bool isAudioButtonPressed=false;
|
|
bool _playAudio=false;
|
|
final recordingPlayer = AssetsAudioPlayer();
|
|
var typeOfSearchItems = [
|
|
'All',
|
|
'Problem',
|
|
'Date',
|
|
];
|
|
|
|
Future<void> getAllProblemsReportMyself() async {
|
|
isProblemDataLoading=true;
|
|
try {
|
|
var response = await AppSettings.getAllReportProblemDetalis();
|
|
|
|
setState(() {
|
|
allProblemsListOriginal = ((jsonDecode(response)) as List)
|
|
.map((dynamic model) {
|
|
return AllProblemsModel.fromJson(model);
|
|
}).toList();
|
|
allProblemsList=allProblemsListOriginal.reversed.toList();
|
|
isProblemDataLoading = false;
|
|
});
|
|
} catch (e) {
|
|
setState(() {
|
|
isProblemDataLoading = false;
|
|
isSereverIssue = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
Future<void> getAllProblemsReportMyselfByProblem(var problem) async {
|
|
|
|
isProblemDataLoading=true;
|
|
try {
|
|
var response = await AppSettings.getAllReportProblemDetalis();
|
|
|
|
setState(() {
|
|
allProblemsListOriginal = ((jsonDecode(response)) as List)
|
|
.map((dynamic model) {
|
|
return AllProblemsModel.fromJson(model);
|
|
}).toList();
|
|
allProblemsList=allProblemsListOriginal.reversed.toList();
|
|
allProblemsList= allProblemsListOriginal.where(
|
|
(x) => x.problem.toString().toLowerCase().contains(problem.toString().toLowerCase())
|
|
).toList();
|
|
isProblemDataLoading = false;
|
|
});
|
|
} catch (e) {
|
|
setState(() {
|
|
isProblemDataLoading = false;
|
|
isSereverIssue = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
Future<void> getAllProblemsReportMyselfByDateRange(var fromDate,var toDate) async {
|
|
isProblemDataLoading = true;
|
|
|
|
try {
|
|
var response = await AppSettings.getAllReportProblemDetalis();
|
|
|
|
setState(() {
|
|
allProblemsListOriginal = ((jsonDecode(response)) as List)
|
|
.map((dynamic model) {
|
|
return AllProblemsModel.fromJson(model);
|
|
}).toList();
|
|
allProblemsList=allProblemsListOriginal.reversed.toList();
|
|
var dateToCheck = DateTime.now().add(Duration(days: -1));
|
|
|
|
allProblemsList = allProblemsListOriginal.where((product) {
|
|
final date = product.dateForFilter;
|
|
final startDate =DateFormat('dd-MM-yyyy').parse(fromDate);
|
|
final endDate = DateFormat('dd-MM-yyyy').parse(toDate);
|
|
return date.isAfter(startDate) && date.isBefore(endDate);
|
|
//reportsList=reportsListOriginal.reversed.toList();
|
|
}).toList();
|
|
|
|
/*if( dateToCheck.isAfter(startDate) && dateToCheck.isBefore(endDate))
|
|
{
|
|
print("dateToCheck is between now and lastYear");
|
|
}
|
|
else
|
|
{
|
|
print("dateToCheck is not between now and lastYear");
|
|
}*/
|
|
|
|
|
|
isProblemDataLoading = false;
|
|
});
|
|
} catch (e) {
|
|
setState(() {
|
|
isProblemDataLoading = false;
|
|
isSereverIssue = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
void initState() {
|
|
getAllProblemsReportMyself();
|
|
var now = new DateTime.now();
|
|
String formattedDate = DateFormat('dd-MM-yyyy').format(now);
|
|
fromdateController.text=formattedDate;
|
|
todateController.text=formattedDate;
|
|
super.initState();
|
|
}
|
|
|
|
|
|
showPicDialog(var imageUrl){
|
|
return showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return StatefulBuilder(
|
|
builder: (BuildContext context, StateSetter setState) {
|
|
return AlertDialog(
|
|
title: const Text(''),
|
|
content: SingleChildScrollView(
|
|
child: ListBody(
|
|
children: <Widget>[
|
|
Container(
|
|
width: MediaQuery.of(context).size.width * .10,
|
|
height: MediaQuery.of(context).size.height * .50,
|
|
child: PhotoView(
|
|
imageProvider: NetworkImage(imageUrl) as ImageProvider,
|
|
maxScale: PhotoViewComputedScale.contained * 4.0,
|
|
minScale: PhotoViewComputedScale.contained,
|
|
initialScale: PhotoViewComputedScale.contained,
|
|
basePosition: Alignment.center,
|
|
|
|
)
|
|
)
|
|
],
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text('Close', style: textButtonStyle()),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
|
|
Widget findings(var obj){
|
|
return Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * .20,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: obj.findingsImages.length,
|
|
itemBuilder: (context, index) {
|
|
return Column(
|
|
children: [
|
|
Card(
|
|
child: GestureDetector(
|
|
onTap: (){
|
|
/*showPicDialog(obj.findingsImages[index]['url']);*/
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:obj.findingsImages[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(
|
|
obj.findingsImages[index]['url'])
|
|
as ImageProvider, // picked file
|
|
fit: BoxFit.fill)),
|
|
),
|
|
),
|
|
),
|
|
/*Expanded(child:IconButton(
|
|
icon: const Icon(Icons.remove,color: Colors.red,),
|
|
|
|
onPressed: () async{
|
|
|
|
},
|
|
),)*/
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
Widget reports(var obj){
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * .20,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: obj.reportImages.length,
|
|
itemBuilder: (context, index) {
|
|
return Column(
|
|
children: [
|
|
Card(
|
|
child: GestureDetector(
|
|
onTap: (){
|
|
//showPicDialog(obj.reportImages[index]['url']);
|
|
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:obj.reportImages[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(
|
|
obj.reportImages[index]
|
|
['url'])
|
|
as ImageProvider, // picked file
|
|
fit: BoxFit.fill)),
|
|
),
|
|
),
|
|
),
|
|
/*Expanded(child:IconButton(
|
|
icon: const Icon(Icons.remove,color: Colors.red,),
|
|
|
|
onPressed: () async{
|
|
|
|
},
|
|
),)*/
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> playFunc(var audio) async {
|
|
recordingPlayer.open(
|
|
Audio.file(audio),
|
|
autoStart: true,
|
|
showNotification: true,
|
|
);
|
|
}
|
|
|
|
Future<void> stopPlayFunc() async {
|
|
recordingPlayer.stop();
|
|
}
|
|
|
|
Widget _filtereddata(){
|
|
if(allProblemsList.length!=0){
|
|
return ListView.builder(
|
|
itemCount: allProblemsList.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.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
|
|
Container(
|
|
width: MediaQuery.of(context).size.width * .60,
|
|
child:
|
|
Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Problem',
|
|
style: labelTextStyle(),
|
|
),
|
|
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
|
Text(
|
|
'Description',
|
|
style: labelTextStyle(),
|
|
),
|
|
|
|
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
|
Text(
|
|
'Date',
|
|
style: labelTextStyle(),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(width:MediaQuery.of(context).size.width * .01,),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
':',
|
|
style: labelTextStyle(),
|
|
),
|
|
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
|
Text(
|
|
':',
|
|
style: labelTextStyle(),
|
|
),
|
|
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
|
Text(
|
|
':',
|
|
style: labelTextStyle(),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(width:MediaQuery.of(context).size.width * .01,),
|
|
Expanded(child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
allProblemsList[index]
|
|
.problem
|
|
.toString()
|
|
.toUpperCase(),
|
|
style: valuesTextStyle()),
|
|
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
|
Text(
|
|
allProblemsList[index].description
|
|
.toString()
|
|
.toUpperCase(),
|
|
style: valuesTextStyle()),
|
|
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
|
Text(
|
|
allProblemsList[index]
|
|
.date
|
|
.toString()
|
|
.toUpperCase(),
|
|
style: valuesTextStyle()),
|
|
],
|
|
),)
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Visibility(
|
|
visible: allProblemsList[index].audio!='',
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: primaryColor, // background
|
|
onPrimary: Colors.white, // foreground
|
|
),
|
|
onPressed: () async {
|
|
setState(() {
|
|
|
|
|
|
if(!allProblemsList[index].isAudioButtonEnabled){
|
|
setState(() {
|
|
allProblemsList[index].isAudioButtonEnabled=true;
|
|
});
|
|
}
|
|
else{
|
|
setState(() {
|
|
allProblemsList[index].isAudioButtonEnabled=false;
|
|
});
|
|
}
|
|
});
|
|
},
|
|
child: const Text('Audio'),
|
|
),),
|
|
Visibility(
|
|
visible: allProblemsList[index].audio!='',
|
|
child: SizedBox(
|
|
width:MediaQuery.of(context).size.width * .01,
|
|
) ,),
|
|
Visibility(
|
|
visible: allProblemsList[index].video!='',
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: primaryColor, // background
|
|
onPrimary: Colors.white, // foreground
|
|
),
|
|
onPressed: () async {
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ProblemVideo(videoUrl:allProblemsList[index].video)));
|
|
|
|
},
|
|
child: const Text('Video'),
|
|
),),
|
|
|
|
Visibility(
|
|
visible: allProblemsList[index].video!='',
|
|
child: SizedBox(
|
|
width:MediaQuery.of(context).size.width * .01,
|
|
) ,),
|
|
Visibility(
|
|
visible: allProblemsList[index].image!='',
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: primaryColor, // background
|
|
onPrimary: Colors.white, // foreground
|
|
),
|
|
onPressed: () async {
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ImageZoomPage(imageName:'Problem Picture',imageDetails:allProblemsList[index].image)));
|
|
|
|
},
|
|
child: const Text('Image'),
|
|
),),
|
|
|
|
],
|
|
),
|
|
Visibility(
|
|
visible: allProblemsList[index].isAudioButtonEnabled,
|
|
child:Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
ElevatedButton.icon(
|
|
style:
|
|
ElevatedButton.styleFrom(elevation: 9.0, primary: Colors.red),
|
|
onPressed: () {
|
|
setState(() {
|
|
_playAudio = !_playAudio;
|
|
});
|
|
if (_playAudio) playFunc(allProblemsList[index].audio);
|
|
if (!_playAudio) stopPlayFunc();
|
|
},
|
|
icon: _playAudio
|
|
? Icon(
|
|
Icons.stop,
|
|
)
|
|
: Icon(Icons.play_arrow),
|
|
label: _playAudio
|
|
? Text(
|
|
"Stop",
|
|
style: TextStyle(
|
|
fontSize: 28,
|
|
),
|
|
)
|
|
: Text(
|
|
"Play",
|
|
style: TextStyle(
|
|
fontSize: 28,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
)
|
|
|
|
],
|
|
)
|
|
),
|
|
|
|
|
|
Visibility(
|
|
visible:false,
|
|
child: Expanded(child:IconButton(
|
|
icon: const Icon(Icons.edit,color: primaryColor,),
|
|
onPressed: () {
|
|
|
|
/*Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new UpdateReport(reportDetails:allProblemsList[index]))).then((value) {
|
|
getAllProblemsReportMyself();
|
|
});*/
|
|
},
|
|
),),
|
|
),
|
|
Expanded(child:IconButton(
|
|
icon: const Icon(Icons.delete,color: primaryColor,),
|
|
|
|
onPressed: () async{
|
|
showDialog(
|
|
//if set to true allow to close popup by tapping out of the popup
|
|
//barrierDismissible: false,
|
|
context: context,
|
|
builder: (BuildContext context) => AlertDialog(
|
|
title: const Text('Do you want to delete Record?',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 20,
|
|
)),
|
|
actionsAlignment: MainAxisAlignment.spaceBetween,
|
|
actions: [
|
|
TextButton(
|
|
onPressed: ()async {
|
|
|
|
bool deleteTankStatus = await AppSettings.deleteReportMySelfProblem(allProblemsList[index].problemId);
|
|
|
|
|
|
if(deleteTankStatus){
|
|
getAllProblemsReportMyself();
|
|
AppSettings.longSuccessToast('Problem deleted successfully');
|
|
Navigator.of(context).pop(true);
|
|
|
|
}
|
|
else{
|
|
AppSettings.longFailedToast('Problem deletion failed');
|
|
Navigator.of(context).pop(true);
|
|
}
|
|
},
|
|
child: const Text('Yes',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 20,
|
|
)),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop(true);
|
|
},
|
|
child: const Text('No',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 20,
|
|
)),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
|
|
|
|
},
|
|
),)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
else{
|
|
return Padding(padding: EdgeInsets.fromLTRB(60,10,60,10),
|
|
child: Column(
|
|
children: [
|
|
Text('No problems found related to your search'),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
CircleAvatar(
|
|
backgroundColor: Colors.red,
|
|
radius: 30,
|
|
child: const Icon(
|
|
Icons.info,
|
|
color: Colors.white,
|
|
),
|
|
)
|
|
],
|
|
),);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
Widget _allreports(){
|
|
|
|
if(allProblemsListOriginal.length!=0){
|
|
|
|
return Padding(padding:EdgeInsets.all(10),
|
|
child:Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Container(
|
|
child: DropdownButtonFormField(
|
|
// Initial Value
|
|
value: dropdownSearchType,
|
|
isExpanded: true,
|
|
decoration: const InputDecoration(
|
|
prefixIcon: Icon(
|
|
Icons.search,
|
|
color: greyColor,
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide(color: greyColor)),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: greyColor),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: greyColor),
|
|
),
|
|
labelText: 'Search By',
|
|
labelStyle: TextStyle(
|
|
color: greyColor, //<-- SEE HERE
|
|
),
|
|
),
|
|
|
|
hint: Text('Select Search Type'),
|
|
// Down Arrow Icon
|
|
icon: const Icon(Icons.keyboard_arrow_down),
|
|
|
|
// Array list of items
|
|
items: typeOfSearchItems.map((String items) {
|
|
return DropdownMenuItem(
|
|
value: items,
|
|
child: Text(items),
|
|
);
|
|
}).toList(),
|
|
// After selecting the desired option,it will
|
|
// change button value to selected value
|
|
onChanged: (String? newValue) {
|
|
setState(() {
|
|
dropdownSearchType = newValue!;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
SizedBox(height: MediaQuery.of(context).size.height * .01,),
|
|
Visibility(
|
|
visible:dropdownSearchType.toString().toLowerCase()=='problem' ,
|
|
child: Container(
|
|
height: MediaQuery.of(context).size.height * .07,
|
|
child: Center(child: TextField(
|
|
|
|
cursorColor: primaryColor,
|
|
controller: searchController,
|
|
onChanged: (string) {
|
|
if(string.length>=1){
|
|
getAllProblemsReportMyselfByProblem(string);
|
|
}
|
|
else{
|
|
getAllProblemsReportMyself();
|
|
}
|
|
},
|
|
decoration: InputDecoration(
|
|
prefixIcon: Icon(
|
|
Icons.search,
|
|
color: primaryColor,
|
|
),
|
|
/*suffixIcon: Icon(
|
|
Icons.clear,
|
|
color: greyColor,
|
|
),*/
|
|
suffixIcon: searchController.text!=''?IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.red,
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
searchController.text='';
|
|
});
|
|
getAllProblemsReportMyself();
|
|
},
|
|
):IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.transparent,
|
|
),
|
|
onPressed: () {
|
|
},
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
//labelText: 'Search by phone number',
|
|
hintText: 'Search by problem',
|
|
labelStyle: TextStyle(
|
|
color: greyColor, //<-- SEE HERE
|
|
),
|
|
),
|
|
),)
|
|
),),
|
|
Visibility(
|
|
visible:dropdownSearchType.toString().toLowerCase()=='doctor' ,
|
|
child: Container(
|
|
height: MediaQuery.of(context).size.height * .07,
|
|
child: Center(child: TextField(
|
|
|
|
cursorColor: primaryColor,
|
|
controller: searchController,
|
|
onChanged: (string) {
|
|
if(string.length>=1){
|
|
//getRecordsByDoctorName(string);
|
|
}
|
|
else{
|
|
getAllProblemsReportMyself();
|
|
}
|
|
},
|
|
decoration: InputDecoration(
|
|
prefixIcon: Icon(
|
|
Icons.search,
|
|
color: primaryColor,
|
|
),
|
|
/*suffixIcon: Icon(
|
|
Icons.clear,
|
|
color: greyColor,
|
|
),*/
|
|
suffixIcon: searchController.text!=''?IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.red,
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
searchController.text='';
|
|
});
|
|
getAllProblemsReportMyself();
|
|
},
|
|
):IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.transparent,
|
|
),
|
|
onPressed: () {
|
|
},
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
//labelText: 'Search by phone number',
|
|
hintText: 'Search by doctor',
|
|
labelStyle: TextStyle(
|
|
color: greyColor, //<-- SEE HERE
|
|
),
|
|
),
|
|
),)
|
|
),),
|
|
Visibility(
|
|
visible:dropdownSearchType.toString().toLowerCase()=='date',
|
|
child: Container(
|
|
//height: 60,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: TextField(
|
|
|
|
cursorColor: primaryColor,
|
|
controller: fromdateController,
|
|
onChanged: (string) {
|
|
if(string.length>=1){
|
|
//getRecordsByDate(string);
|
|
}
|
|
else{
|
|
getAllProblemsReportMyself();
|
|
}
|
|
},
|
|
onTap: () async {
|
|
DateTime? pickedDate = await showDatePicker(
|
|
context: context,
|
|
initialDate: DateTime.now(),
|
|
firstDate: DateTime(1950),
|
|
lastDate: DateTime.now(),
|
|
builder: (BuildContext context, Widget? child) {
|
|
return Theme(
|
|
data: ThemeData.dark().copyWith(
|
|
colorScheme: ColorScheme.dark(
|
|
primary: buttonColors,
|
|
onPrimary: Colors.white,
|
|
surface: buttonColors,
|
|
onSurface: Colors.white,
|
|
),
|
|
dialogBackgroundColor: primaryColor,
|
|
),
|
|
child: child!,
|
|
);
|
|
},
|
|
);
|
|
|
|
if (pickedDate != null) {
|
|
print(
|
|
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
|
|
String formattedDate =
|
|
DateFormat('dd-MM-yyyy').format(pickedDate);
|
|
print(
|
|
formattedDate); //formatted date output using intl package => 2021-03-16
|
|
setState(() {
|
|
fromdateController.text = formattedDate; //set output date to TextField value.
|
|
});
|
|
getAllProblemsReportMyselfByDateRange(fromdateController.text,todateController.text);
|
|
} else {}
|
|
},
|
|
decoration: InputDecoration(
|
|
prefixIcon: Icon(
|
|
Icons.calendar_month,
|
|
color: primaryColor,
|
|
),
|
|
suffixIcon: fromdateController.text!=''?IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.red,
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
fromdateController.text='';
|
|
});
|
|
getAllProblemsReportMyself();
|
|
},
|
|
):IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.transparent,
|
|
),
|
|
onPressed: () {
|
|
},
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
//labelText: 'Search by phone number',
|
|
hintText: 'From date',
|
|
|
|
labelStyle: TextStyle(
|
|
color: greyColor, //<-- SEE HERE
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 5),
|
|
Expanded(
|
|
child: TextField(
|
|
|
|
cursorColor: primaryColor,
|
|
controller: todateController,
|
|
onChanged: (string) {
|
|
if(string.length>=1){
|
|
//getRecordsByDate(string);
|
|
}
|
|
else{
|
|
getAllProblemsReportMyself();
|
|
}
|
|
},
|
|
onTap: () async {
|
|
DateTime? pickedDate = await showDatePicker(
|
|
context: context,
|
|
initialDate: DateTime.now(),
|
|
firstDate: DateTime(1950),
|
|
lastDate: DateTime.now(),
|
|
builder: (BuildContext context, Widget? child) {
|
|
return Theme(
|
|
data: ThemeData.dark().copyWith(
|
|
colorScheme: ColorScheme.dark(
|
|
primary: buttonColors,
|
|
onPrimary: Colors.white,
|
|
surface: buttonColors,
|
|
onSurface: Colors.white,
|
|
),
|
|
dialogBackgroundColor: primaryColor,
|
|
),
|
|
child: child!,
|
|
);
|
|
},
|
|
);
|
|
|
|
if (pickedDate != null) {
|
|
print(
|
|
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
|
|
String formattedDate =
|
|
DateFormat('dd-MM-yyyy').format(pickedDate);
|
|
print(
|
|
formattedDate); //formatted date output using intl package => 2021-03-16
|
|
setState(() {
|
|
todateController.text = formattedDate; //set output date to TextField value.
|
|
});
|
|
getAllProblemsReportMyselfByDateRange(fromdateController.text,todateController.text);
|
|
} else {}
|
|
},
|
|
decoration: InputDecoration(
|
|
prefixIcon: Icon(
|
|
Icons.calendar_month,
|
|
color: primaryColor,
|
|
),
|
|
suffixIcon: todateController.text!=''?IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.red,
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
todateController.text='';
|
|
});
|
|
getAllProblemsReportMyself();
|
|
},
|
|
):IconButton(
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.transparent,
|
|
),
|
|
onPressed: () {
|
|
},
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: primaryColor),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
//labelText: 'Search by phone number',
|
|
hintText: 'To date',
|
|
|
|
labelStyle: TextStyle(
|
|
color: greyColor, //<-- SEE HERE
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 5),
|
|
|
|
],
|
|
),
|
|
),),
|
|
Expanded(child: _filtereddata()),
|
|
Padding(
|
|
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
child: CircleAvatar(
|
|
backgroundColor: primaryColor,
|
|
radius: 40,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
IconButton(
|
|
iconSize: 40,
|
|
icon: const Icon(
|
|
Icons.add,
|
|
color: Colors.white,
|
|
),
|
|
onPressed: () async{
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => ReportMySelf())).then((value) {
|
|
getAllProblemsReportMyself();
|
|
});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
]));
|
|
|
|
|
|
}
|
|
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 problem'),
|
|
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) => ReportMySelf())).then((value) {
|
|
getAllProblemsReportMyself();
|
|
});
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppSettings.appBar('Report My Self'),
|
|
body: isProblemDataLoading?Center(
|
|
child: CircularProgressIndicator(
|
|
color: primaryColor,
|
|
strokeWidth: 5.0,
|
|
),
|
|
): _allreports(),
|
|
);
|
|
}
|
|
}
|
|
|