From 252a3f168b4caab86a16ca8fa14c6928e718baca Mon Sep 17 00:00:00 2001 From: Shikhar <88368793+Shikhar12233456@users.noreply.github.com> Date: Tue, 18 Apr 2023 15:37:42 +0530 Subject: [PATCH] some feature added --- lib/Components/side_drawer.dart | 3 +- lib/Components/utils.dart | 20 + lib/api.dart | 4 +- lib/main.dart | 12 +- .../ComplaintHistory/get_complaint_by_id.dart | 526 ++++++++++++------ .../ComplaintHistory/pending_complaints.dart | 379 ++++++++++--- .../ComplaintHistory/update_complaint.dart | 84 +-- lib/screens/Complaint/Feedback/feedback.dart | 107 +--- .../LodgeComplaint/lodge_complaint.dart | 130 +++-- lib/screens/Complaint/complaint.dart | 278 ++++----- 10 files changed, 953 insertions(+), 590 deletions(-) create mode 100644 lib/Components/utils.dart diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..71ce3483 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -132,7 +132,8 @@ class _SideDrawerState extends State { pageMover: '/library_homepage'), ModulesPadding(line: 'Awards & Scholarship Module'), ModulesPadding( - line: 'Complaint Module', pageMover: '/complaint'), + line: 'Complaint Module', pageMover: '/complaint', + isActive: true,), ModulesPadding(line: 'Central Mess Module'), ModulesPadding(line: 'Feeds Module'), ModulesPadding( diff --git a/lib/Components/utils.dart b/lib/Components/utils.dart new file mode 100644 index 00000000..f26d1f22 --- /dev/null +++ b/lib/Components/utils.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class Utils { + final primarycolor = Colors.purple; + final primarybackgroundcolor = Colors.white; + final lightgrey = Colors.grey; + Decoration containerBorder(Color col) { + return BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all(color: primarycolor)); + } + + Widget leadingPopIconsButton(Color cc, BuildContext context) { + return IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Icon(Icons.arrow_back_ios)); + } +} diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..1986fd5b 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,9 +1,9 @@ //Server and local links String klocalLink = "127.0.0.1:8000"; -String kserverLink = "172.27.16.215:80"; +String kserverLink = "172.27.16.214"; //Login Service -String kAuthUrl = "172.27.16.215:80"; +String kAuthUrl = "172.27.16.214"; String kAuthLogin = "/api/auth/login/"; //Profile Service diff --git a/lib/main.dart b/lib/main.dart index 9ca81ff8..1fbd58de 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'dart:async'; import 'package:fusion/screens/Academic/Add_Drop_Courses/add_drop_courses.dart'; import 'package:fusion/screens/Complaint/ComplaintHistory/complain_history.dart'; +import 'package:fusion/screens/Complaint/ComplaintHistory/get_complaint_by_id.dart'; import 'package:fusion/screens/Complaint/Feedback/feedback.dart'; import 'package:fusion/screens/Complaint/LodgeComplaint/lodge_complaint.dart'; import 'package:fusion/screens/Establishment/establishment_home_page.dart'; @@ -60,7 +61,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { MediaQueryData windowData = - MediaQueryData.fromWindow(WidgetsBinding.instance.window); + MediaQueryData.fromWindow(WidgetsBinding.instance.window); windowData = windowData.copyWith( textScaleFactor: 1, ); @@ -71,10 +72,10 @@ class MyApp extends StatelessWidget { title: 'Fusion', debugShowCheckedModeBanner: false, theme: ThemeData( - // primarySwatch: Colors.blueGrey, + // primarySwatch: Colors.blueGrey, // colorSchemeSeed: Color(0xFF2085D0), colorSchemeSeed: Color(0xFFF36C35), - fontFamily: 'Nunito', + fontFamily: 'Nunito', useMaterial3: true, ), initialRoute: '/landing', @@ -119,10 +120,13 @@ class MyApp extends StatelessWidget { '/complaint/lodge_complaint': (context) => LodgeComplaint( ModalRoute.of(context)!.settings.arguments.toString()), '/complaint/complaint_history': (context) => ComplainHistory(), - '/complaint/feedback': (context) => ComplaintFeedBack(), + // '/complaint/feedback': (context) => ComplaintFeedBack(), '/profile': (context) => Profile(), '/health_center': (context) => HealthCenterMod( ModalRoute.of(context)!.settings.arguments.toString()), + '/complaint/fulldetail': (context) => GetComplaintByID( + ModalRoute.of(context)!.settings.arguments + as Map), '/health_center/healthcenter': (context) => HealthCenter(), '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), diff --git a/lib/screens/Complaint/ComplaintHistory/get_complaint_by_id.dart b/lib/screens/Complaint/ComplaintHistory/get_complaint_by_id.dart index 0161752b..d3353857 100644 --- a/lib/screens/Complaint/ComplaintHistory/get_complaint_by_id.dart +++ b/lib/screens/Complaint/ComplaintHistory/get_complaint_by_id.dart @@ -1,210 +1,368 @@ import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; +import 'package:fusion/Components/utils.dart'; +import 'package:fusion/services/complaint_service.dart'; class GetComplaintByID extends StatefulWidget { final Map data; GetComplaintByID(this.data); - @override _GetComplaintByIDState createState() => _GetComplaintByIDState(); } class _GetComplaintByIDState extends State { + Utils utils = Utils(); + final feedbackController = TextEditingController(); @override Widget build(BuildContext context) { - DateFormat formatter = DateFormat('yyyy-MM-dd'); - return Scaffold( appBar: AppBar( + backgroundColor: Colors.white, + leading: utils.leadingPopIconsButton(utils.primarycolor, context), title: Text( "Complaint Details", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 23), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 23, + color: utils.primarycolor), ), + // actions: [IconButton(onPressed: () {}, icon: Icon(Icons.menu))], ), - body: ListView( - children: [ - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Complaint ID : ${widget.data['id'].toString()}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Complaint Date : ${widget.data['complaint_date'].substring(0, 10)}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Complaint Finish : ${widget.data['complaint_finish'].toString()}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Location : ${widget.data['location']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Specific Location : ${widget.data['specific_location']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Details : ${widget.data['details']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Status : ${widget.data['status']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Remarks : ${widget.data['remarks']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Flag : ${widget.data['flag']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Reason : ${widget.data['reason']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Feedback : ${widget.data['feedback']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Upload Complaint : ${widget.data['']}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Comment : ${widget.data['comment'].toString()}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Complainer : ${widget.data['complainer'].toString()}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration: utils.containerBorder(utils.primarycolor), + child: Column( + children: [ + Text( + "Complainer Details ", + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.7)), + ), + Container( + color: utils.primarycolor, + height: 1, + width: MediaQuery.of(context).size.width, + ), + paddwithchoice(10), + detailabout(" Id : ", widget.data["complainer"].toString()), + paddwithchoice(25), + Text( + "Complaint Details ", + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.7)), + ), + Container( + height: 1, + color: utils.primarycolor, + width: MediaQuery.of(context).size.width, + ), + paddwithchoice(20), + detailabout("Complaint Id: ", widget.data["id"].toString()), + paddBox(), + detailabout("Complaint time: ", + parsetime(widget.data["complaint_date"].toString())), + paddBox(), + detailabout("Complaint Date: ", + widget.data["complaint_finish"].toString()), + paddBox(), + detailabout("Complaint Type: ", + widget.data["complaint_type"].toString()), + paddBox(), + detailabout("Location: ", widget.data["location"].toString()), + paddBox(), + detailabout("Specific Location: ", + widget.data["specific_location"].toString()), + paddBox(), + detailabout( + "Full Details: ", widget.data["details"].toString()), + paddBox(), + status(widget.data["status"]), + paddBox(), + detailabout( + "Remarks: ", + widget.data["ramarks"] == null + ? "N/A" + : widget.data["ramarks"]), + paddBox(), + detailabout( + "Worker assigned: ", + widget.data["worker_id"] == null + ? "Not Assigned" + : widget.data["worker_id"].toString()), + paddwithchoice(30), + Text( + "Comments and Feedback", + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.7)), + ), + Container( + color: utils.primarycolor, + height: 1, + width: MediaQuery.of(context).size.width, + ), + paddwithchoice(20), + if (widget.data["feedback"] == "" && + widget.data["status"] == 2) ...[ + SizedBox( + width: MediaQuery.of(context).size.width * 0.88, + height: 30, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "Feedback: ", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.6)), + ), + Container( + // color: Colors.black.withOpacity(0.1), + alignment: Alignment.center, + height: 30, + width: MediaQuery.of(context).size.width * 0.65, + child: TextField( + controller: feedbackController, + decoration: InputDecoration( + isCollapsed: true, + enabledBorder: InputBorder.none, + hintText: "give feedback"), + onSubmitted: (String value) async { + if (value != "") { + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text("FeedBack.."), + content: Text(value), + actions: [ + TextButton( + onPressed: () async { + ComplaintService auth = + ComplaintService(); + bool lodge = + await auth.updateComplaint( + (widget.data["id"]), + widget.data["complaint_date"] + .toString(), + widget + .data["complaint_finish"] + .toString(), + widget.data["complaint_type"] + .toString(), + widget.data["location"] + .toString(), + widget + .data["specific_location"] + .toString(), + widget.data["details"] + .toString(), + widget.data["status"] + .toString(), + widget.data["remarks"] + .toString(), + widget.data["flag"] + .toString(), + widget.data["reason"] + .toString(), + value, + widget.data["comment"] + .toString(), + widget.data["complainer"] + .toString(), + ); + final String completed = + "Thank you for your feedback"; + final String nc = + "Feedback not uploaded successfully, Kindly try after some time"; + final snackBar = SnackBar( + content: Text( + lodge == true + ? completed + : nc, + style: TextStyle( + color: Colors.white, + fontWeight: + FontWeight.w600, + ), + ), + backgroundColor: Colors.grey, + duration: + Duration(seconds: 1), + shape: StadiumBorder(), + behavior: + SnackBarBehavior.floating, + ); + ScaffoldMessenger.of(context) + .showSnackBar(snackBar); + Navigator.pop(context); + }, + child: Text("Give Feedback")), + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text("cancel")) + ], + ); + }); + } else { + final snackBar = SnackBar( + content: Text( + 'Feedback can not be empty.', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + ), + ), + backgroundColor: Colors.grey, + duration: Duration(seconds: 1), + shape: StadiumBorder(), + behavior: SnackBarBehavior.floating, + ); + ScaffoldMessenger.of(context) + .showSnackBar(snackBar); + } + }, + ), + ) + ], + ), + ) + ] else ...[ + detailabout( + "Feedback: ", + widget.data["feedback"] == "" + ? "N/A" + : widget.data["feedback"]), + ], + paddBox(), + detailabout( + "Comments: ", + widget.data["comment"] == null + ? "N/A" + : widget.data["comment"]), + paddwithchoice(30), + ], ), ), - Container( - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - height: 80, - color: Colors.grey, - child: Text( - "Worker ID : ${widget.data['worker_id'].toString()}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.white), - ), + ), + ), + ); + } + + Widget detailabout(String type, String data) { + return Padding( + padding: const EdgeInsets.only(left: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + type, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.6)), ), + Text( + data, + style: TextStyle(fontSize: 16, color: Colors.black), + ) ], ), ); } + + Widget paddBox() { + return SizedBox( + height: 5, + ); + } + + Widget paddwithchoice(double height) { + return SizedBox( + height: height, + ); + } +} + +String parsetime(String data) { + var date = DateTime.parse(data); + if (date.hour <= 9 && date.minute <= 9) { + return "0${date.hour} : 0${date.minute}"; + } else if (date.hour <= 9) { + return "0${date.hour} : ${date.minute}"; + } else if (date.minute <= 9) { + return "${date.hour} : 0${date.minute}"; + } else { + return "${date.hour} : ${date.minute}"; + } +} + +String parseDate(String data) { + var date = DateTime.parse(data); + return "${date.year} / ${date.month} / ${date.day}"; +} + +Widget status(int st) { + return Padding( + padding: const EdgeInsets.only(left: 10), + child: Row( + children: [ + Text( + "Status: ", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.6)), + ), + getStatus(st), + addIcon(st), + ], + ), + ); +} + +Icon addIcon(int i) { + if (i == 0) { + return Icon( + Icons.pending, + color: Color.fromARGB(255, 206, 155, 44), + ); + } else if (i == 1) { + return Icon( + Icons.motion_photos_pause_outlined, + color: Colors.red, + ); + } else { + return Icon( + Icons.check_circle, + color: Colors.green, + ); + } +} + +Text getStatus(int i) { + if (i == 0) { + return Text("Pending", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color.fromARGB(255, 206, 155, 44))); + } else if (i == 1) { + return Text("On-Hold", + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.w600, color: Colors.red)); + } else + return Text("Completed", + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.w600, color: Colors.green)); } diff --git a/lib/screens/Complaint/ComplaintHistory/pending_complaints.dart b/lib/screens/Complaint/ComplaintHistory/pending_complaints.dart index 3da80fbd..c2751876 100644 --- a/lib/screens/Complaint/ComplaintHistory/pending_complaints.dart +++ b/lib/screens/Complaint/ComplaintHistory/pending_complaints.dart @@ -1,22 +1,11 @@ import 'dart:async'; import 'dart:convert'; - import 'package:flutter/material.dart'; import 'package:fusion/models/complaints.dart'; import 'package:fusion/services/complaint_service.dart'; import 'package:http/http.dart'; -//A dummy list of sample json returned by backend (this complaints will bew removed when backend is available) -final List> complaints = [ - { - "S.No": " ", - "Date": " ", - "Complaint Type": " ", - "Location": " ", - "Details": " ", - "Worker Name": " " - } -]; +import '../../../Components/utils.dart'; class PendingComplaints extends StatefulWidget { @override @@ -25,14 +14,16 @@ class PendingComplaints extends StatefulWidget { class _PendingComplaintsState extends State { bool _loading = true; - + Utils utils = Utils(); late StreamController _complaintController; late ComplaintService complaintService; late ComplaintDataUserStudent data; - + int st = 3; + String cuuItemp = "All"; + List item = ["All", "Pending", "On-hold", "Completed"]; + Map map = {"All": 3, "Pending": 0, "On-hold": 1, "Completed": 2}; @override void initState() { - // TODO: implement initState super.initState(); _complaintController = StreamController(); complaintService = ComplaintService(); @@ -45,7 +36,8 @@ class _PendingComplaintsState extends State { Response response = await complaintService.getComplaint(); setState(() { data = ComplaintDataUserStudent.fromJson(jsonDecode(response.body)); - print(data.student_complain); + print("complain ${data.student_complain}"); + // print(object) //print(data); _loading = false; }); @@ -63,88 +55,295 @@ class _PendingComplaintsState extends State { @override Widget build(BuildContext context) { return Scaffold( - body: _loading == true - ? Center(child: CircularProgressIndicator()) - : listView()); + appBar: AppBar( + backgroundColor: utils.primarybackgroundcolor, + leading: utils.leadingPopIconsButton(utils.primarycolor, context), + title: Text( + "Complaints...", + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + color: utils.primarycolor), + ), + actions: [ + Card( + elevation: 1, + child: Container( + alignment: Alignment.center, + height: 40, + width: 110, + child: DropdownButton( + value: cuuItemp, + underline: SizedBox(), + onChanged: (value) { + setState(() { + cuuItemp = value.toString(); + st = map[cuuItemp]!; + }); + }, + items: item.map>((e) { + return DropdownMenuItem( + value: e, + child: Text( + e, + style: TextStyle( + color: Colors.purple.withOpacity(0.7), + fontWeight: FontWeight.w600), + )); + }).toList(), + ), + ), + ) + ], + ), + body: RefreshIndicator( + onRefresh: () async { + getData(); + // Navigator.pop(context); + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => PendingComplaints())); + }, + child: _loading == true + ? Center(child: CircularProgressIndicator()) + // FOr showing List of cards wich contains all data about Complaints + : ListView.builder( + itemCount: data.student_complain?.length, + itemBuilder: (context, index) { + Map _comp = data.student_complain?[index]; + print(_comp); + return fun(st, _comp, context); + }), + )); } } -//Main component to render the table.. -ListView listView() { - return ListView( - children: [ - SizedBox(height: 20), - //To scroll pass the width - SingleChildScrollView( - scrollDirection: Axis.horizontal, - //Component to lay table on the page - child: DataTable( - // headingRowColor: - // MaterialStateColor.resolveWith((states) => Colors.blue), - dataRowHeight: 80.0, - columnSpacing: 10.0, - columns: [ - //DataColumns to lay columns of the table - DataColumn( - label: Text('S.No', - style: - TextStyle(fontSize: 13, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Date', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Complaint Type', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Location', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Details', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Worker Name', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), +Widget fun(int obj, Map _data, BuildContext context) { + if (obj != 3) { + return complaintElement(_data, context, obj); + } else + return allElement(_data, context); +} + +Widget complaintElement( + Map _data, BuildContext context, int obj) { + final ktextstyle = TextStyle( + color: Colors.black.withOpacity(0.65), + fontSize: 14, + fontWeight: FontWeight.w700); + if (_data["status"] == obj) { + return Card( + elevation: 2, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + side: BorderSide( + color: Utils().primarycolor.withOpacity(0.6), width: 1.12)), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column(children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Complaint Id: ${_data["id"]}", + style: ktextstyle, + ), + Text( + "Complaint Date: ${_data["complaint_finish"]}", + style: ktextstyle, + ) + ], + ), + SizedBox( + height: 13, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Type: ${_data["complaint_type"]}", + style: ktextstyle, + ), + status(_data["status"]) + ], + ), + SizedBox( + height: 13, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Location: ${_data["location"]}", + style: ktextstyle, + ), + Text( + "Worker assigned: ${_data["worker_id"].toString()}", + style: ktextstyle, + ) + ], + ), + SizedBox( + height: 13, + ), + TextButton( + onPressed: () { + Navigator.pushNamed(context, '/complaint/fulldetail', + arguments: _data); + }, + child: Container( + decoration: BoxDecoration( + color: Utils().primarycolor.withOpacity(0.9), + borderRadius: BorderRadius.all(Radius.circular(6))), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Get full details", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 17), + ), + ), + )) + ]), + ), + ); + } + return Container(); +} + +Widget allElement(Map _data, BuildContext context) { + final ktextstyle = TextStyle( + color: Colors.black.withOpacity(0.65), + fontSize: 14, + fontWeight: FontWeight.w700); + return Card( + elevation: 2, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + side: BorderSide( + color: Utils().primarycolor.withOpacity(0.6), width: 1.12)), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column(children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Complaint Id: ${_data["id"]}", + style: ktextstyle, + ), + Text( + "Complaint Date: ${_data["complaint_finish"]}", + style: ktextstyle, + ) ], - //This method will get lay all the rows - rows: complaintList(), ), + SizedBox( + height: 13, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Type: ${_data["complaint_type"]}", + style: ktextstyle, + ), + status(_data["status"]) + ], + ), + SizedBox( + height: 13, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Location: ${_data["location"]}", + style: ktextstyle, + ), + Text( + "Worker assigned: ${_data["worker_id"].toString()}", + style: ktextstyle, + ) + ], + ), + SizedBox( + height: 13, + ), + TextButton( + onPressed: () { + Navigator.pushNamed(context, '/complaint/fulldetail', + arguments: _data); + }, + child: Container( + decoration: BoxDecoration( + color: Utils().primarycolor.withOpacity(0.9), + borderRadius: BorderRadius.all(Radius.circular(6))), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Get full details", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 17), + ), + ), + )) + ]), + ), + ); +} + +Widget status(int st) { + return Row( + children: [ + Text( + "Status: ", + style: TextStyle( + color: Colors.black.withOpacity(0.65), + fontSize: 14, + fontWeight: FontWeight.w700), ), + addIcon(st), + getStatus(st) ], ); } -List complaintList() { - //Get the list of json and map through, to select each json and lay row to the table.. - return complaints - .map( - ((element) => DataRow( - cells: [ - DataCell(Container( - width: 40, //SET width - child: Text(element[ - "S.No"]!))), //Extracting from Map element the value - DataCell(Container( - width: 57, //SET width - child: Text(element["Date"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Complaint Type"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Location"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Details"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Worker Name"]!))), - ], - )), - ) - .toList(); +Icon addIcon(int i) { + if (i == 0) { + return Icon( + Icons.pending, + color: Color.fromARGB(255, 206, 155, 44), + ); + } else if (i == 1) { + return Icon( + Icons.motion_photos_pause_outlined, + color: Colors.red, + ); + } else { + return Icon( + Icons.check_circle, + color: Colors.green, + ); + } +} + +Text getStatus(int i) { + if (i == 0) { + return Text("Pending", + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 14, + color: Color.fromARGB(255, 206, 155, 44))); + } else if (i == 1) { + return Text("On-Hold", + style: TextStyle( + fontWeight: FontWeight.w700, fontSize: 14, color: Colors.red)); + } else + return Text("Completed", + style: TextStyle( + fontWeight: FontWeight.w700, fontSize: 14, color: Colors.green)); } diff --git a/lib/screens/Complaint/ComplaintHistory/update_complaint.dart b/lib/screens/Complaint/ComplaintHistory/update_complaint.dart index 8ea7af87..e535e15a 100644 --- a/lib/screens/Complaint/ComplaintHistory/update_complaint.dart +++ b/lib/screens/Complaint/ComplaintHistory/update_complaint.dart @@ -3,13 +3,16 @@ import 'package:flutter/services.dart'; import 'package:fusion/services/complaint_service.dart'; import 'package:intl/intl.dart'; -const kTextFieldInputDecoration = InputDecoration( - filled: true, - fillColor: Colors.white, - contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), - border: - OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(15))), -); +kTextFieldInputDecoration(String hint) { + return InputDecoration( + hintText: hint, + filled: true, + fillColor: Colors.white, + contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), + border: + OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(15))), + ); +} class UpdateComplaint extends StatefulWidget { final int? id; @@ -27,14 +30,14 @@ class UpdateComplaint extends StatefulWidget { class _UpdateComplaintState extends State { @override Widget build(BuildContext context) { - DateTime? complaint_finish = DateTime.now(); + DateTime? complaintFinish = DateTime.now(); DateFormat formatter = DateFormat('yyyy-MM-dd'); - String? finishedDate = formatter.format(complaint_finish); - String complaint_date = DateTime.now().toString(); + String? finishedDate = formatter.format(complaintFinish); + String complaintDate = DateTime.now().toString(); print(finishedDate); - String? complaint_type = widget.complaintType; + String? complaintType = widget.complaintType; String? location = widget.location; - String? specific_location; + String? specificLocation; String? details; String? status = "0"; @@ -45,13 +48,26 @@ class _UpdateComplaintState extends State { String? complainer = widget.complainerRollNo; return Scaffold( - appBar: AppBar(title: Text('Update Complaint')), + appBar: AppBar( + title: Text('Update Complaint'), + backgroundColor: Colors.black, + ), body: Container( padding: EdgeInsets.all(16), child: ListView( children: [ SizedBox( - height: 30, + height: 5, + ), + Text( + "Complaint Id: ${widget.id}", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.7)), + ), + SizedBox( + height: 15, ), Text( 'Complaint Type *', @@ -61,22 +77,19 @@ class _UpdateComplaintState extends State { ), ), SizedBox( - height: 20, + height: 15, ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 16), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey, - ), - borderRadius: BorderRadius.circular(15), - ), - child: Text( - widget.complaintType!, - style: TextStyle(fontSize: 18), + Container( + padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, ), + borderRadius: BorderRadius.circular(15), + ), + child: Text( + widget.complaintType!, + style: TextStyle(fontSize: 18), ), ), SizedBox( @@ -123,14 +136,16 @@ class _UpdateComplaintState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: + kTextFieldInputDecoration("Room Number, Floor, Block etc. "), onChanged: (input) { - specific_location = input; + specificLocation = input; }, validator: (String? value) { if (value!.isEmpty) { return 'Please enter specific_location'; } + return null; }, ), SizedBox( @@ -151,7 +166,7 @@ class _UpdateComplaintState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("What is your Complaint?"), onChanged: (input) { details = input; }, @@ -159,6 +174,7 @@ class _UpdateComplaintState extends State { if (value!.isEmpty) { return 'Please enter details'; } + return null; }, ), SizedBox( @@ -170,11 +186,11 @@ class _UpdateComplaintState extends State { ComplaintService auth = ComplaintService(); bool lodge = await auth.updateComplaint( widget.id!, - complaint_date, + complaintDate, finishedDate, - complaint_type!, + complaintType!, location!, - specific_location!, + specificLocation!, details!, status, widget.remarks!, diff --git a/lib/screens/Complaint/Feedback/feedback.dart b/lib/screens/Complaint/Feedback/feedback.dart index 799533c9..6cea7662 100644 --- a/lib/screens/Complaint/Feedback/feedback.dart +++ b/lib/screens/Complaint/Feedback/feedback.dart @@ -1,112 +1,17 @@ -// import 'package:date_field/date_field.dart'; import 'package:flutter/material.dart'; -// import '../Constants/constants.dart'; -//A dummy list of sample json returned by backend (this onHoldComplains will bew removed when backend is available) -final List> feedbackList = [ - { - "Date": " ", - "Type": " ", - "Location": " ", - "Details": " ", - "Status": " ", - "Worker Name": " ", - "Feedback": " " - } -]; +class feedback extends StatefulWidget { + const feedback({key}); -class ComplaintFeedBack extends StatefulWidget { @override - _ComplaintFeedBackState createState() => _ComplaintFeedBackState(); + State createState() => _feedbackState(); } -class _ComplaintFeedBackState extends State { +class _feedbackState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - backgroundColor: Colors.black, - title: Text( - "Feedback", - style: TextStyle(color: Colors.white), - )), - body: SingleChildScrollView( - scrollDirection: Axis.horizontal, - //Component to lay table on the page - child: DataTable( - // headingRowColor: - // MaterialStateColor.resolveWith((states) => Colors.blue), - dataRowHeight: 80.0, - columnSpacing: 10.0, - columns: [ - //DataColumns to lay columns of the table - DataColumn( - label: Text('Date', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Type', - style: - TextStyle(fontSize: 13, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Location', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Details', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Status', - style: - TextStyle(fontSize: 13, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Worker Name', - style: - TextStyle(fontSize: 14, fontWeight: FontWeight.bold))), - DataColumn( - label: Text('Feedback', - style: - TextStyle(fontSize: 1, fontWeight: FontWeight.bold))), - ], - //This method will get lay all the rows - rows: feedBacks(), - ), - ), + return Container( + ); } } - -List feedBacks() { - //Get the list of json and map through, to select each json and lay row to the table.. - return feedbackList - .map( - ((element) => DataRow( - cells: [ - //Extracting from Map element the value - DataCell(Container( - width: 57, //SET width - child: Text(element["Date"]!))), - DataCell(Container( - width: 40, //SET width - child: Text(element["Type"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Location"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Details"]!))), - DataCell(Container( - width: 40, //SET width - child: Text(element["Status"]!))), - DataCell(Container( - width: 57, //SET width - child: Text(element["Worker Name"]!))), - DataCell(Container( - width: 40, //SET width - child: Text(element["Feedback"]!))), - ], - )), - ) - .toList(); -} diff --git a/lib/screens/Complaint/LodgeComplaint/lodge_complaint.dart b/lib/screens/Complaint/LodgeComplaint/lodge_complaint.dart index 45756975..e8b7d3e0 100644 --- a/lib/screens/Complaint/LodgeComplaint/lodge_complaint.dart +++ b/lib/screens/Complaint/LodgeComplaint/lodge_complaint.dart @@ -5,14 +5,24 @@ import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; import 'package:intl/intl.dart'; -const kTextFieldInputDecoration = InputDecoration( - filled: true, - fillColor: Colors.white, - contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), - border: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(32)), - ), -); +import '../../../Components/utils.dart'; + +kTextFieldInputDecoration(String hint) { + return InputDecoration( + hintText: hint, + filled: true, + fillColor: Colors.white, + contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Utils().primarycolor), + borderRadius: BorderRadius.all(Radius.circular(32)), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Utils().primarycolor), + borderRadius: BorderRadius.all(Radius.circular(32)), + ), + ); +} class LodgeComplaint extends StatefulWidget { final String? complainerRollNo; @@ -22,7 +32,9 @@ class LodgeComplaint extends StatefulWidget { } class _LodgeComplaintState extends State { - final GlobalKey _formKey = GlobalKey(); + var sl = TextEditingController(); + var det = new TextEditingController(); + Utils utils = Utils(); String? complaint_type; List complaintTypeItem = [ 'Electricity', @@ -48,12 +60,12 @@ class _LodgeComplaintState extends State { var service = locator(); @override Widget build(BuildContext context) { - DateTime? complaint_finish = DateTime.now(); + DateTime? complaintFinish = DateTime.now(); DateFormat formatter = DateFormat('yyyy-MM-dd'); - String formattedDate = formatter.format(complaint_finish); + String formattedDate = formatter.format(complaintFinish); print(formattedDate); - String? specific_location; - String? details; + String? specificLocation = ""; + String? details = ""; String? status = "0"; String? remarks = "On-Hold"; String? flag = "0"; @@ -61,14 +73,22 @@ class _LodgeComplaintState extends State { String? feedback = ""; String? comment = "None"; String? complainer = widget.complainerRollNo; - String? worker_id = ""; + String? workerId = ""; + renew() { + setState(() { + sl.clear(); + det.clear(); + }); + } return Scaffold( appBar: AppBar( - backgroundColor: Colors.black, + backgroundColor: utils.primarybackgroundcolor, + leading: utils.leadingPopIconsButton(utils.primarycolor, context), title: Text( "Lodge Complaint", - style: TextStyle(color: Colors.white), + style: TextStyle( + color: utils.primarycolor, fontWeight: FontWeight.bold), )), body: SingleChildScrollView( child: Container( @@ -79,9 +99,17 @@ class _LodgeComplaintState extends State { Text( 'Add a new Complaint', style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 15, - ), + fontWeight: FontWeight.w600, + fontSize: 20, + color: Colors.black.withOpacity(0.6)), + ), + SizedBox( + height: 5, + ), + Container( + height: 1, + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration(color: Colors.black.withOpacity(0.6)), ), SizedBox( height: 30, @@ -90,7 +118,7 @@ class _LodgeComplaintState extends State { 'Complaint Type *', style: TextStyle( fontWeight: FontWeight.w500, - fontSize: 15, + fontSize: 18, ), ), Padding( @@ -100,12 +128,12 @@ class _LodgeComplaintState extends State { padding: EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( border: Border.all( - color: Colors.grey, + color: utils.primarycolor, ), borderRadius: BorderRadius.circular(15), ), child: DropdownButton( - hint: Text('Select Item'), + hint: Text('Select Complaint Type'), dropdownColor: Colors.grey[200], icon: Icon(Icons.arrow_drop_down), isExpanded: true, @@ -131,13 +159,13 @@ class _LodgeComplaintState extends State { ), ), SizedBox( - height: 30, + height: 15, ), Text( 'Location *', style: TextStyle( fontWeight: FontWeight.w500, - fontSize: 15, + fontSize: 18, ), ), Padding( @@ -147,12 +175,12 @@ class _LodgeComplaintState extends State { padding: EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( border: Border.all( - color: Colors.grey, + color: utils.primarycolor, ), borderRadius: BorderRadius.circular(15), ), child: DropdownButton( - hint: Text('Select Item'), + hint: Text('Select Location'), dropdownColor: Colors.grey[200], icon: Icon(Icons.arrow_drop_down), isExpanded: true, @@ -176,13 +204,13 @@ class _LodgeComplaintState extends State { ), ), SizedBox( - height: 20, + height: 15, ), Text( 'Specific Location *', style: TextStyle( fontWeight: FontWeight.w500, - fontSize: 15, + fontSize: 18, ), ), SizedBox( @@ -190,17 +218,20 @@ class _LodgeComplaintState extends State { ), TextFormField( autofocus: false, + controller: sl, style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: + kTextFieldInputDecoration("Room Number, Floor, Block etc."), onChanged: (input) { - specific_location = input; + specificLocation = input; }, validator: (String? value) { if (value!.isEmpty) { return 'Please enter specific_location'; } + return null; }, ), SizedBox( @@ -210,7 +241,7 @@ class _LodgeComplaintState extends State { 'Complaint Details *', style: TextStyle( fontWeight: FontWeight.w500, - fontSize: 15, + fontSize: 18, ), ), SizedBox( @@ -218,10 +249,12 @@ class _LodgeComplaintState extends State { ), TextFormField( autofocus: false, + controller: det, style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: + kTextFieldInputDecoration("What is your Complaint?"), onChanged: (input) { details = input; }, @@ -229,29 +262,41 @@ class _LodgeComplaintState extends State { if (value!.isEmpty) { return 'Please enter details'; } + return null; }, ), SizedBox( - height: 30, + height: 15, + ), + Text( + "*Complaint will be registered with your User Id: ${widget.complainerRollNo}", + style: TextStyle( + fontSize: 12.4, + fontWeight: FontWeight.w600, + color: Colors.black.withOpacity(0.7)), + ), + SizedBox( + height: 20, ), Center( child: ElevatedButton( onPressed: () async { + print("working"); ComplaintService auth = ComplaintService(); bool lodge = await auth.lodgeComplaint( formattedDate, complaint_type!, location!, - specific_location, - details!, + sl.text, + det.text, status, remarks, flag, reason, feedback, comment, - complainer, - worker_id); + widget.complainerRollNo, + workerId); TextInput.finishAutofillContext(); if (lodge == true) { return showDialog( @@ -262,7 +307,9 @@ class _LodgeComplaintState extends State { actions: [ ElevatedButton( onPressed: () { + // Navigator.popUntil(context, ) Navigator.of(ctx).pop(); + renew(); }, child: Text("okay"), ), @@ -291,16 +338,17 @@ class _LodgeComplaintState extends State { padding: const EdgeInsets.all(8.0), child: Text( 'Submit', - style: TextStyle(fontSize: 20), + style: TextStyle( + fontSize: 20, color: utils.primarybackgroundcolor), ), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (Set states) { if (states.contains(MaterialState.pressed)) - return Colors.deepOrange; - return Colors - .deepOrangeAccent; // Use the component's default. + return utils.lightgrey; + return utils + .primarycolor; // Use the component's default. }, ), ), diff --git a/lib/screens/Complaint/complaint.dart b/lib/screens/Complaint/complaint.dart index f1b5ed77..96bce78a 100644 --- a/lib/screens/Complaint/complaint.dart +++ b/lib/screens/Complaint/complaint.dart @@ -1,16 +1,13 @@ import 'dart:async'; import 'dart:convert'; -import 'package:fusion/Components/appBar.dart'; import 'package:fusion/models/profile.dart'; +import 'package:fusion/screens/Complaint/ComplaintHistory/pending_complaints.dart'; import 'package:fusion/services/profile_service.dart'; import 'package:http/http.dart'; -import 'ComplaintHistory/complain_history.dart'; import 'package:flutter/material.dart'; -import 'package:fusion/Components/side_drawer.dart'; -import 'dart:ui'; -import 'LodgeComplaint/lodge_complaint.dart'; -import 'Feedback/feedback.dart'; -import 'package:provider/provider.dart'; + +import '../../Components/side_drawer.dart'; +import '../../Components/utils.dart'; class Complaint extends StatefulWidget { String? token; @@ -20,9 +17,7 @@ class Complaint extends StatefulWidget { } class _ComplaintState extends State { - bool _loading1 = true; - bool _loading2 = false; - bool _loading3 = false; + Utils utils = Utils(); bool _loading = true; late StreamController _profileController; @@ -61,7 +56,37 @@ class _ComplaintState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: DefaultAppBar().buildAppBar(), + backgroundColor: Colors.white, + appBar: AppBar( + leading: Builder(builder: (BuildContext context) { + return IconButton( + onPressed: () { + Scaffold.of(context).openDrawer(); + }, + tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip, + icon: Icon( + Icons.abc, + color: utils.primarycolor, + )); + }), + backgroundColor: utils.primarybackgroundcolor, + title: Container( + alignment: Alignment.center, + child: Text( + "Fusion", + style: TextStyle( + color: utils.primarycolor, fontWeight: FontWeight.bold), + ), + ), + actions: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: IconButton( + onPressed: () {}, + icon: Icon(Icons.notifications, color: utils.lightgrey)), + ) + ], + ), drawer: SideDrawer(), body: _loading == true ? Center(child: CircularProgressIndicator()) @@ -76,6 +101,7 @@ class _ComplaintState extends State { margin: EdgeInsets.symmetric(horizontal: 50, vertical: 20), shadowColor: Colors.black, child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.only(top: 20), @@ -110,138 +136,124 @@ class _ComplaintState extends State { ], ), ), - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 50, vertical: 20), - shadowColor: Colors.black, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextButton( - onPressed: () { - setState(() { - _loading1 = true; - _loading2 = false; - _loading3 = false; - Navigator.pushNamed( - context, '/complaint/lodge_complaint', - arguments: data.user != null - ? data.user!['username'] - : "null"); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Lodge a Complaint', - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 18, - color: - _loading1 ? Colors.black : Colors.black26, + SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + onTap: () { + Navigator.pushNamed( + context, '/complaint/lodge_complaint', + arguments: data.user != null + ? data.user!['username'] + : "null"); + }, + child: Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10)), + shadowColor: Colors.black, + child: Container( + decoration: utils.containerBorder(Colors.grey), + alignment: Alignment.center, + height: 125, + width: MediaQuery.of(context).size.width * 0.4, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.add, + size: 60, + // shadows: [], ), - ), - Icon( - Icons.arrow_forward, - color: _loading1 - ? Colors.deepOrangeAccent - : Colors.white, - ) - ], - ), - ), - SizedBox(height: 10), - TextButton( - onPressed: () { - setState(() { - _loading1 = false; - _loading2 = true; - _loading3 = false; - Navigator.pushNamed( - context, - '/complaint/complaint_history', - ); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Complaint History', - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 18, - color: - _loading2 ? Colors.black : Colors.black26, + SizedBox( + height: 4, + ), + Text( + "Lodge a complaint", + style: TextStyle(fontSize: 16), ), - ), - Icon( - Icons.arrow_forward, - color: _loading2 - ? Colors.deepOrangeAccent - : Colors.white, - ) - ], + SizedBox( + height: 6, + ) + ], + ), ), ), - SizedBox(height: 10), - TextButton( - onPressed: () { - setState(() { - _loading1 = false; - _loading2 = false; - _loading3 = true; - Navigator.pushNamed( - context, - '/complaint/feedback', - ); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Feedback', - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 18, - color: - _loading3 ? Colors.black : Colors.black26, + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PendingComplaints())); + }, + child: Card( + shadowColor: Colors.black, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10)), + child: Container( + decoration: utils.containerBorder(Colors.grey), + alignment: Alignment.center, + height: 125, + width: MediaQuery.of(context).size.width * 0.4, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.history_edu_outlined, + size: 50, + ), + SizedBox( + height: 4, ), - ), - Icon( - Icons.arrow_forward, - color: _loading3 - ? Colors.deepOrangeAccent - : Colors.white, - ) - ], + Text("Complaint History"), + SizedBox( + height: 6, + ) + ], + ), ), ), - SizedBox(height: 10), - ], - ), - ), - // _loading1 - // ? LodgeComplaint( - // data.user != null ? data.user!['username'] : "null") - // : SizedBox( - // height: 2, - // ), - // _loading2 - // ? ComplainHistory() - // : SizedBox( - // height: 5, - // ), - // _loading3 - // ? FeedBack() - // : SizedBox( - // height: 2, - // ), + ) + ], + ) ], ), ), ); } + + Widget buttonwidget(String name, IconData icons) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration: BoxDecoration( + color: Colors.purple, + borderRadius: BorderRadius.all(Radius.circular(10)), + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon( + icons, + color: Colors.white, + ), + SizedBox( + width: 8, + ), + Text( + name, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: Colors.white), + ) + ], + ), + ), + ), + ); + } }