From 08a1dc79b5389b8dd846f1056c9a44e62df627f9 Mon Sep 17 00:00:00 2001 From: Devendra Date: Fri, 27 Jan 2023 04:25:43 +0530 Subject: [PATCH 01/14] Added RSPC Module --- android/app/build.gradle | 2 +- db/patents.csv | 5 + lib/Components/side_drawer.dart | 31 +- lib/main.dart | 14 + lib/screens/Healthcenter/Appointment.dart | 235 ++++---- .../Healthcenter/ambulanceRequest.dart | 121 ++-- lib/screens/Healthcenter/feedback.dart | 96 +-- .../consultancy_project.dart | 281 +++++++++ lib/screens/RSPC/Patents/patents.dart | 64 ++ lib/screens/RSPC/Patents/patents_tab.dart | 91 +++ .../ResearchProject/research_project.dart | 382 ++++++++++++ lib/screens/RSPC/rspc.dart | 559 ++++++++++++++++++ 12 files changed, 1651 insertions(+), 230 deletions(-) create mode 100644 db/patents.csv create mode 100644 lib/screens/RSPC/ConsultancyProject/consultancy_project.dart create mode 100644 lib/screens/RSPC/Patents/patents.dart create mode 100644 lib/screens/RSPC/Patents/patents_tab.dart create mode 100644 lib/screens/RSPC/ResearchProject/research_project.dart create mode 100644 lib/screens/RSPC/rspc.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index 49ec907a..94e71df6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 31 + compileSdkVersion 32 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/db/patents.csv b/db/patents.csv new file mode 100644 index 00000000..bf18b135 --- /dev/null +++ b/db/patents.csv @@ -0,0 +1,5 @@ +"Patend ID","IPD Form","Patent PDF","Status" +"17","EDP_Presentation_tGhmx5M.pdf","EDP_Presentation_cjWYh29.pdf","Pending" +"16","EDP_Presentation_dDC7iY8.pdf","EDP_Presentation_gtDJ0Gy.pdf","Approved" +"19","EDP_Presentation_QwCDZAv.pdf","EDP_Presenstation_gethd0.pdf","Disapproved" +"15","EDP_Presentation_QWWeeee.pdf","EDP_Presentation_G2vrh3s.pdf","Pending" diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..ed77b59d 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -122,27 +122,44 @@ class _SideDrawerState extends State { isActive: true, ), ModulesPadding( - line: 'Gymkhana Module', - pageMover: '/gymkhana_homepage'), + line: 'Gymkhana Module', + pageMover: '/gymkhana_homepage', + isActive: true, + ), + ModulesPadding( - line: 'Establishment Module', - pageMover: '/establishment'), + line: 'Establishment Module', + pageMover: '/establishment', + isActive: true, + ), ModulesPadding( - line: 'Library Module', - pageMover: '/library_homepage'), + line: 'Library Module', + pageMover: '/library_homepage', + isActive: true, + ), 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( line: 'Health Center Module', pageMover: '/health_center', + isActive: true, ), + ModulesPadding(line: 'Leave Module'), ModulesPadding(line: 'Placement Module'), ModulesPadding(line: 'Visitors Hostel Module'), ModulesPadding(line: 'File Tracking Module'), + ModulesPadding( + line: 'RSPC Module', + pageMover: '/rspc', + isActive: true, + ), ], ), ) diff --git a/lib/main.dart b/lib/main.dart index 97708725..dd50c480 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -35,6 +35,10 @@ import 'package:fusion/screens/Programme_Curriculum/Discipline/discipline.dart'; import 'package:fusion/screens/Programme_Curriculum/Programme/programme_home_page.dart'; import 'package:fusion/screens/Programme_Curriculum/Programme_Info/programme_info.dart'; import 'package:fusion/screens/Programme_Curriculum/programme_curriculum_home.dart'; +import 'package:fusion/screens/RSPC/Patents/patents.dart'; +import 'package:fusion/screens/RSPC/Patents/patents_tab.dart'; +import 'package:fusion/screens/RSPC/ConsultancyProject/consultancy_project.dart'; +import 'package:fusion/screens/RSPC/ResearchProject/research_project.dart'; import 'package:fusion/screens/landing_page.dart'; import 'package:fusion/screens/Healthcenter/healthcentermodule.dart'; import 'package:fusion/screens/Healthcenter/feedback.dart'; @@ -42,6 +46,7 @@ import 'package:fusion/screens/Healthcenter/viewschedule.dart'; import 'package:fusion/screens/Healthcenter/history.dart'; import 'package:fusion/screens/Healthcenter/HealthCenter.dart'; import 'package:fusion/services/service_locator.dart'; +import 'screens/RSPC/rspc.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); @@ -113,6 +118,15 @@ class MyApp extends StatelessWidget { '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), '/health_center/history': (context) => History(), + '/rspc': (context) => + RSPCModule(ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/research_project': (context) => AddResearchProject( + ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/consultancy_project': (context) => AddConsultancyProject( + ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/patents': (context) => + Patents(ModalRoute.of(context)!.settings.arguments.toString()), + // '/rspc/patents': (context) => Patents(), }, ); } diff --git a/lib/screens/Healthcenter/Appointment.dart b/lib/screens/Healthcenter/Appointment.dart index dd486166..0fc8baec 100644 --- a/lib/screens/Healthcenter/Appointment.dart +++ b/lib/screens/Healthcenter/Appointment.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:date_field/date_field.dart'; class Appointment extends StatefulWidget { - @override _AppointmentState createState() => _AppointmentState(); } @@ -10,128 +9,136 @@ class Appointment extends StatefulWidget { //int get _value=>_value; class _AppointmentState extends State { - int _value=1; + int _value = 1; @override Widget build(BuildContext context) { return Container( - // color: Colors.red, - width: 200, - //height: 120, - //color: Colors.blue, - alignment: Alignment.topCenter, - padding: EdgeInsets.all(30.0), - child:ListView( - children: [ - Text("Doctor",style:TextStyle(fontSize: 18,fontWeight: FontWeight.bold),textAlign: TextAlign.start,), - Padding( - padding:EdgeInsets.symmetric(horizontal:0.0), - child:Container( - height:0.5, - width:130.0, - color:Colors.black,),), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - DropdownButton( - dropdownColor: Colors.deepOrangeAccent, - elevation: 16, - value: _value, - isExpanded: true, - hint: Text("-SELECT-"), - items: [ - DropdownMenuItem( - child: Text("--SELECT--"), - value: 1, - ), - DropdownMenuItem( - child: Text("Dr Tony Gupta"), - value: 2, - ), - DropdownMenuItem( - child: Text("Dr Hrishi Goyal"), - value: 3, - - ), - DropdownMenuItem( - child: Text("Dr Preeti Singh"), - value: 4 - ), - ], - onChanged: (value) { - setState(() { - //_value = value; - }); - }), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - //SessionView, - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.event_note), - labelText: 'Date', - ), - mode: DateTimeFieldPickerMode.date, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, + // color: Colors.red, + width: 200, + //height: 120, + //color: Colors.blue, + alignment: Alignment.topCenter, + padding: EdgeInsets.all(30.0), + child: ListView( + children: [ + Text( + "Doctor", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 0.0), + child: Container( + height: 0.5, + width: 130.0, + color: Colors.black, ), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.access_time_rounded), - labelText: 'From Time', - ), - mode: DateTimeFieldPickerMode.time, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + DropdownButton( + dropdownColor: Colors.deepOrangeAccent, + elevation: 16, + value: _value, + isExpanded: true, + hint: Text("-SELECT-"), + items: [ + DropdownMenuItem( + child: Text("--SELECT--"), + value: 1, + ), + DropdownMenuItem( + child: Text("Dr Tony Gupta"), + value: 2, + ), + DropdownMenuItem( + child: Text("Dr Hrishi Goyal"), + value: 3, + ), + DropdownMenuItem(child: Text("Dr Preeti Singh"), value: 4), + ], + onChanged: (value) { + setState(() { + //_value = value; + }); + }), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + //SessionView, + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.event_note), + labelText: 'Date', ), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.access_time_rounded), - labelText: 'To Time', - ), - mode: DateTimeFieldPickerMode.time, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, + mode: DateTimeFieldPickerMode.date, + autovalidateMode: AutovalidateMode.always, + validator: (e) => + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { + print(value); + }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.access_time_rounded), + labelText: 'From Time', ), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - TextFormField( - cursorHeight: 30, - decoration: new InputDecoration( - labelText: "Issues/Symptoms", - fillColor: Colors.white, - border: new OutlineInputBorder( - ), - //fillColor: Colors.green - ), - style: new TextStyle( - fontFamily: "Poppins", - ), + mode: DateTimeFieldPickerMode.time, + autovalidateMode: AutovalidateMode.always, + validator: (e) => + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { + print(value); + }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.access_time_rounded), + labelText: 'To Time', ), - Padding(padding: EdgeInsets.symmetric(vertical: 5.0)), - Center(child:FlatButton( - child: Text('Submit', style: TextStyle(fontSize: 15.0),), - color: Colors.deepOrangeAccent, - onPressed: () {}, + mode: DateTimeFieldPickerMode.time, + autovalidateMode: AutovalidateMode.always, + validator: (e) => + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { + print(value); + }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + TextFormField( + cursorHeight: 30, + decoration: new InputDecoration( + labelText: "Issues/Symptoms", + fillColor: Colors.white, + border: new OutlineInputBorder(), + //fillColor: Colors.green ), + style: new TextStyle( + fontFamily: "Poppins", + ), + ), + Padding(padding: EdgeInsets.symmetric(vertical: 5.0)), + Center( + child: TextButton( + child: Text( + 'Submit', + style: TextStyle(fontSize: 15.0), + ), + // color: Colors.deepOrangeAccent, + onPressed: () {}, ), - ], - ), + ), + ], + ), ); } } diff --git a/lib/screens/Healthcenter/ambulanceRequest.dart b/lib/screens/Healthcenter/ambulanceRequest.dart index 4d90910a..41e92bc1 100644 --- a/lib/screens/Healthcenter/ambulanceRequest.dart +++ b/lib/screens/Healthcenter/ambulanceRequest.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:date_field/date_field.dart'; - class AmbulanceRequest extends StatefulWidget { @override _AmbulanceRequestState createState() => _AmbulanceRequestState(); @@ -13,65 +12,67 @@ class _AmbulanceRequestState extends State { return Container( padding: EdgeInsets.all(20.0), child: Column( - children: [ - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.event_note), - labelText: 'From', - ), - mode: DateTimeFieldPickerMode.date, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, - ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.event_note), - labelText: 'To', - ), - mode: DateTimeFieldPickerMode.date, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, - ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - TextFormField( - maxLines: 4, - cursorHeight: 30, - decoration: new InputDecoration( - labelText: "Reason", - fillColor: Colors.white, - border: new OutlineInputBorder( - ), - //fillColor: Colors.green - ), - style: new TextStyle( - fontFamily: "Poppins", - ), - ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - Center(child:FlatButton( - child: Text('Submit', style: TextStyle(fontSize: 15.0),), - color: Colors.deepOrangeAccent, - onPressed: () {}, - ), - ), - - ], + children: [ + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.event_note), + labelText: 'From', + ), + mode: DateTimeFieldPickerMode.date, + autovalidateMode: AutovalidateMode.always, + validator: (e) => + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { + print(value); + }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.event_note), + labelText: 'To', + ), + mode: DateTimeFieldPickerMode.date, + autovalidateMode: AutovalidateMode.always, + validator: (e) => + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { + print(value); + }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + TextFormField( + maxLines: 4, + cursorHeight: 30, + decoration: new InputDecoration( + labelText: "Reason", + fillColor: Colors.white, + border: new OutlineInputBorder(), + //fillColor: Colors.green + ), + style: new TextStyle( + fontFamily: "Poppins", + ), + ), + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + Center( + child: TextButton( + child: Text( + 'Submit', + style: TextStyle(fontSize: 15.0), + ), + // color: Colors.deepOrangeAccent, + onPressed: () {}, + ), + ), + ], ), ); } diff --git a/lib/screens/Healthcenter/feedback.dart b/lib/screens/Healthcenter/feedback.dart index 6b34c3f9..c45ed5fe 100644 --- a/lib/screens/Healthcenter/feedback.dart +++ b/lib/screens/Healthcenter/feedback.dart @@ -1,18 +1,13 @@ import 'package:flutter/material.dart'; - class FeedBack extends StatefulWidget { @override _FeedBackState createState() => _FeedBackState(); } - - class _FeedBackState extends State { @override - - - Widget feed=Container( + Widget feed = Container( padding: EdgeInsets.all(20.0), child: Column( children: [ @@ -22,25 +17,28 @@ class _FeedBackState extends State { decoration: new InputDecoration( labelText: "Feedback", fillColor: Colors.white, - border: new OutlineInputBorder( - ), + border: new OutlineInputBorder(), //fillColor: Colors.green ), style: new TextStyle( fontFamily: "Poppins", ), ), - Center(child:FlatButton( - child: Text('Submit', style: TextStyle(fontSize: 15.0),), - color: Colors.deepOrangeAccent, - onPressed: () {}, - ), + Center( + child: TextButton( + child: Text( + 'Submit', + style: TextStyle(fontSize: 15.0), + ), + // color: Colors.deepOrangeAccent, + + onPressed: () {}, + ), ), ], ), ); - Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, @@ -50,41 +48,43 @@ class _FeedBackState extends State { ), body: Container( child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - SizedBox(height: 20.0), - DefaultTabController( - length: 1, // length of tabs - initialIndex: 0, - child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Container( - //color: Colors.deepOrangeAccent, - child: TabBar( - labelColor: Colors.deepOrange, - indicatorColor: Colors.deepOrangeAccent, - unselectedLabelColor: Colors.black, - tabs: [ - Tab( - child: Text("Feedback Form", style: TextStyle( - fontWeight: FontWeight.bold),),), - ], - ), - ), - Container( - height: 520, //height of TabBarView - decoration: BoxDecoration( - border: Border( - top: BorderSide(color: Colors.grey, width: 0.5)) + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 20.0), + DefaultTabController( + length: 1, // length of tabs + initialIndex: 0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + //color: Colors.deepOrangeAccent, + child: TabBar( + labelColor: Colors.deepOrange, + indicatorColor: Colors.deepOrangeAccent, + unselectedLabelColor: Colors.black, + tabs: [ + Tab( + child: Text( + "Feedback Form", + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ], + ), ), - child: TabBarView(children: [ - feed, - - ]) - ) - ]) - ), - ]), + Container( + height: 520, //height of TabBarView + decoration: BoxDecoration( + border: Border( + top: BorderSide( + color: Colors.grey, width: 0.5))), + child: TabBarView(children: [ + feed, + ])) + ])), + ]), ), ); } -} \ No newline at end of file +} diff --git a/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart new file mode 100644 index 00000000..d05faa23 --- /dev/null +++ b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart @@ -0,0 +1,281 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +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)), + ), +); + +const kInputDateDecoration = InputDecoration( + labelText: 'Select Date', + icon: Icon(Icons.calendar_today_rounded), + filled: true, + fillColor: Colors.white, + contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(32)), + ), +); + +class AddConsultancyProject extends StatefulWidget { + final String? uid; + AddConsultancyProject(this.uid); + + @override + State createState() => _AddConsultancyProjectState(); +} + +class _AddConsultancyProjectState extends State { + final GlobalKey _formKey = GlobalKey(); + String? projectIncharge; + String? coProjectIncharge; + String? fundingAgency; + List status = [ + 'Ongoing', + 'Complete', + ]; + String? projectTitle; + var service = locator(); + + TextEditingController submissionDate = TextEditingController(); + TextEditingController startDate = TextEditingController(); + TextEditingController expectedFinishDate = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.black, + title: Text( + "Consultancy Project", + style: TextStyle(color: Colors.white), + ), + ), + body: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(25), + margin: EdgeInsets.only(bottom: 20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Add a Consultancy Project', + style: TextStyle( + fontWeight: FontWeight.w800, + fontSize: 15, + ), + ), + SizedBox( + height: 30, + ), + Text( + 'Consultant *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Client *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Financial Outlay *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Title *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Start Date *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 10), + child: TextField( + controller: submissionDate, + decoration: kInputDateDecoration, + onTap: () async { + DateTime? pickeddate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100)); + if (pickeddate != null) { + setState(() { + submissionDate.text = + DateFormat('dd-MM-yyyy').format(pickeddate); + }); + } + }, + ), + ), + SizedBox( + height: 20, + ), + Text( + 'End Date *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 10), + child: TextField( + controller: startDate, + decoration: kInputDateDecoration, + onTap: () async { + DateTime? pickeddate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100)); + if (pickeddate != null) { + setState(() { + startDate.text = + DateFormat('dd-MM-yyyy').format(pickeddate); + }); + } + }, + ), + ), + SizedBox( + height: 20, + ), + Center( + child: ElevatedButton( + onPressed: (() {}), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'Submit', + style: TextStyle(fontSize: 20), + ), + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.pressed)) + return Colors.deepOrange; + return Colors + .deepOrangeAccent; // Use the component's default. + }, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/RSPC/Patents/patents.dart b/lib/screens/RSPC/Patents/patents.dart new file mode 100644 index 00000000..bd3bfbd7 --- /dev/null +++ b/lib/screens/RSPC/Patents/patents.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +// import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/RSPC/Patents/patents_tab.dart'; +import 'package:flutter/services.dart' show rootBundle; + +import 'package:csv/csv.dart'; + +class Patents extends StatefulWidget { + final uid; + Patents(this.uid); + @override + State createState() => _PatentsState(); +} + +class _PatentsState extends State { + List> _patentList = []; + + Future _loadCSV() async { + final _patentsData = await rootBundle.loadString('db/patents.csv'); + List> _list = + const CsvToListConverter().convert(_patentsData); + _patentList = _list; + return 1; + } + + @override + void initState() { + super.initState(); + _loadCSV(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: _loadCSV(), + builder: (context, snapshot) { + if (!snapshot.hasData) return Scaffold(); + final patentData = { + "table": { + "columns": _patentList[0], + "rows": _patentList.skip(1).map((e) => e) + } + }; + return DefaultTabController( + length: 1, + child: Scaffold( + appBar: AppBar( + backgroundColor: Colors.black, + title: Text( + "Patents", + style: TextStyle(color: Colors.white), + ), + ), + // drawer: SideDrawer(), + body: TabBarView( + children: [ + PatentsStatus(data: patentData), + ], + ), + )); + }); + } +} diff --git a/lib/screens/RSPC/Patents/patents_tab.dart b/lib/screens/RSPC/Patents/patents_tab.dart new file mode 100644 index 00000000..8512333e --- /dev/null +++ b/lib/screens/RSPC/Patents/patents_tab.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; + +class PatentsStatus extends StatefulWidget { + final data; + const PatentsStatus({this.data}); + + @override + _PatentsStatusState createState() => _PatentsStatusState(); +} + +class _PatentsStatusState extends State { + late Map? table; + var rows; + var columns; + + @override + void initState() { + super.initState(); + table = widget.data?['table']; + rows = table?['rows']; + columns = table?['columns']; + } + + @override + Widget build(BuildContext context) { + return Container( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + //Component to lay table on the page + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: DataTable( + // headingRowColor: + // MaterialStateColor.resolveWith((states) => Colors.blue), + dataRowHeight: 80.0, + columnSpacing: 15.0, + columns: tabColumnList(), + rows: tabRowList(), + // rows: [], + ), + )), + ); + } + + List tabColumnList() { + //Get the list of json and map through, to select each json and lay row to the table.. + + List data = []; + data = columns + .map( + (el) { + return DataColumn( + label: Text(el.toString(), + style: + TextStyle(fontSize: 13, fontWeight: FontWeight.bold))); + }, + ) + .toList() + .cast(); + return data; + } + + List tabRowList() { + //Get the list of json and map through, to select each json and lay row to the table.. + List data = []; + data = rows + .map( + (el) { + return DataRow( + cells: el + .map((e) => DataCell(GestureDetector( + onTap: () => { + // Navigator.pushNamed(context, + // '/programme_curriculum_home/courses_info', + // arguments: {'e': e}) + }, + child: Container( + //SET width + constraints: BoxConstraints(maxWidth: 200), + child: Text(e.toString())), + ))) + .toList() + .cast(), + ); + }, + ) + .toList() + .cast(); + return data; + } +} diff --git a/lib/screens/RSPC/ResearchProject/research_project.dart b/lib/screens/RSPC/ResearchProject/research_project.dart new file mode 100644 index 00000000..3ee21a2d --- /dev/null +++ b/lib/screens/RSPC/ResearchProject/research_project.dart @@ -0,0 +1,382 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +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)), + ), +); + +const kInputDateDecoration = InputDecoration( + labelText: 'Select Date', + icon: Icon(Icons.calendar_today_rounded), + filled: true, + fillColor: Colors.white, + contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(32)), + ), +); + +class AddResearchProject extends StatefulWidget { + final String? uid; + AddResearchProject(this.uid); + + @override + State createState() => _AddResearchProjectState(); +} + +class _AddResearchProjectState extends State { + final GlobalKey _formKey = GlobalKey(); + String? projectIncharge; + String? coProjectIncharge; + String? fundingAgency; + List status = [ + 'Ongoing', + 'Complete', + ]; + String? projectTitle; + var service = locator(); + + TextEditingController submissionDate = TextEditingController(); + TextEditingController startDate = TextEditingController(); + TextEditingController expectedFinishDate = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.black, + title: Text( + "Research Project", + style: TextStyle(color: Colors.white), + ), + ), + body: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(25), + margin: EdgeInsets.only(bottom: 20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Add a new Research project', + style: TextStyle( + fontWeight: FontWeight.w800, + fontSize: 15, + ), + ), + SizedBox( + height: 30, + ), + Text( + 'Project Incharge(PI) *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Co-Project Incharge(CO-PI) *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Title of Project *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Funding Agency *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Status *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 10), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 16), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, + ), + borderRadius: BorderRadius.circular(15), + ), + child: DropdownButton( + hint: Text('Status'), + dropdownColor: Colors.grey[200], + icon: Icon(Icons.arrow_drop_down), + isExpanded: true, + underline: SizedBox(), + style: TextStyle(color: Colors.black, fontSize: 16), + onChanged: (newValue) { + setState(() { + // location = newValue.toString(); + }); + + //print(valueItem); + }, + // value: location, + items: status.map((valueItem) { + return DropdownMenuItem( + value: valueItem, + child: Text(valueItem), + ); + }).toList(), + ), + ), + ), + SizedBox( + height: 20, + ), + Text( + 'Submission Date *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 10), + child: TextField( + controller: submissionDate, + decoration: kInputDateDecoration, + onTap: () async { + DateTime? pickeddate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100)); + if (pickeddate != null) { + setState(() { + submissionDate.text = + DateFormat('dd-MM-yyyy').format(pickeddate); + }); + } + }, + ), + ), + SizedBox( + height: 20, + ), + Text( + 'Start Date *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 10), + child: TextField( + controller: startDate, + decoration: kInputDateDecoration, + onTap: () async { + DateTime? pickeddate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100)); + if (pickeddate != null) { + setState(() { + startDate.text = + DateFormat('dd-MM-yyyy').format(pickeddate); + }); + } + }, + ), + ), + SizedBox( + height: 20, + ), + Text( + 'Expected Finish Date *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 16), + child: TextField( + controller: expectedFinishDate, + decoration: kInputDateDecoration, + onTap: () async { + DateTime? pickeddate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100)); + if (pickeddate != null) { + setState(() { + expectedFinishDate.text = + DateFormat('dd-MM-yyyy').format(pickeddate); + }); + } + }, + ), + ), + Text( + 'Financial Outlay *', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + SizedBox( + height: 10, + ), + TextFormField( + autofocus: false, + style: TextStyle( + color: Colors.black, + ), + decoration: kTextFieldInputDecoration, + onChanged: (input) { + // specific_location = input; + }, + validator: (String? value) { + if (value!.isEmpty) { + return 'Please enter specific_location'; + } + }, + ), + SizedBox( + height: 20, + ), + Center( + child: ElevatedButton( + onPressed: (() {}), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'Submit', + style: TextStyle(fontSize: 20), + ), + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.pressed)) + return Colors.deepOrange; + return Colors + .deepOrangeAccent; // Use the component's default. + }, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/RSPC/rspc.dart b/lib/screens/RSPC/rspc.dart new file mode 100644 index 00000000..75888784 --- /dev/null +++ b/lib/screens/RSPC/rspc.dart @@ -0,0 +1,559 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/models/profile.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'; + +class RSPCModule extends StatefulWidget { + String? token; + RSPCModule(this.token); + + @override + State createState() => _RSPCModuleState(); +} + +class _RSPCModuleState extends State { + bool _loading1 = true; + bool _loading2 = false; + bool _loading3 = false; + bool _loading = true; + + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data; + @override + void initState() { + super.initState(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + //print('token-'+widget.token!); + try { + Response response = await profileService.getProfile(); + setState(() { + data = ProfileData.fromJson(jsonDecode(response.body)); + print(data.user!['username']); + _loading = false; + }); + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _profileController.add(res); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: _loading == true + ? Center( + child: CircularProgressIndicator(), + ) + : Container( + color: Colors.white60, + child: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50, vertical: 20), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20), + width: 170, + height: 170, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/profile_pic.png'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox(height: 10), + Text( + data.user != null + ? (data.user!['first_name'] + + ' ' + + data.user!['last_name']) + : "User does not exist on data", + style: TextStyle(color: Colors.black, fontSize: 20), + ), + SizedBox(height: 10), + Text( + data.profile != null + ? (data.profile!['department']!['name'] + + ' ' + + data.profile!['user_type']) + : "No Profile", + style: TextStyle(color: Colors.black, fontSize: 15), + ), + SizedBox(height: 10), + ], + ), + ), + 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, '/rspc/research_project', + arguments: data.user != null + ? data.user!['username'] + : "null"); + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Research Projects', + style: TextStyle( + fontWeight: FontWeight.w800, + fontSize: 18, + color: + _loading1 ? Colors.black : Colors.black26, + ), + ), + Icon( + Icons.arrow_forward, + color: _loading1 + ? Colors.deepOrangeAccent + : Colors.white, + ) + ], + ), + ), + ], + ), + ), + 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, '/rspc/consultancy_project', + arguments: data.user != null + ? data.user!['username'] + : "null"); + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Consultancy Projects', + style: TextStyle( + fontWeight: FontWeight.w800, + fontSize: 18, + color: + _loading1 ? Colors.black : Colors.black26, + ), + ), + Icon( + Icons.arrow_forward, + color: _loading1 + ? Colors.deepOrangeAccent + : Colors.white, + ) + ], + ), + ), + ], + ), + ), + 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, '/rspc/patents', + arguments: data.user != null + ? data.user!['username'] + : "null"); + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Patents', + style: TextStyle( + fontWeight: FontWeight.w800, + fontSize: 18, + color: + _loading1 ? Colors.black : Colors.black26, + ), + ), + 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, + // ), + // ), + // Icon( + // Icons.arrow_forward, + // color: _loading2 + // ? Colors.deepOrangeAccent + // : Colors.white, + // ) + // ], + // ), + // ), + // 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, + // ), + // ), + // Icon( + // Icons.arrow_forward, + // color: _loading3 + // ? Colors.deepOrangeAccent + // : Colors.white, + // ) + // ], + // ), + // ), + // SizedBox(height: 10), + +/********************************************************************************************** */ + ], + ), + ), + ); + } +} + + + + +// class Complaint extends StatefulWidget { +// String? token; +// Complaint(this.token); +// @override +// _ComplaintState createState() => _ComplaintState(); +// } + +// class _ComplaintState extends State { +// bool _loading1 = true; +// bool _loading2 = false; +// bool _loading3 = false; +// bool _loading = true; + +// late StreamController _profileController; +// late ProfileService profileService; +// late ProfileData data; +// @override +// void initState() { +// super.initState(); + +// _profileController = StreamController(); +// profileService = ProfileService(); + +// getData(); +// } + +// getData() async { +// //print('token-'+widget.token!); +// try { +// Response response = await profileService.getProfile(); +// setState(() { +// data = ProfileData.fromJson(jsonDecode(response.body)); +// print(data.user!['username']); +// _loading = false; +// }); +// } catch (e) { +// print(e); +// } +// } + +// loadData() async { +// getData().then((res) { +// _profileController.add(res); +// }); +// } + +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: _loading == true +// ? Center(child: CircularProgressIndicator()) +// : Container( +// color: Colors.white60, +// child: ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 50, vertical: 20), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20), +// width: 170, +// height: 170, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/profile_pic.png'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox(height: 10), +// Text( +// data.user != null +// ? (data.user!['first_name'] + +// ' ' + +// data.user!['last_name']) +// : "User does not exist on data", +// style: TextStyle(color: Colors.black, fontSize: 20), +// ), +// SizedBox(height: 10), +// Text( +// data.profile != null +// ? (data.profile!['department']!['name'] + +// ' ' + +// data.profile!['user_type']) +// : "No Profile", +// style: TextStyle(color: Colors.black, fontSize: 15), +// ), +// SizedBox(height: 10), +// ], +// ), +// ), +// 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, +// ), +// ), +// 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, +// ), +// ), +// Icon( +// Icons.arrow_forward, +// color: _loading2 +// ? Colors.deepOrangeAccent +// : Colors.white, +// ) +// ], +// ), +// ), +// 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, +// ), +// ), +// Icon( +// Icons.arrow_forward, +// color: _loading3 +// ? Colors.deepOrangeAccent +// : Colors.white, +// ) +// ], +// ), +// ), +// 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, +// // ), +// ], +// ), +// ), +// ); +// } +// } From d2349789e555152b2045755c25b34bdaf7a70e78 Mon Sep 17 00:00:00 2001 From: Devendra Date: Fri, 27 Jan 2023 05:19:20 +0530 Subject: [PATCH 02/14] Fixing Style of patents table --- lib/main.dart | 1 - lib/screens/RSPC/Patents/patents_tab.dart | 25 +++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index dd50c480..c4b41495 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -126,7 +126,6 @@ class MyApp extends StatelessWidget { ModalRoute.of(context)!.settings.arguments.toString()), '/rspc/patents': (context) => Patents(ModalRoute.of(context)!.settings.arguments.toString()), - // '/rspc/patents': (context) => Patents(), }, ); } diff --git a/lib/screens/RSPC/Patents/patents_tab.dart b/lib/screens/RSPC/Patents/patents_tab.dart index 8512333e..ec785223 100644 --- a/lib/screens/RSPC/Patents/patents_tab.dart +++ b/lib/screens/RSPC/Patents/patents_tab.dart @@ -31,9 +31,10 @@ class _PatentsStatusState extends State { scrollDirection: Axis.vertical, child: DataTable( // headingRowColor: + // MaterialStateColor.resolveWith((states) => Colors.blue), - dataRowHeight: 80.0, - columnSpacing: 15.0, + dataRowHeight: 70.0, + columnSpacing: 10.0, columns: tabColumnList(), rows: tabRowList(), // rows: [], @@ -50,9 +51,14 @@ class _PatentsStatusState extends State { .map( (el) { return DataColumn( - label: Text(el.toString(), - style: - TextStyle(fontSize: 13, fontWeight: FontWeight.bold))); + label: Expanded( + child: Text( + el.toString(), + style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold), + textAlign: TextAlign.center, + ), + ), + ); }, ) .toList() @@ -75,9 +81,12 @@ class _PatentsStatusState extends State { // arguments: {'e': e}) }, child: Container( - //SET width - constraints: BoxConstraints(maxWidth: 200), - child: Text(e.toString())), + //SET width + constraints: BoxConstraints(maxWidth: 200), + child: Text( + e.toString(), + ), + ), ))) .toList() .cast(), From 1af0ffc8b307acab0021f388cd1831c91f0740f1 Mon Sep 17 00:00:00 2001 From: Devendra Date: Sat, 4 Feb 2023 01:22:05 +0530 Subject: [PATCH 03/14] Added functionality of creating new research project and consultancy project. --- lib/api.dart | 11 +- lib/models/notification.dart | 8 +- lib/screens/Gymkhana/GymkhanaHomepage.dart | 3 +- .../DashboardComponents/cardItems.dart | 5 +- lib/screens/LoginandDashboard/dashboard.dart | 12 +- lib/screens/LoginandDashboard/login_page.dart | 7 +- .../consultancy_project.dart | 94 +++++++++++---- .../ResearchProject/research_project.dart | 110 +++++++++++++----- lib/screens/landing_page.dart | 1 + lib/services/login_service.dart | 4 +- lib/services/profile_service.dart | 6 +- lib/services/rspc_service.dart | 100 ++++++++++++++++ lib/services/storage_service.dart | 2 + 13 files changed, 303 insertions(+), 60 deletions(-) create mode 100644 lib/services/rspc_service.dart diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..5e4e0d51 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,9 +1,11 @@ //Server and local links String klocalLink = "127.0.0.1:8000"; -String kserverLink = "172.27.16.215:80"; +// String kserverLink = "172.27.16.215:80"; +String kserverLink = "127.0.0.1:8000"; //Login Service -String kAuthUrl = "172.27.16.215:80"; +// String kAuthUrl = "172.27.16.215:80"; +String kAuthUrl = "127.0.0.1:8000"; String kAuthLogin = "/api/auth/login/"; //Profile Service @@ -29,6 +31,11 @@ const kGymkhanaMemberRecords = '/api/gymkhana/members_record'; //HealthCentre String kHealthCentreStudent = "/healthcenter/api/student"; +//RSPC + +String kResearchProjectNew = "/rspc/api/new_research_project"; +String kConsultantProjectNew = "/rspc/api/new_consultant_project"; + //------------Screens------------ //screens/Academic/Current_Semester diff --git a/lib/models/notification.dart b/lib/models/notification.dart index ae6bc858..efe57a2f 100644 --- a/lib/models/notification.dart +++ b/lib/models/notification.dart @@ -28,6 +28,7 @@ class Notification { factory Notification.fromJson(json) { return Notification( id: json["id"], + // data: jsonDecode(json["data"]), data: jsonDecode(json["data"].replaceAll("'", '"')), verb: json["verb"], unread: json["unread"], @@ -41,8 +42,13 @@ class Notification { static List fromListJson(json) { List notifs = []; json.forEach((v) { - notifs.add(Notification.fromJson(v)); + // notifs.add(Notification.fromJson(v)); + // print(Notification.fromJson(v).data); + // print(jsonDecode(v)); + // print('\n\n'); }); + // print(notifs); + // print('NOTIFS'); return notifs; } } diff --git a/lib/screens/Gymkhana/GymkhanaHomepage.dart b/lib/screens/Gymkhana/GymkhanaHomepage.dart index 8b0345cb..0e382c21 100644 --- a/lib/screens/Gymkhana/GymkhanaHomepage.dart +++ b/lib/screens/Gymkhana/GymkhanaHomepage.dart @@ -8,6 +8,7 @@ import 'package:fusion/models/profile.dart'; import 'package:fusion/services/gymkhana_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; +import 'package:http/http.dart' as http; class GymkhanaHomepage extends StatefulWidget { @override @@ -70,7 +71,7 @@ class _GymkhanaHomepageState extends State { //TODO: uncomment when API is functioning try { - //Response response = await gymkhanaService.getGymkhanaData(); + http.Response response = await gymkhanaService.getGymkhanaData(); setState(() { //TODO: uncomment when API is functioning diff --git a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart index fffcde98..1b22d919 100644 --- a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart +++ b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart @@ -85,7 +85,8 @@ class _InfoCardState extends State { height: 10.0, ), Text( - widget.notification.data!["module"], + // widget.notification.data!["module"], + '', textAlign: TextAlign.left, style: TextStyle( fontSize: 20.0, @@ -116,7 +117,7 @@ class _InfoCardState extends State { setState(() { try { service.markRead(widget.notification.id!.toString()); - }catch(e){ + } catch (e) { print(e); } }); diff --git a/lib/screens/LoginandDashboard/dashboard.dart b/lib/screens/LoginandDashboard/dashboard.dart index 80c2719f..477dbf5a 100644 --- a/lib/screens/LoginandDashboard/dashboard.dart +++ b/lib/screens/LoginandDashboard/dashboard.dart @@ -11,6 +11,7 @@ import 'package:fusion/models/dashboard.dart'; import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; import 'package:fusion/services/dashboard_service.dart'; import 'package:http/http.dart'; +import 'dart:convert'; class Dashboard extends StatefulWidget { static String tag = 'home-page'; @@ -46,9 +47,17 @@ class _DashboardState extends State { getData() async { try { Response response = await dashboardService.getDashboard(); + // print('response ${response.body}'); Response response2 = await profileService.getProfile(); + // print('response ${response2.body}'); + + // print(jsonDecode(response.body)); + // var decodedData = jsonDecode(response.body)['notifications'][0]; + // print(decodedData); + // print(decodedData.notifications); setState(() { data = DashboardData.fromJson(jsonDecode(response.body)); + // data = ; data2 = ProfileData.fromJson(jsonDecode(response2.body)); _loading = false; }); @@ -56,6 +65,7 @@ class _DashboardState extends State { studentType = data2.profile!['department']!['name'] + ' ' + data2.profile!['user_type']; + print(name); } catch (e) { print(e); } @@ -239,7 +249,7 @@ class _DashboardState extends State { ), ), ), - _notificationsBool + (_notificationsBool) ? NotificationCard( notifications: data.notifications, ) diff --git a/lib/screens/LoginandDashboard/login_page.dart b/lib/screens/LoginandDashboard/login_page.dart index f5202c07..f61d6d5a 100644 --- a/lib/screens/LoginandDashboard/login_page.dart +++ b/lib/screens/LoginandDashboard/login_page.dart @@ -87,7 +87,12 @@ class _LoginPageState extends State { _showDialog(); } else { LoginService auth = LoginService(); - bool complete = await auth.login(username ?? "", pass ?? ""); + bool complete = false; + try { + complete = await auth.login(username ?? "", pass ?? ""); + } catch (e) { + print(e); + } TextInput.finishAutofillContext(); if (complete == true) { Navigator.pushReplacementNamed(context, "/landing"); diff --git a/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart index d05faa23..8ce9fc61 100644 --- a/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart +++ b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:fusion/services/rspc_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; @@ -34,20 +35,19 @@ class AddConsultancyProject extends StatefulWidget { } class _AddConsultancyProjectState extends State { + // ignore: unused_field final GlobalKey _formKey = GlobalKey(); - String? projectIncharge; - String? coProjectIncharge; - String? fundingAgency; - List status = [ - 'Ongoing', - 'Complete', - ]; + String? consultant; + String? clientName; + String? financialOutlay; String? projectTitle; + String? startDate; + String? endDate; + var service = locator(); - TextEditingController submissionDate = TextEditingController(); - TextEditingController startDate = TextEditingController(); - TextEditingController expectedFinishDate = TextEditingController(); + TextEditingController startDateController = TextEditingController(); + TextEditingController endDateController = TextEditingController(); @override Widget build(BuildContext context) { @@ -93,11 +93,11 @@ class _AddConsultancyProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + consultant = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is manadatory.'; } }, ), @@ -121,11 +121,11 @@ class _AddConsultancyProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + clientName = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is manadatory.'; } }, ), @@ -149,11 +149,11 @@ class _AddConsultancyProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + financialOutlay = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is manadatory.'; } }, ), @@ -177,11 +177,11 @@ class _AddConsultancyProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + projectTitle = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is manadatory.'; } }, ), @@ -199,7 +199,7 @@ class _AddConsultancyProjectState extends State { padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 10), child: TextField( - controller: submissionDate, + controller: startDateController, decoration: kInputDateDecoration, onTap: () async { DateTime? pickeddate = await showDatePicker( @@ -209,8 +209,9 @@ class _AddConsultancyProjectState extends State { lastDate: DateTime(2100)); if (pickeddate != null) { setState(() { - submissionDate.text = + startDateController.text = DateFormat('dd-MM-yyyy').format(pickeddate); + startDate = startDateController.text; }); } }, @@ -230,7 +231,7 @@ class _AddConsultancyProjectState extends State { padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 10), child: TextField( - controller: startDate, + controller: endDateController, decoration: kInputDateDecoration, onTap: () async { DateTime? pickeddate = await showDatePicker( @@ -240,8 +241,9 @@ class _AddConsultancyProjectState extends State { lastDate: DateTime(2100)); if (pickeddate != null) { setState(() { - startDate.text = + endDateController.text = DateFormat('dd-MM-yyyy').format(pickeddate); + endDate = endDateController.text; }); } }, @@ -252,7 +254,53 @@ class _AddConsultancyProjectState extends State { ), Center( child: ElevatedButton( - onPressed: (() {}), + onPressed: (() async { + RSPCService auth = RSPCService(); + bool newConsultancyProject = + await auth.addConsultancyProject( + consultant: consultant, + clientName: clientName, + financialOutlay: financialOutlay, + startDate: startDate, + endDate: endDate); + TextInput.finishAutofillContext(); + if (newConsultancyProject) { + print('Successfully added'); + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Success"), + content: Text("Project Added Successfully"), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } else { + print('ERROR OCCURED'); + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Failed"), + content: + Text("Cannot add above Consultancy Project."), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } + }), child: Padding( padding: const EdgeInsets.all(8.0), child: Text( diff --git a/lib/screens/RSPC/ResearchProject/research_project.dart b/lib/screens/RSPC/ResearchProject/research_project.dart index 3ee21a2d..502fe98e 100644 --- a/lib/screens/RSPC/ResearchProject/research_project.dart +++ b/lib/screens/RSPC/ResearchProject/research_project.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:fusion/services/rspc_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; @@ -34,20 +35,27 @@ class AddResearchProject extends StatefulWidget { } class _AddResearchProjectState extends State { + // ignore: unused_field final GlobalKey _formKey = GlobalKey(); String? projectIncharge; String? coProjectIncharge; String? fundingAgency; + String? projectTitle; + String? currentStatus; + String? financialOutlay; + String? submissionDate; + String? startDate; + String? expectedFinishDate; + List status = [ 'Ongoing', 'Complete', ]; - String? projectTitle; var service = locator(); - TextEditingController submissionDate = TextEditingController(); - TextEditingController startDate = TextEditingController(); - TextEditingController expectedFinishDate = TextEditingController(); + TextEditingController submissionDateController = TextEditingController(); + TextEditingController startDateController = TextEditingController(); + TextEditingController expectedFinishDateController = TextEditingController(); @override Widget build(BuildContext context) { @@ -93,11 +101,11 @@ class _AddResearchProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + projectIncharge = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is mandatory.'; } }, ), @@ -121,11 +129,11 @@ class _AddResearchProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + coProjectIncharge = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is mandatory.'; } }, ), @@ -149,11 +157,11 @@ class _AddResearchProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + projectTitle = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is mandatory.'; } }, ), @@ -177,11 +185,11 @@ class _AddResearchProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + fundingAgency = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is mandatory.'; } }, ), @@ -214,13 +222,8 @@ class _AddResearchProjectState extends State { underline: SizedBox(), style: TextStyle(color: Colors.black, fontSize: 16), onChanged: (newValue) { - setState(() { - // location = newValue.toString(); - }); - - //print(valueItem); + currentStatus = newValue.toString(); }, - // value: location, items: status.map((valueItem) { return DropdownMenuItem( value: valueItem, @@ -244,7 +247,7 @@ class _AddResearchProjectState extends State { padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 10), child: TextField( - controller: submissionDate, + controller: submissionDateController, decoration: kInputDateDecoration, onTap: () async { DateTime? pickeddate = await showDatePicker( @@ -254,8 +257,9 @@ class _AddResearchProjectState extends State { lastDate: DateTime(2100)); if (pickeddate != null) { setState(() { - submissionDate.text = + submissionDateController.text = DateFormat('dd-MM-yyyy').format(pickeddate); + submissionDate = submissionDateController.text; }); } }, @@ -275,7 +279,7 @@ class _AddResearchProjectState extends State { padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 10), child: TextField( - controller: startDate, + controller: startDateController, decoration: kInputDateDecoration, onTap: () async { DateTime? pickeddate = await showDatePicker( @@ -285,8 +289,9 @@ class _AddResearchProjectState extends State { lastDate: DateTime(2100)); if (pickeddate != null) { setState(() { - startDate.text = + startDateController.text = DateFormat('dd-MM-yyyy').format(pickeddate); + startDate = startDateController.text; }); } }, @@ -306,7 +311,7 @@ class _AddResearchProjectState extends State { padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 16), child: TextField( - controller: expectedFinishDate, + controller: expectedFinishDateController, decoration: kInputDateDecoration, onTap: () async { DateTime? pickeddate = await showDatePicker( @@ -316,8 +321,9 @@ class _AddResearchProjectState extends State { lastDate: DateTime(2100)); if (pickeddate != null) { setState(() { - expectedFinishDate.text = + expectedFinishDateController.text = DateFormat('dd-MM-yyyy').format(pickeddate); + expectedFinishDate = expectedFinishDateController.text; }); } }, @@ -340,11 +346,11 @@ class _AddResearchProjectState extends State { ), decoration: kTextFieldInputDecoration, onChanged: (input) { - // specific_location = input; + financialOutlay = input; }, validator: (String? value) { if (value!.isEmpty) { - return 'Please enter specific_location'; + return 'This field is manadatory.'; } }, ), @@ -353,7 +359,57 @@ class _AddResearchProjectState extends State { ), Center( child: ElevatedButton( - onPressed: (() {}), + onPressed: (() async { + RSPCService auth = RSPCService(); + + bool addNewResearchProject = await auth.addResearchProject( + projectIncharge: projectIncharge, + coProjectIncharge: coProjectIncharge, + fundingAgency: fundingAgency, + financialOutlay: financialOutlay, + currentStatus: currentStatus, + projectTitle: projectTitle, + startDate: startDate, + submissionDate: submissionDate, + expectedFinishDate: expectedFinishDate, + ); + TextInput.finishAutofillContext(); + if (addNewResearchProject) { + print('Successfully added'); + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Success"), + content: Text("Project Added Successfully"), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } else { + print('ERROR OCCURED'); + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Failed"), + content: Text("Cannot add above Research Project."), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } + }), child: Padding( padding: const EdgeInsets.all(8.0), child: Text( diff --git a/lib/screens/landing_page.dart b/lib/screens/landing_page.dart index 3a4ce5dd..73fc0a50 100644 --- a/lib/screens/landing_page.dart +++ b/lib/screens/landing_page.dart @@ -14,6 +14,7 @@ class _LandingPageState extends State { return FutureBuilder( future: StorageService.getInstance(), builder: (context, AsyncSnapshot? snapshot) { + // print(snapshot?.data); if (snapshot?.hasData ?? false) { if (snapshot?.data.userInDB != null) return Dashboard(); return LoginPage(); diff --git a/lib/services/login_service.dart b/lib/services/login_service.dart index 604e53e6..1008ab53 100644 --- a/lib/services/login_service.dart +++ b/lib/services/login_service.dart @@ -22,10 +22,12 @@ class LoginService { ), headers: headers, body: jsonEncode(data)); - var prefs = await StorageService.getInstance(); + // print(response.body); + var prefs = await StorageService.getInstance(); var storage_service = await StorageService.getInstance(); storage_service!.saveUserInDB(User((jsonDecode(response.body))["token"])); + return true; } catch (e) { rethrow; diff --git a/lib/services/profile_service.dart b/lib/services/profile_service.dart index 7214af5a..b82f6d68 100644 --- a/lib/services/profile_service.dart +++ b/lib/services/profile_service.dart @@ -25,14 +25,18 @@ class ProfileService { ), headers: headers, ); + + // print('ProfileService ${response.statusCode}\n'); + if (response.statusCode == 200) { print("successfully fetched profile"); storage_service .saveProfileInDB(ProfileData.fromJson(jsonDecode(response.body))); return response; } - throw Exception('Can\'t load'); + // throw Exception('Can\'t loaddddddddd Profile_Service'); } catch (e) { + print(e); rethrow; } } diff --git a/lib/services/rspc_service.dart b/lib/services/rspc_service.dart new file mode 100644 index 00000000..c360c69b --- /dev/null +++ b/lib/services/rspc_service.dart @@ -0,0 +1,100 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'dart:core'; +import 'package:fusion/api.dart'; +import 'package:fusion/constants.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:http/http.dart' as http; + +class RSPCService { + Future addResearchProject({ + String? projectIncharge, + String? coProjectIncharge, + String? fundingAgency, + String? projectTitle, + String? currentStatus, + String? financialOutlay, + String? submissionDate, + String? startDate, + String? expectedFinishDate, + }) async { + try { + Map data = { + 'pi': projectIncharge, + 'co_pi': coProjectIncharge, + 'title': projectTitle, + 'financial_outlay': financialOutlay, + 'funding_agency': fundingAgency, + 'status': currentStatus, + 'start': startDate, + 'end': expectedFinishDate, + 'sub': submissionDate, + }; + var storageService = locator(); + if (storageService.userInDB?.token == null) + throw Exception('Token Error'); + Map headers = { + 'Authorization': 'Token ' + (storageService.userInDB?.token ?? "") + }; + + var client = http.Client(); + var response = await client.post( + Uri.http( + getLink(), + kResearchProjectNew, + ), + headers: headers, + body: data, + ); + + if (response.statusCode == 201) return true; + return false; + } catch (e) { + print('Error While posting new research project -- $e'); + rethrow; + } + } + + Future addConsultancyProject({ + String? consultant, + String? clientName, + String? financialOutlay, + String? projectTitle, + String? startDate, + String? endDate, + }) async { + try { + Map data = { + 'consultants': consultant, + 'client': clientName, + 'title': projectTitle, + 'financial_outlay': financialOutlay, + 'start': startDate, + 'end': endDate, + }; + var storageService = locator(); + if (storageService.userInDB?.token == null) + throw Exception('Token Error'); + Map headers = { + 'Authorization': 'Token ' + (storageService.userInDB?.token ?? "") + }; + + var client = http.Client(); + var response = await client.post( + Uri.http( + getLink(), + kConsultantProjectNew, + ), + headers: headers, + body: data, + ); + + if (response.statusCode == 201) return true; + return false; + } catch (e) { + print('Error While posting new research project -- $e'); + rethrow; + } + } +} diff --git a/lib/services/storage_service.dart b/lib/services/storage_service.dart index 94d39ea4..b444288d 100644 --- a/lib/services/storage_service.dart +++ b/lib/services/storage_service.dart @@ -32,6 +32,7 @@ class StorageService with ChangeNotifier { void saveUserInDB(User userToSave) { saveStringToDisk(UserKey, json.encode(userToSave.toJson())); + print('SAVED SUCCESSFULLY '); notifyListeners(); } @@ -46,6 +47,7 @@ class StorageService with ChangeNotifier { if (_sharedPreferences == null) { _sharedPreferences = await SharedPreferences.getInstance(); } + // print(_instance); return _instance; } From 6ca5f469ad1f18055ebc6b7a227ecfdd264d6e57 Mon Sep 17 00:00:00 2001 From: Devendra Date: Thu, 9 Feb 2023 03:55:50 +0530 Subject: [PATCH 04/14] Code Cleaning --- lib/api.dart | 5 +- lib/main.dart | 1 - lib/screens/RSPC/rspc.dart | 315 ------------------------------------- 3 files changed, 3 insertions(+), 318 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 5e4e0d51..93b6698d 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -33,8 +33,9 @@ String kHealthCentreStudent = "/healthcenter/api/student"; //RSPC -String kResearchProjectNew = "/rspc/api/new_research_project"; -String kConsultantProjectNew = "/rspc/api/new_consultant_project"; +String kResearchProjectNew = "/research_procedures/api/new_research_project"; +String kConsultantProjectNew = + "/research_procedures/api/new_consultant_project"; //------------Screens------------ diff --git a/lib/main.dart b/lib/main.dart index c4b41495..18b425e1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,7 +36,6 @@ import 'package:fusion/screens/Programme_Curriculum/Programme/programme_home_pag import 'package:fusion/screens/Programme_Curriculum/Programme_Info/programme_info.dart'; import 'package:fusion/screens/Programme_Curriculum/programme_curriculum_home.dart'; import 'package:fusion/screens/RSPC/Patents/patents.dart'; -import 'package:fusion/screens/RSPC/Patents/patents_tab.dart'; import 'package:fusion/screens/RSPC/ConsultancyProject/consultancy_project.dart'; import 'package:fusion/screens/RSPC/ResearchProject/research_project.dart'; import 'package:fusion/screens/landing_page.dart'; diff --git a/lib/screens/RSPC/rspc.dart b/lib/screens/RSPC/rspc.dart index 75888784..a4e47538 100644 --- a/lib/screens/RSPC/rspc.dart +++ b/lib/screens/RSPC/rspc.dart @@ -4,13 +4,8 @@ import 'package:fusion/Components/appBar.dart'; import 'package:fusion/models/profile.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'; class RSPCModule extends StatefulWidget { String? token; @@ -38,7 +33,6 @@ class _RSPCModuleState extends State { } getData() async { - //print('token-'+widget.token!); try { Response response = await profileService.getProfile(); setState(() { @@ -242,318 +236,9 @@ class _RSPCModuleState extends State { ], ), ), - -/***************************************************************************** */ - - // 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, - // ), - // ), - // Icon( - // Icons.arrow_forward, - // color: _loading2 - // ? Colors.deepOrangeAccent - // : Colors.white, - // ) - // ], - // ), - // ), - // 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, - // ), - // ), - // Icon( - // Icons.arrow_forward, - // color: _loading3 - // ? Colors.deepOrangeAccent - // : Colors.white, - // ) - // ], - // ), - // ), - // SizedBox(height: 10), - -/********************************************************************************************** */ ], ), ), ); } } - - - - -// class Complaint extends StatefulWidget { -// String? token; -// Complaint(this.token); -// @override -// _ComplaintState createState() => _ComplaintState(); -// } - -// class _ComplaintState extends State { -// bool _loading1 = true; -// bool _loading2 = false; -// bool _loading3 = false; -// bool _loading = true; - -// late StreamController _profileController; -// late ProfileService profileService; -// late ProfileData data; -// @override -// void initState() { -// super.initState(); - -// _profileController = StreamController(); -// profileService = ProfileService(); - -// getData(); -// } - -// getData() async { -// //print('token-'+widget.token!); -// try { -// Response response = await profileService.getProfile(); -// setState(() { -// data = ProfileData.fromJson(jsonDecode(response.body)); -// print(data.user!['username']); -// _loading = false; -// }); -// } catch (e) { -// print(e); -// } -// } - -// loadData() async { -// getData().then((res) { -// _profileController.add(res); -// }); -// } - -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// appBar: DefaultAppBar().buildAppBar(), -// drawer: SideDrawer(), -// body: _loading == true -// ? Center(child: CircularProgressIndicator()) -// : Container( -// color: Colors.white60, -// child: ListView( -// shrinkWrap: true, -// physics: ClampingScrollPhysics(), -// children: [ -// Card( -// elevation: 2.0, -// margin: EdgeInsets.symmetric(horizontal: 50, vertical: 20), -// shadowColor: Colors.black, -// child: Column( -// children: [ -// Container( -// margin: EdgeInsets.only(top: 20), -// width: 170, -// height: 170, -// decoration: BoxDecoration( -// image: DecorationImage( -// image: AssetImage('assets/profile_pic.png'), -// fit: BoxFit.cover, -// ), -// ), -// ), -// SizedBox(height: 10), -// Text( -// data.user != null -// ? (data.user!['first_name'] + -// ' ' + -// data.user!['last_name']) -// : "User does not exist on data", -// style: TextStyle(color: Colors.black, fontSize: 20), -// ), -// SizedBox(height: 10), -// Text( -// data.profile != null -// ? (data.profile!['department']!['name'] + -// ' ' + -// data.profile!['user_type']) -// : "No Profile", -// style: TextStyle(color: Colors.black, fontSize: 15), -// ), -// SizedBox(height: 10), -// ], -// ), -// ), -// 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, -// ), -// ), -// 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, -// ), -// ), -// Icon( -// Icons.arrow_forward, -// color: _loading2 -// ? Colors.deepOrangeAccent -// : Colors.white, -// ) -// ], -// ), -// ), -// 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, -// ), -// ), -// Icon( -// Icons.arrow_forward, -// color: _loading3 -// ? Colors.deepOrangeAccent -// : Colors.white, -// ) -// ], -// ), -// ), -// 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, -// // ), -// ], -// ), -// ), -// ); -// } -// } From cd618694a7d944bc892b6d0c0940394975f03580 Mon Sep 17 00:00:00 2001 From: Devendra Date: Sat, 11 Feb 2023 18:22:42 +0530 Subject: [PATCH 05/14] Able to sent research & consultant project data to server. --- .../consultancy_project.dart | 30 ++++++++++++++----- .../ResearchProject/research_project.dart | 22 ++++++++++---- lib/services/login_service.dart | 4 ++- lib/services/profile_service.dart | 7 ++--- lib/services/rspc_service.dart | 10 +++++-- 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart index 8ce9fc61..ac7f4fcc 100644 --- a/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart +++ b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart @@ -1,9 +1,12 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fusion/services/rspc_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; +import 'package:fusion/services/profile_service.dart'; import 'package:intl/intl.dart'; const kTextFieldInputDecoration = InputDecoration( @@ -43,12 +46,19 @@ class _AddConsultancyProjectState extends State { String? projectTitle; String? startDate; String? endDate; + String? pfNo; var service = locator(); TextEditingController startDateController = TextEditingController(); TextEditingController endDateController = TextEditingController(); + String reverseStringUsingRunes(String input) { + var chars = input.runes.toList(); + + return String.fromCharCodes(chars.reversed); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -210,7 +220,7 @@ class _AddConsultancyProjectState extends State { if (pickeddate != null) { setState(() { startDateController.text = - DateFormat('dd-MM-yyyy').format(pickeddate); + DateFormat('yyyy-MM-dd').format(pickeddate); startDate = startDateController.text; }); } @@ -242,7 +252,7 @@ class _AddConsultancyProjectState extends State { if (pickeddate != null) { setState(() { endDateController.text = - DateFormat('dd-MM-yyyy').format(pickeddate); + DateFormat('yyyy-MM-dd').format(pickeddate); endDate = endDateController.text; }); } @@ -255,14 +265,20 @@ class _AddConsultancyProjectState extends State { Center( child: ElevatedButton( onPressed: (() async { + dynamic res = await ProfileService().getProfile(); + dynamic user = jsonDecode(res.body)['user']; + pfNo = user['id'].toString(); RSPCService auth = RSPCService(); bool newConsultancyProject = await auth.addConsultancyProject( - consultant: consultant, - clientName: clientName, - financialOutlay: financialOutlay, - startDate: startDate, - endDate: endDate); + consultant: consultant, + clientName: clientName, + projectTitle: projectTitle, + financialOutlay: financialOutlay, + startDate: startDate, + endDate: endDate, + pfNo: pfNo, + ); TextInput.finishAutofillContext(); if (newConsultancyProject) { print('Successfully added'); diff --git a/lib/screens/RSPC/ResearchProject/research_project.dart b/lib/screens/RSPC/ResearchProject/research_project.dart index 502fe98e..1dd189b7 100644 --- a/lib/screens/RSPC/ResearchProject/research_project.dart +++ b/lib/screens/RSPC/ResearchProject/research_project.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fusion/services/rspc_service.dart'; @@ -6,6 +8,8 @@ import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; import 'package:intl/intl.dart'; +import '../../../services/profile_service.dart'; + const kTextFieldInputDecoration = InputDecoration( filled: true, fillColor: Colors.white, @@ -46,6 +50,7 @@ class _AddResearchProjectState extends State { String? submissionDate; String? startDate; String? expectedFinishDate; + String? pfNo; List status = [ 'Ongoing', @@ -217,12 +222,15 @@ class _AddResearchProjectState extends State { child: DropdownButton( hint: Text('Status'), dropdownColor: Colors.grey[200], + value: currentStatus, icon: Icon(Icons.arrow_drop_down), isExpanded: true, underline: SizedBox(), style: TextStyle(color: Colors.black, fontSize: 16), onChanged: (newValue) { - currentStatus = newValue.toString(); + setState(() { + currentStatus = newValue.toString(); + }); }, items: status.map((valueItem) { return DropdownMenuItem( @@ -258,7 +266,7 @@ class _AddResearchProjectState extends State { if (pickeddate != null) { setState(() { submissionDateController.text = - DateFormat('dd-MM-yyyy').format(pickeddate); + DateFormat('yyyy-MM-dd').format(pickeddate); submissionDate = submissionDateController.text; }); } @@ -290,7 +298,7 @@ class _AddResearchProjectState extends State { if (pickeddate != null) { setState(() { startDateController.text = - DateFormat('dd-MM-yyyy').format(pickeddate); + DateFormat('yyyy-MM-dd').format(pickeddate); startDate = startDateController.text; }); } @@ -322,7 +330,7 @@ class _AddResearchProjectState extends State { if (pickeddate != null) { setState(() { expectedFinishDateController.text = - DateFormat('dd-MM-yyyy').format(pickeddate); + DateFormat('yyyy-MM-dd').format(pickeddate); expectedFinishDate = expectedFinishDateController.text; }); } @@ -360,8 +368,11 @@ class _AddResearchProjectState extends State { Center( child: ElevatedButton( onPressed: (() async { + dynamic res = await ProfileService().getProfile(); + dynamic user = jsonDecode(res.body)['user']; + pfNo = user['id'].toString(); + print(pfNo); RSPCService auth = RSPCService(); - bool addNewResearchProject = await auth.addResearchProject( projectIncharge: projectIncharge, coProjectIncharge: coProjectIncharge, @@ -372,6 +383,7 @@ class _AddResearchProjectState extends State { startDate: startDate, submissionDate: submissionDate, expectedFinishDate: expectedFinishDate, + pfNo: pfNo, ); TextInput.finishAutofillContext(); if (addNewResearchProject) { diff --git a/lib/services/login_service.dart b/lib/services/login_service.dart index 1008ab53..5c7cce80 100644 --- a/lib/services/login_service.dart +++ b/lib/services/login_service.dart @@ -22,7 +22,9 @@ class LoginService { ), headers: headers, body: jsonEncode(data)); - // print(response.body); + // print("here"); + // print(response); + // print(jsonDecode(response.body)); var prefs = await StorageService.getInstance(); var storage_service = await StorageService.getInstance(); diff --git a/lib/services/profile_service.dart b/lib/services/profile_service.dart index b82f6d68..faed943c 100644 --- a/lib/services/profile_service.dart +++ b/lib/services/profile_service.dart @@ -16,7 +16,7 @@ class ProfileService { Map headers = { 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") }; - print("fetching profile"); + print("fetching profile........"); var client = http.Client(); http.Response response = await client.get( Uri.http( @@ -26,15 +26,12 @@ class ProfileService { headers: headers, ); - // print('ProfileService ${response.statusCode}\n'); - if (response.statusCode == 200) { - print("successfully fetched profile"); + print("successfully fetched profile.........."); storage_service .saveProfileInDB(ProfileData.fromJson(jsonDecode(response.body))); return response; } - // throw Exception('Can\'t loaddddddddd Profile_Service'); } catch (e) { print(e); rethrow; diff --git a/lib/services/rspc_service.dart b/lib/services/rspc_service.dart index c360c69b..c12d9166 100644 --- a/lib/services/rspc_service.dart +++ b/lib/services/rspc_service.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'dart:core'; @@ -18,9 +19,11 @@ class RSPCService { String? submissionDate, String? startDate, String? expectedFinishDate, + String? pfNo, }) async { try { Map data = { + 'pf_no': pfNo, 'pi': projectIncharge, 'co_pi': coProjectIncharge, 'title': projectTitle, @@ -63,6 +66,7 @@ class RSPCService { String? projectTitle, String? startDate, String? endDate, + String? pfNo, }) async { try { Map data = { @@ -70,9 +74,11 @@ class RSPCService { 'client': clientName, 'title': projectTitle, 'financial_outlay': financialOutlay, - 'start': startDate, - 'end': endDate, + 'start_date': startDate, + 'end_date': endDate, + 'pf_no': pfNo, }; + print(data); var storageService = locator(); if (storageService.userInDB?.token == null) throw Exception('Token Error'); From 40d1c0bb9f747d1b3d9f9f20b338665fa7db6197 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 15:36:03 +0530 Subject: [PATCH 06/14] Added Research and Consultancy form. --- lib/main.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 791d2d53..7cbe9144 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -131,6 +131,14 @@ class MyApp extends StatelessWidget { '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), '/health_center/history': (context) => History(), + '/rspc': (context) => + RSPCModule(ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/research_project': (context) => AddResearchProject( + ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/consultancy_project': (context) => AddConsultancyProject( + ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/patents': (context) => + Patents(ModalRoute.of(context)!.settings.arguments.toString()), }, ), ); From 80c10c726147988c3960699223987815b8bfb673 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 17:57:56 +0530 Subject: [PATCH 07/14] RSPC UI Changes. --- lib/Components/utils.dart | 20 ++ .../consultancy_project.dart | 65 ++-- lib/screens/RSPC/Patents/patents.dart | 12 +- .../ResearchProject/research_project.dart | 81 +++-- lib/screens/RSPC/rspc.dart | 324 +++++++++++------- 5 files changed, 322 insertions(+), 180 deletions(-) create mode 100644 lib/Components/utils.dart 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/screens/RSPC/ConsultancyProject/consultancy_project.dart b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart index ac7f4fcc..210840b0 100644 --- a/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart +++ b/lib/screens/RSPC/ConsultancyProject/consultancy_project.dart @@ -9,14 +9,24 @@ import 'package:fusion/services/storage_service.dart'; import 'package:fusion/services/profile_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)), + ), + ); +} const kInputDateDecoration = InputDecoration( labelText: 'Select Date', @@ -48,6 +58,8 @@ class _AddConsultancyProjectState extends State { String? endDate; String? pfNo; + Utils utils = Utils(); + var service = locator(); TextEditingController startDateController = TextEditingController(); @@ -63,10 +75,12 @@ class _AddConsultancyProjectState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - backgroundColor: Colors.black, + backgroundColor: utils.primarybackgroundcolor, + leading: utils.leadingPopIconsButton(utils.primarycolor, context), title: Text( "Consultancy Project", - style: TextStyle(color: Colors.white), + style: + TextStyle(color: utils.primarycolor, fontWeight: FontWeight.bold), ), ), body: SingleChildScrollView( @@ -79,9 +93,17 @@ class _AddConsultancyProjectState extends State { Text( 'Add a Consultancy Project', 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, @@ -101,7 +123,7 @@ class _AddConsultancyProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Consultant"), onChanged: (input) { consultant = input; }, @@ -129,7 +151,7 @@ class _AddConsultancyProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Client"), onChanged: (input) { clientName = input; }, @@ -157,7 +179,7 @@ class _AddConsultancyProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Outlay"), onChanged: (input) { financialOutlay = input; }, @@ -185,7 +207,7 @@ class _AddConsultancyProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Title"), onChanged: (input) { projectTitle = input; }, @@ -321,16 +343,17 @@ class _AddConsultancyProjectState 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/RSPC/Patents/patents.dart b/lib/screens/RSPC/Patents/patents.dart index bd3bfbd7..d60410bb 100644 --- a/lib/screens/RSPC/Patents/patents.dart +++ b/lib/screens/RSPC/Patents/patents.dart @@ -6,6 +6,8 @@ import 'package:flutter/services.dart' show rootBundle; import 'package:csv/csv.dart'; +import '../../../Components/utils.dart'; + class Patents extends StatefulWidget { final uid; Patents(this.uid); @@ -15,7 +17,7 @@ class Patents extends StatefulWidget { class _PatentsState extends State { List> _patentList = []; - + Utils utils = Utils(); Future _loadCSV() async { final _patentsData = await rootBundle.loadString('db/patents.csv'); List> _list = @@ -46,12 +48,16 @@ class _PatentsState extends State { length: 1, child: Scaffold( appBar: AppBar( - backgroundColor: Colors.black, + backgroundColor: utils.primarybackgroundcolor, + leading: + utils.leadingPopIconsButton(utils.primarycolor, context), title: Text( "Patents", - style: TextStyle(color: Colors.white), + style: TextStyle( + color: utils.primarycolor, fontWeight: FontWeight.bold), ), ), + // drawer: SideDrawer(), body: TabBarView( children: [ diff --git a/lib/screens/RSPC/ResearchProject/research_project.dart b/lib/screens/RSPC/ResearchProject/research_project.dart index 1dd189b7..7150f896 100644 --- a/lib/screens/RSPC/ResearchProject/research_project.dart +++ b/lib/screens/RSPC/ResearchProject/research_project.dart @@ -8,16 +8,34 @@ import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; import 'package:intl/intl.dart'; +import '../../../Components/utils.dart'; import '../../../services/profile_service.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)), - ), -); +// 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)), +// ), +// ); + +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)), + ), + ); +} const kInputDateDecoration = InputDecoration( labelText: 'Select Date', @@ -51,6 +69,7 @@ class _AddResearchProjectState extends State { String? startDate; String? expectedFinishDate; String? pfNo; + Utils utils = Utils(); List status = [ 'Ongoing', @@ -66,12 +85,13 @@ class _AddResearchProjectState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - backgroundColor: Colors.black, - title: Text( - "Research Project", - style: TextStyle(color: Colors.white), - ), - ), + backgroundColor: utils.primarybackgroundcolor, + leading: utils.leadingPopIconsButton(utils.primarycolor, context), + title: Text( + "Research Project", + style: TextStyle( + color: utils.primarycolor, fontWeight: FontWeight.bold), + )), body: SingleChildScrollView( child: Container( padding: EdgeInsets.all(25), @@ -82,9 +102,17 @@ class _AddResearchProjectState extends State { Text( 'Add a new Research project', 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, @@ -104,7 +132,7 @@ class _AddResearchProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("PI"), onChanged: (input) { projectIncharge = input; }, @@ -132,7 +160,7 @@ class _AddResearchProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Co-PI"), onChanged: (input) { coProjectIncharge = input; }, @@ -160,7 +188,7 @@ class _AddResearchProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Title"), onChanged: (input) { projectTitle = input; }, @@ -188,7 +216,7 @@ class _AddResearchProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Agency"), onChanged: (input) { fundingAgency = input; }, @@ -352,7 +380,7 @@ class _AddResearchProjectState extends State { style: TextStyle( color: Colors.black, ), - decoration: kTextFieldInputDecoration, + decoration: kTextFieldInputDecoration("Outlay"), onChanged: (input) { financialOutlay = input; }, @@ -426,16 +454,17 @@ class _AddResearchProjectState 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/RSPC/rspc.dart b/lib/screens/RSPC/rspc.dart index a4e47538..ef179fc8 100644 --- a/lib/screens/RSPC/rspc.dart +++ b/lib/screens/RSPC/rspc.dart @@ -1,12 +1,13 @@ import 'dart:async'; import 'dart:convert'; -import 'package:fusion/Components/appBar.dart'; import 'package:fusion/models/profile.dart'; import 'package:fusion/services/profile_service.dart'; import 'package:http/http.dart'; import 'package:flutter/material.dart'; import 'package:fusion/Components/side_drawer.dart'; +import '../../Components/utils.dart'; + class RSPCModule extends StatefulWidget { String? token; RSPCModule(this.token); @@ -16,9 +17,7 @@ class RSPCModule extends StatefulWidget { } class _RSPCModuleState extends State { - bool _loading1 = true; - bool _loading2 = false; - bool _loading3 = false; + Utils utils = Utils(); bool _loading = true; late StreamController _profileController; @@ -27,12 +26,15 @@ class _RSPCModuleState extends State { @override void initState() { super.initState(); + _profileController = StreamController(); profileService = ProfileService(); + getData(); } getData() async { + //print('token-'+widget.token!); try { Response response = await profileService.getProfile(); setState(() { @@ -54,12 +56,40 @@ class _RSPCModuleState 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.menu, + 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(), - ) + ? Center(child: CircularProgressIndicator()) : Container( color: Colors.white60, child: ListView( @@ -71,6 +101,7 @@ class _RSPCModuleState extends State { margin: EdgeInsets.symmetric(horizontal: 50, vertical: 20), shadowColor: Colors.black, child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.only(top: 20), @@ -105,140 +136,173 @@ class _RSPCModuleState 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, '/rspc/research_project', - arguments: data.user != null - ? data.user!['username'] - : "null"); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Research Projects', - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 18, - color: - _loading1 ? Colors.black : Colors.black26, + SizedBox(height: 10), + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + onTap: () { + Navigator.pushNamed(context, '/rspc/research_project', + 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: [], + ), + SizedBox( + height: 4, + ), + Center( + child: Text( + "Add Research Project", + style: TextStyle(fontSize: 16), + ), ), - ), - Icon( - Icons.arrow_forward, - color: _loading1 - ? Colors.deepOrangeAccent - : Colors.white, - ) - ], + SizedBox( + height: 6, + ) + ], + ), ), ), - ], - ), - ), - 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, '/rspc/consultancy_project', - arguments: data.user != null - ? data.user!['username'] - : "null"); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Consultancy Projects', - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 18, - color: - _loading1 ? Colors.black : Colors.black26, + ), + GestureDetector( + onTap: () { + Navigator.pushNamed( + context, '/rspc/consultancy_project', + 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_box, + size: 60, + // shadows: [], + ), + SizedBox( + height: 4, ), - ), - Icon( - Icons.arrow_forward, - color: _loading1 - ? Colors.deepOrangeAccent - : Colors.white, - ) - ], + Center( + child: Text( + "Add Consultancy Project", + style: TextStyle(fontSize: 16), + ), + ), + SizedBox( + height: 6, + ) + ], + ), ), ), - ], - ), - ), - 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, '/rspc/patents', - arguments: data.user != null - ? data.user!['username'] - : "null"); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Patents', - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 18, - color: - _loading1 ? Colors.black : Colors.black26, + ), + GestureDetector( + onTap: () { + Navigator.pushNamed(context, '/rspc/patents', + 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.book, + size: 60, + // shadows: [], ), - ), - Icon( - Icons.arrow_forward, - color: _loading1 - ? Colors.deepOrangeAccent - : Colors.white, - ) - ], + SizedBox( + height: 4, + ), + Center( + child: Text( + "Patents", + style: TextStyle(fontSize: 16), + ), + ), + SizedBox( + height: 6, + ) + ], + ), ), ), - ], - ), - ), + ), + ], + ) ], ), ), ); } + + 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), + ) + ], + ), + ), + ), + ); + } } From b58cb371e1fbe849935d442c59c438cf0bf5193c Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 18:05:14 +0530 Subject: [PATCH 08/14] Removing Unnecessary comments. --- lib/screens/RSPC/Patents/patents.dart | 2 ++ lib/screens/RSPC/ResearchProject/research_project.dart | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/screens/RSPC/Patents/patents.dart b/lib/screens/RSPC/Patents/patents.dart index d60410bb..bea90288 100644 --- a/lib/screens/RSPC/Patents/patents.dart +++ b/lib/screens/RSPC/Patents/patents.dart @@ -1,3 +1,5 @@ +// ignore_for_file: unused_import + import 'package:flutter/material.dart'; // import 'package:fusion/Components/appBar.dart'; import 'package:fusion/Components/side_drawer.dart'; diff --git a/lib/screens/RSPC/ResearchProject/research_project.dart b/lib/screens/RSPC/ResearchProject/research_project.dart index 7150f896..dfc178a3 100644 --- a/lib/screens/RSPC/ResearchProject/research_project.dart +++ b/lib/screens/RSPC/ResearchProject/research_project.dart @@ -11,15 +11,6 @@ import 'package:intl/intl.dart'; import '../../../Components/utils.dart'; import '../../../services/profile_service.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)), -// ), -// ); - kTextFieldInputDecoration(String hint) { return InputDecoration( hintText: hint, From 852203fc28c34bcf41116eb2b03d808dc15fa9d4 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 18:06:31 +0530 Subject: [PATCH 09/14] Url Changes. --- lib/api.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 93b6698d..466a779a 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,11 +1,9 @@ //Server and local links String klocalLink = "127.0.0.1:8000"; -// String kserverLink = "172.27.16.215:80"; -String kserverLink = "127.0.0.1:8000"; +String kserverLink = "172.27.16.215:80"; //Login Service -// String kAuthUrl = "172.27.16.215:80"; -String kAuthUrl = "127.0.0.1:8000"; +String kAuthUrl = "172.27.16.215:80"; String kAuthLogin = "/api/auth/login/"; //Profile Service From 9774ffe8e7edef089dd115e4ea8ed65a7c391df0 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 18:57:51 +0530 Subject: [PATCH 10/14] Code cleaning. --- lib/Components/side_drawer.dart | 5 ----- lib/models/notification.dart | 8 +------- lib/screens/Gymkhana/GymkhanaHomepage.dart | 3 ++- .../DashboardComponents/cardItems.dart | 7 ++----- lib/screens/LoginandDashboard/dashboard.dart | 13 +++---------- lib/screens/landing_page.dart | 1 - lib/services/profile_service.dart | 5 +++-- lib/services/storage_service.dart | 2 -- 8 files changed, 11 insertions(+), 33 deletions(-) diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index ed77b59d..b5298885 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -124,31 +124,26 @@ class _SideDrawerState extends State { ModulesPadding( line: 'Gymkhana Module', pageMover: '/gymkhana_homepage', - isActive: true, ), ModulesPadding( line: 'Establishment Module', pageMover: '/establishment', - isActive: true, ), ModulesPadding( line: 'Library Module', pageMover: '/library_homepage', - isActive: true, ), ModulesPadding(line: 'Awards & Scholarship Module'), ModulesPadding( line: 'Complaint Module', pageMover: '/complaint', - isActive: true, ), ModulesPadding(line: 'Central Mess Module'), ModulesPadding(line: 'Feeds Module'), ModulesPadding( line: 'Health Center Module', pageMover: '/health_center', - isActive: true, ), ModulesPadding(line: 'Leave Module'), diff --git a/lib/models/notification.dart b/lib/models/notification.dart index efe57a2f..ae6bc858 100644 --- a/lib/models/notification.dart +++ b/lib/models/notification.dart @@ -28,7 +28,6 @@ class Notification { factory Notification.fromJson(json) { return Notification( id: json["id"], - // data: jsonDecode(json["data"]), data: jsonDecode(json["data"].replaceAll("'", '"')), verb: json["verb"], unread: json["unread"], @@ -42,13 +41,8 @@ class Notification { static List fromListJson(json) { List notifs = []; json.forEach((v) { - // notifs.add(Notification.fromJson(v)); - // print(Notification.fromJson(v).data); - // print(jsonDecode(v)); - // print('\n\n'); + notifs.add(Notification.fromJson(v)); }); - // print(notifs); - // print('NOTIFS'); return notifs; } } diff --git a/lib/screens/Gymkhana/GymkhanaHomepage.dart b/lib/screens/Gymkhana/GymkhanaHomepage.dart index 0e382c21..d2e0570f 100644 --- a/lib/screens/Gymkhana/GymkhanaHomepage.dart +++ b/lib/screens/Gymkhana/GymkhanaHomepage.dart @@ -9,6 +9,7 @@ import 'package:fusion/services/gymkhana_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; import 'package:http/http.dart' as http; +import 'package:http/http.dart'; class GymkhanaHomepage extends StatefulWidget { @override @@ -71,7 +72,7 @@ class _GymkhanaHomepageState extends State { //TODO: uncomment when API is functioning try { - http.Response response = await gymkhanaService.getGymkhanaData(); + Response response = await gymkhanaService.getGymkhanaData(); setState(() { //TODO: uncomment when API is functioning diff --git a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart index 1b22d919..545aa612 100644 --- a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart +++ b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart @@ -85,8 +85,7 @@ class _InfoCardState extends State { height: 10.0, ), Text( - // widget.notification.data!["module"], - '', + widget.notification.data!["module"], textAlign: TextAlign.left, style: TextStyle( fontSize: 20.0, @@ -117,9 +116,7 @@ class _InfoCardState extends State { setState(() { try { service.markRead(widget.notification.id!.toString()); - } catch (e) { - print(e); - } + } catch (e) {} }); }, style: ButtonStyle( diff --git a/lib/screens/LoginandDashboard/dashboard.dart b/lib/screens/LoginandDashboard/dashboard.dart index 477dbf5a..5394e143 100644 --- a/lib/screens/LoginandDashboard/dashboard.dart +++ b/lib/screens/LoginandDashboard/dashboard.dart @@ -47,17 +47,11 @@ class _DashboardState extends State { getData() async { try { Response response = await dashboardService.getDashboard(); - // print('response ${response.body}'); - Response response2 = await profileService.getProfile(); - // print('response ${response2.body}'); - // print(jsonDecode(response.body)); - // var decodedData = jsonDecode(response.body)['notifications'][0]; - // print(decodedData); - // print(decodedData.notifications); + Response response2 = await profileService.getProfile(); setState(() { data = DashboardData.fromJson(jsonDecode(response.body)); - // data = ; + data2 = ProfileData.fromJson(jsonDecode(response2.body)); _loading = false; }); @@ -65,7 +59,6 @@ class _DashboardState extends State { studentType = data2.profile!['department']!['name'] + ' ' + data2.profile!['user_type']; - print(name); } catch (e) { print(e); } @@ -249,7 +242,7 @@ class _DashboardState extends State { ), ), ), - (_notificationsBool) + _notificationsBool ? NotificationCard( notifications: data.notifications, ) diff --git a/lib/screens/landing_page.dart b/lib/screens/landing_page.dart index 73fc0a50..3a4ce5dd 100644 --- a/lib/screens/landing_page.dart +++ b/lib/screens/landing_page.dart @@ -14,7 +14,6 @@ class _LandingPageState extends State { return FutureBuilder( future: StorageService.getInstance(), builder: (context, AsyncSnapshot? snapshot) { - // print(snapshot?.data); if (snapshot?.hasData ?? false) { if (snapshot?.data.userInDB != null) return Dashboard(); return LoginPage(); diff --git a/lib/services/profile_service.dart b/lib/services/profile_service.dart index faed943c..dadf3c33 100644 --- a/lib/services/profile_service.dart +++ b/lib/services/profile_service.dart @@ -16,7 +16,7 @@ class ProfileService { Map headers = { 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") }; - print("fetching profile........"); + print("fetching profile"); var client = http.Client(); http.Response response = await client.get( Uri.http( @@ -27,11 +27,12 @@ class ProfileService { ); if (response.statusCode == 200) { - print("successfully fetched profile.........."); + print("successfully fetched profile"); storage_service .saveProfileInDB(ProfileData.fromJson(jsonDecode(response.body))); return response; } + throw Exception('Can\'t load'); } catch (e) { print(e); rethrow; diff --git a/lib/services/storage_service.dart b/lib/services/storage_service.dart index b444288d..94d39ea4 100644 --- a/lib/services/storage_service.dart +++ b/lib/services/storage_service.dart @@ -32,7 +32,6 @@ class StorageService with ChangeNotifier { void saveUserInDB(User userToSave) { saveStringToDisk(UserKey, json.encode(userToSave.toJson())); - print('SAVED SUCCESSFULLY '); notifyListeners(); } @@ -47,7 +46,6 @@ class StorageService with ChangeNotifier { if (_sharedPreferences == null) { _sharedPreferences = await SharedPreferences.getInstance(); } - // print(_instance); return _instance; } From 86e001df9535f20895eb99fb32993e0199448e5e Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 19:00:55 +0530 Subject: [PATCH 11/14] Error Handling Added. --- .../LoginandDashboard/DashboardComponents/cardItems.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart index 545aa612..01efef21 100644 --- a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart +++ b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart @@ -116,7 +116,9 @@ class _InfoCardState extends State { setState(() { try { service.markRead(widget.notification.id!.toString()); - } catch (e) {} + } catch (e) { + print(e); + } }); }, style: ButtonStyle( From 490686b22bd1733bb367feca777a669c325f5d1d Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Apr 2023 20:24:30 +0530 Subject: [PATCH 12/14] Fixed Styling. --- lib/screens/RSPC/rspc.dart | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/screens/RSPC/rspc.dart b/lib/screens/RSPC/rspc.dart index ef179fc8..a0dbf958 100644 --- a/lib/screens/RSPC/rspc.dart +++ b/lib/screens/RSPC/rspc.dart @@ -157,6 +157,7 @@ class _RSPCModuleState extends State { height: 125, width: MediaQuery.of(context).size.width * 0.4, child: Column( + crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( @@ -167,11 +168,10 @@ class _RSPCModuleState extends State { SizedBox( height: 4, ), - Center( - child: Text( - "Add Research Project", - style: TextStyle(fontSize: 16), - ), + Text( + "Add Research Project", + style: TextStyle(fontSize: 16), + textAlign: TextAlign.center, ), SizedBox( height: 6, @@ -199,6 +199,7 @@ class _RSPCModuleState extends State { height: 125, width: MediaQuery.of(context).size.width * 0.4, child: Column( + crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( @@ -209,11 +210,10 @@ class _RSPCModuleState extends State { SizedBox( height: 4, ), - Center( - child: Text( - "Add Consultancy Project", - style: TextStyle(fontSize: 16), - ), + Text( + "Add Consultancy Project", + style: TextStyle(fontSize: 16), + textAlign: TextAlign.center, ), SizedBox( height: 6, @@ -240,12 +240,12 @@ class _RSPCModuleState extends State { height: 125, width: MediaQuery.of(context).size.width * 0.4, child: Column( + crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.book, size: 60, - // shadows: [], ), SizedBox( height: 4, @@ -254,6 +254,7 @@ class _RSPCModuleState extends State { child: Text( "Patents", style: TextStyle(fontSize: 16), + textAlign: TextAlign.center, ), ), SizedBox( From 56581419d8822858db5f670182c9dd6bbc1cbc81 Mon Sep 17 00:00:00 2001 From: Devendra Date: Thu, 20 Apr 2023 03:03:19 +0530 Subject: [PATCH 13/14] Changing Fields of Research Project. --- lib/services/rspc_service.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/rspc_service.dart b/lib/services/rspc_service.dart index c12d9166..2d72f791 100644 --- a/lib/services/rspc_service.dart +++ b/lib/services/rspc_service.dart @@ -30,9 +30,9 @@ class RSPCService { 'financial_outlay': financialOutlay, 'funding_agency': fundingAgency, 'status': currentStatus, - 'start': startDate, - 'end': expectedFinishDate, - 'sub': submissionDate, + 'start_date': startDate, + 'finish_date': expectedFinishDate, + 'date_submission': submissionDate, }; var storageService = locator(); if (storageService.userInDB?.token == null) From 0b1eaaee228cacfcf7086ec89ab3268edb2d4117 Mon Sep 17 00:00:00 2001 From: Devendra Patil <95930224+Devendra072002@users.noreply.github.com> Date: Thu, 20 Apr 2023 14:02:24 +0530 Subject: [PATCH 14/14] Added Two more screens for viewing research and consultancy projects data. --- lib/api.dart | 3 + lib/main.dart | 8 +- lib/models/project.dart | 19 ++ .../ViewProject/consultancy_projects.dart | 263 ++++++++++++++++ .../RSPC/ViewProject/research_projects.dart | 281 ++++++++++++++++++ lib/screens/RSPC/rspc.dart | 93 +++++- lib/services/consultancy_project_service.dart | 41 +++ lib/services/research_project_service.dart | 41 +++ 8 files changed, 742 insertions(+), 7 deletions(-) create mode 100644 lib/models/project.dart create mode 100644 lib/screens/RSPC/ViewProject/consultancy_projects.dart create mode 100644 lib/screens/RSPC/ViewProject/research_projects.dart create mode 100644 lib/services/consultancy_project_service.dart create mode 100644 lib/services/research_project_service.dart diff --git a/lib/api.dart b/lib/api.dart index 466a779a..9a6aaf8b 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -34,6 +34,9 @@ String kHealthCentreStudent = "/healthcenter/api/student"; String kResearchProjectNew = "/research_procedures/api/new_research_project"; String kConsultantProjectNew = "/research_procedures/api/new_consultant_project"; +String kResearchProjects = "/research_procedures/api/get_research_projects"; +String kConsultancyProjects = + "/research_procedures/api/get_consultancy_projects"; //------------Screens------------ diff --git a/lib/main.dart b/lib/main.dart index 7cbe9144..458028e2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,6 +38,8 @@ import 'package:fusion/screens/Programme_Curriculum/programme_curriculum_home.da import 'package:fusion/screens/RSPC/Patents/patents.dart'; import 'package:fusion/screens/RSPC/ConsultancyProject/consultancy_project.dart'; import 'package:fusion/screens/RSPC/ResearchProject/research_project.dart'; +import 'package:fusion/screens/RSPC/ViewProject/consultancy_projects.dart'; +import 'package:fusion/screens/RSPC/ViewProject/research_projects.dart'; import 'package:fusion/screens/landing_page.dart'; import 'package:fusion/screens/Healthcenter/healthcentermodule.dart'; import 'package:fusion/screens/Healthcenter/feedback.dart'; @@ -131,7 +133,7 @@ class MyApp extends StatelessWidget { '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), '/health_center/history': (context) => History(), - '/rspc': (context) => + '/rspc': (context) => RSPCModule(ModalRoute.of(context)!.settings.arguments.toString()), '/rspc/research_project': (context) => AddResearchProject( ModalRoute.of(context)!.settings.arguments.toString()), @@ -139,6 +141,10 @@ class MyApp extends StatelessWidget { ModalRoute.of(context)!.settings.arguments.toString()), '/rspc/patents': (context) => Patents(ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/view_research_project': (context) => ResearchProject( + ModalRoute.of(context)!.settings.arguments.toString()), + '/rspc/view_consultancy_project': (context) => ConsultancyProject( + ModalRoute.of(context)!.settings.arguments.toString()), }, ), ); diff --git a/lib/models/project.dart b/lib/models/project.dart new file mode 100644 index 00000000..f2fd3d17 --- /dev/null +++ b/lib/models/project.dart @@ -0,0 +1,19 @@ +class ProjectData { + List? projects; + + ProjectData({ + this.projects, + }); + + factory ProjectData.fromJson(Map json) { + return ProjectData( + projects: json["projects"], + ); + } + + Map toJson() { + return { + "projects": this.projects, + }; + } +} diff --git a/lib/screens/RSPC/ViewProject/consultancy_projects.dart b/lib/screens/RSPC/ViewProject/consultancy_projects.dart new file mode 100644 index 00000000..66f95824 --- /dev/null +++ b/lib/screens/RSPC/ViewProject/consultancy_projects.dart @@ -0,0 +1,263 @@ +// import 'dart:ffi'; + +// import 'package:date_field/date_field.dart'; +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart'; +import '../../../Components/utils.dart'; +import '../../../models/profile.dart'; +import '../../../models/project.dart'; +import '../../../services/consultancy_project_service.dart'; +import '../../../services/service_locator.dart'; +import '../../../services/storage_service.dart'; + +class ConsultancyProject extends StatefulWidget { + final uid; + ConsultancyProject(this.uid); + @override + _ConsultancyProjectState createState() => _ConsultancyProjectState(); +} + +class _ConsultancyProjectState extends State { + bool _loading1 = true; + ProfileData? data; + late StreamController _projectController; + late ProjectService projectService; + late ProjectData projectData; + Utils utils = Utils(); + + @override + void initState() { + super.initState(); + var service = locator(); + data = service.profileData; + _projectController = StreamController(); + projectService = ProjectService(); + if (data == null) {} + getData(); + } + + getData() async { + try { + Response response = await projectService.getProjectData(); + + setState(() { + print(response.body); + projectData = ProjectData.fromJson(jsonDecode(response.body)); + print(projectData); + _loading1 = false; + }); + } catch (e) { + print(e); + } + } + + @override + void dispose() { + _projectController.close(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData.dark(), + home: _loading1 == true + ? Center(child: CircularProgressIndicator()) + : Projects(data: projectData), + debugShowCheckedModeBanner: false, + ); + } +} + +class Projects extends StatelessWidget { + final ProjectData data; + Utils utils = Utils(); + Projects({required this.data}); + + Widget bodyData() => SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columnSpacing: 35, + columns: [ + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Consultant", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Client", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Title", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Funding Outlay", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Status", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Start Date", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "End Date", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + ], + rows: getRows()), + ), + ); + List getRows() { + print(data.projects); + List dummy = [ + DataRow(cells: [ + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + ]), + ]; + + if (data.projects == null) { + print("No Projects Available"); + return dummy; + } + + if (data.projects!.length == 0) { + print("No Projects Available"); + return dummy; + } + + return data.projects! + .map((element) => DataRow(cells: [ + DataCell(Text(element['consultants'])), + DataCell(Text(element['client'])), + DataCell(Text(element['title'])), + DataCell(Text(element['financial_outlay'].toString())), + DataCell(Text(element['status'])), + DataCell(Text(element['start_date'])), + DataCell(Text(element['end_date'])), + ])) + .toList(); + } + + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 1, + child: Scaffold( + appBar: AppBar( + leading: utils.leadingPopIconsButton(Colors.black, context), + title: Text( + "Research Projects", + style: TextStyle( + color: utils.primarycolor, fontWeight: FontWeight.bold), + ), + ), + body: bodyData(), + ), + ); + } +} diff --git a/lib/screens/RSPC/ViewProject/research_projects.dart b/lib/screens/RSPC/ViewProject/research_projects.dart new file mode 100644 index 00000000..785193e3 --- /dev/null +++ b/lib/screens/RSPC/ViewProject/research_projects.dart @@ -0,0 +1,281 @@ +// import 'dart:ffi'; + +// import 'package:date_field/date_field.dart'; +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart'; +import '../../../Components/utils.dart'; +import '../../../models/profile.dart'; +import '../../../models/project.dart'; +import '../../../services/research_project_service.dart'; +import '../../../services/service_locator.dart'; +import '../../../services/storage_service.dart'; + +class ResearchProject extends StatefulWidget { + final uid; + ResearchProject(this.uid); + @override + _ResearchProjectState createState() => _ResearchProjectState(); +} + +class _ResearchProjectState extends State { + bool _loading1 = true; + ProfileData? data; + late StreamController _projectController; + late ProjectService projectService; + late ProjectData projectData; + Utils utils = Utils(); + + @override + void initState() { + super.initState(); + var service = locator(); + data = service.profileData; + _projectController = StreamController(); + projectService = ProjectService(); + if (data == null) {} + getData(); + } + + getData() async { + try { + Response response = await projectService.getProjectData(); + + setState(() { + print(response.body); + projectData = ProjectData.fromJson(jsonDecode(response.body)); + print(projectData); + _loading1 = false; + }); + } catch (e) { + print(e); + } + } + + @override + void dispose() { + _projectController.close(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData.dark(), + home: _loading1 == true + ? Center(child: CircularProgressIndicator()) + : Projects(data: projectData), + debugShowCheckedModeBanner: false, + ); + } +} + +class Projects extends StatelessWidget { + final ProjectData data; + Utils utils = Utils(); + Projects({required this.data}); + + Widget bodyData() => SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columnSpacing: 35, + columns: [ + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "PI", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Co-PI's", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Title", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Funding Agency", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Financial Outlay", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Status", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Submission Date", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + DataColumn( + label: Flexible( + child: SizedBox( + width: 100, + child: Text( + "Start Date", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.visible, + softWrap: true, + ), + ), + ), + numeric: false, + onSort: (i, b) {}, + ), + ], + rows: getRows()), + ), + ); + List getRows() { + print(data.projects); + List dummy = [ + DataRow(cells: [ + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + DataCell(Text('')), + ]), + ]; + + if (data.projects == null) { + print("No Projects Available"); + return dummy; + } + + if (data.projects!.length == 0) { + print("No Projects Available"); + return dummy; + } + + return data.projects! + .map((element) => DataRow(cells: [ + DataCell(Text(element['pi'])), + DataCell(Text(element['co_pi'])), + DataCell(Text(element['title'])), + DataCell(Text(element['funding_agency'])), + DataCell(Text(element['financial_outlay'])), + DataCell(Text(element['status'])), + DataCell(Text(element['date_submission'])), + DataCell(Text(element['start_date'])), + ])) + .toList(); + } + + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 1, + child: Scaffold( + appBar: AppBar( + leading: utils.leadingPopIconsButton(Colors.black, context), + title: Text( + "Research Projects", + style: TextStyle( + color: utils.primarycolor, fontWeight: FontWeight.bold), + ), + ), + body: bodyData(), + ), + ); + } +} diff --git a/lib/screens/RSPC/rspc.dart b/lib/screens/RSPC/rspc.dart index a0dbf958..5e3b8f77 100644 --- a/lib/screens/RSPC/rspc.dart +++ b/lib/screens/RSPC/rspc.dart @@ -250,12 +250,93 @@ class _RSPCModuleState extends State { SizedBox( height: 4, ), - Center( - child: Text( - "Patents", - style: TextStyle(fontSize: 16), - textAlign: TextAlign.center, - ), + Text( + "Patents", + style: TextStyle(fontSize: 16), + textAlign: TextAlign.center, + ), + SizedBox( + height: 6, + ) + ], + ), + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.pushNamed( + context, '/rspc/view_research_project', + 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( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.border_color_outlined, + size: 60, + ), + SizedBox( + height: 4, + ), + Text( + "Research Projects", + style: TextStyle(fontSize: 16), + textAlign: TextAlign.center, + ), + SizedBox( + height: 6, + ) + ], + ), + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.pushNamed( + context, '/rspc/view_consultancy_project', + 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( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.border_color_outlined, + size: 60, + // shadows: [], + ), + SizedBox( + height: 4, + ), + Text( + "Consultancy Projects", + style: TextStyle(fontSize: 16), + textAlign: TextAlign.center, ), SizedBox( height: 6, diff --git a/lib/services/consultancy_project_service.dart b/lib/services/consultancy_project_service.dart new file mode 100644 index 00000000..5e9f5332 --- /dev/null +++ b/lib/services/consultancy_project_service.dart @@ -0,0 +1,41 @@ +// ignore_for_file: non_constant_identifier_names + +import 'dart:convert'; +import '../api.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:http/http.dart' as http; + +import '../constants.dart'; + +class ProjectService { + getProjectData() async { + try { + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + print("fetching Penalty"); + var client = http.Client(); + http.Response response = await client.get( + Uri.http( + getLink(), + kConsultancyProjects, + ), + headers: headers, + ); + if (response.statusCode == 200) { + print("successfully fetched Project Data"); + return response; + } else { + print("error fetching Project Data"); + } + throw Exception('Can\'t load Project Data'); + } catch (e) { + rethrow; + } + } +} diff --git a/lib/services/research_project_service.dart b/lib/services/research_project_service.dart new file mode 100644 index 00000000..a9f69a28 --- /dev/null +++ b/lib/services/research_project_service.dart @@ -0,0 +1,41 @@ +// ignore_for_file: non_constant_identifier_names + +import 'dart:convert'; +import '../api.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:http/http.dart' as http; + +import '../constants.dart'; + +class ProjectService { + getProjectData() async { + try { + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + print("fetching Penalty"); + var client = http.Client(); + http.Response response = await client.get( + Uri.http( + getLink(), + kResearchProjects, + ), + headers: headers, + ); + if (response.statusCode == 200) { + print("successfully fetched Project Data"); + return response; + } else { + print("error fetching Project Data"); + } + throw Exception('Can\'t load Project Data'); + } catch (e) { + rethrow; + } + } +}