From 1505674033beac7ab77dc5a54cdda87def08d9ea Mon Sep 17 00:00:00 2001 From: Arindam Upadhyay <20bec018@iiitdmj.ac.in> Date: Mon, 27 Mar 2023 13:11:13 +0530 Subject: [PATCH 1/5] script structured --- clone.sh | 13 ------------- scripts/clone.sh | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 clone.sh create mode 100644 scripts/clone.sh diff --git a/clone.sh b/clone.sh deleted file mode 100644 index 3a3780c4..00000000 --- a/clone.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -#branches=("ac-1" "ac-2" "ac-3" "ac-4" "ac-5" "ps-1" "ps-2" "gad-1" "gad-2" "gad-3" "gad-4" "gad-5" "hr" "sa-1" "sa-2" "sa-3" "sa-4" "os-1" "os-2" "os-3" "os-4" "rspc") -branches=("ac") -for branch in "${branches[@]}" -do - echo "Creating $branch" - - git checkout -b "$branch" - git push origin "$branch" - - echo "Pushed new branch $branch to remote" -done \ No newline at end of file diff --git a/scripts/clone.sh b/scripts/clone.sh new file mode 100644 index 00000000..20bf0276 --- /dev/null +++ b/scripts/clone.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +branches=("ac" "ac-1" "ac-2" "ac-3" "ac-4" "ac-5" "ps-1" "ps-2" "gad-1" "gad-2" "gad-3" "gad-4" "gad-5" "hr" "sa-1" "sa-2" "sa-3" "sa-4" "os-1" "os-2" "os-3" "os-4" "rspc") + +for branch in "${branches[@]}" +do + echo "Creating $branch..." + + git checkout -b "$branch" + git push origin "$branch" + + echo "Pushed new branch $branch to remote" +done \ No newline at end of file From aa2e5791c9de58bf6f19f7220e74d8c2306c14d5 Mon Sep 17 00:00:00 2001 From: AgPriyanshu18 Date: Fri, 17 Nov 2023 17:02:40 +0530 Subject: [PATCH 2/5] Server Url updated --- android/build.gradle | 4 ++-- android/gradle/wrapper/gradle-wrapper.properties | 2 +- lib/api.dart | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index b3a325d5..a78be8cb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.8.21' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index cc5527d7..6b665338 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..73d1c6bc 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,10 +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.214:8000"; //Login Service -String kAuthUrl = "172.27.16.215:80"; +String kAuthUrl = "172.27.16.214:8000"; String kAuthLogin = "/api/auth/login/"; +// String kAuthLogin = "/accounts/login"; //Profile Service String kProfile = "/api/profile/"; From d329bf366a06f21c4acea0b74852b8a843557da7 Mon Sep 17 00:00:00 2001 From: Praneki <97080887+PraneGIT@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:51:24 +0530 Subject: [PATCH 3/5] Gad 5 to main (#162) * Ui Changes and Added functionality of designation * Updated kserverLink,kAuthUrl and gradle ver (7.4.2) --------- Co-authored-by: TusharGupta03 --- android/build.gradle | 2 +- lib/Components/appBar2.dart | 106 +++++ lib/Components/bottom_navigation_bar.dart | 148 +++++++ lib/Components/side_drawer2.dart | 264 ++++++++++++ lib/DesignationProvider.dart | 12 + lib/api.dart | 1 + lib/main.dart | 12 +- .../DashboardComponents/announcement.dart | 200 +++++++++ .../DashboardComponents/cardItems.dart | 76 ++-- .../DashboardComponents/news.dart | 201 +++++++++ .../DashboardComponents/notify.dart | 152 +++++++ lib/screens/LoginandDashboard/dashboard.dart | 389 +++++++++++------- lib/screens/LoginandDashboard/login_page.dart | 155 ++++--- lib/services/appBar_services.dart | 14 + lib/services/dashboard_service.dart | 51 ++- lib/services/login_service.dart | 16 +- lib/services/storage_service.dart | 14 +- 17 files changed, 1543 insertions(+), 270 deletions(-) create mode 100644 lib/Components/appBar2.dart create mode 100644 lib/Components/bottom_navigation_bar.dart create mode 100644 lib/Components/side_drawer2.dart create mode 100644 lib/DesignationProvider.dart create mode 100644 lib/screens/LoginandDashboard/DashboardComponents/announcement.dart create mode 100644 lib/screens/LoginandDashboard/DashboardComponents/news.dart create mode 100644 lib/screens/LoginandDashboard/DashboardComponents/notify.dart create mode 100644 lib/services/appBar_services.dart diff --git a/android/build.gradle b/android/build.gradle index a78be8cb..881e7e55 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/lib/Components/appBar2.dart b/lib/Components/appBar2.dart new file mode 100644 index 00000000..a1f63393 --- /dev/null +++ b/lib/Components/appBar2.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/constants.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; + +class CustomAppBar extends StatefulWidget implements PreferredSizeWidget { + final String curr_desig; + final String headerTitle; + + final ValueChanged onDesignationChanged; + + const CustomAppBar({ + Key? key, + required this.curr_desig, + required this.headerTitle, + + required this.onDesignationChanged, + }) : super(key: key); + + @override + _CustomAppBarState createState() => _CustomAppBarState(); + + @override + Size get preferredSize => Size.fromHeight(kToolbarHeight); +} + +class _CustomAppBarState extends State { + late List designations; + late String current; + var service = locator(); + + @override + void initState() { + super.initState(); + designations = (service!.getFromDisk('designations') as List) + .map((dynamic item) => item.toString()) + .toList(); + + current = service!.getFromDisk( + 'Current_designation'); // Ensure designations is not null before accessing index 0 + } + + @override + Widget build(BuildContext context) { + return AppBar( + iconTheme: IconThemeData(color: Colors.white), + backgroundColor: kPrimaryColor, + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Padding( + padding: EdgeInsets.only(right: 20.0), // Add some right padding to ensure space for the dropdown + child: Text( + widget.headerTitle, // Example of a long title + overflow: TextOverflow.ellipsis, // Prevents overflow by adding ellipsis + style: TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + DropdownButtonHideUnderline( + child: DropdownButton( + padding: const EdgeInsets.all(15), + borderRadius: BorderRadius.circular(5), + value: current, + icon: Icon(Icons.arrow_drop_down, color: Colors.white), + iconSize: 24, + style: TextStyle(color: Colors.white, fontSize: 18), + dropdownColor: + kPrimaryColor, // Set the dropdown background color to orange + onChanged: (String? newValue) { + widget.onDesignationChanged(newValue!); + setState(() { + current = newValue!; + service!.saveToDisk('Current_designation', current); + }); + }, + items: designations.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: TextStyle( + color: Colors.white), // Set the text color to white + ), + ); + }).toList(), + onTap: () { + // Find the index of the selected value + int index = designations.indexOf(current); + // Scroll the dropdown to the selected value + Scrollable.ensureVisible(context, + alignment: 0.5, duration: Duration(milliseconds: 300)); + }, + ), + ), + ], + ), + actions: [], + ); + } +} \ No newline at end of file diff --git a/lib/Components/bottom_navigation_bar.dart b/lib/Components/bottom_navigation_bar.dart new file mode 100644 index 00000000..f95ad3c3 --- /dev/null +++ b/lib/Components/bottom_navigation_bar.dart @@ -0,0 +1,148 @@ +import 'package:flutter/material.dart'; + +class MyBottomNavigationBar extends StatefulWidget { + @override + _MyBottomNavigationBarState createState() => _MyBottomNavigationBarState(); +} + +class _MyBottomNavigationBarState extends State { + bool _notificationsBool = false; + bool _announcementsBool = false; + bool _newsBool = false; + bool _homeBool = false; + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 100.0, + child: Padding( + padding: EdgeInsets.only(bottom: 40), + child: Card( + color: Colors.deepOrangeAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(17.0), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 13.0, right: 10.0, top: 5.0, bottom: 5.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + onTap: () { + _notificationsBool = false; + _announcementsBool = false; + _newsBool = false; + _homeBool = true; + setState(() { + _notificationsBool = false; + _announcementsBool = false; + _newsBool = false; + _homeBool = true; + }); + Navigator.pushReplacementNamed(context, "/dashboard"); + + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon( + Icons.home_rounded, + color: Colors.white, + size: _homeBool ? 30.0 : 25.0, + ), + ], + ), + ), + GestureDetector( + onTap: () { + _newsBool = true; + _announcementsBool = false; + _notificationsBool = false; + _homeBool = false; + + setState(() { + _newsBool = true; + _announcementsBool = false; + _notificationsBool = false; + _homeBool = false; + }); + Navigator.pushReplacementNamed(context, "/news"); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon( + Icons.newspaper_rounded, + color: Colors.white, + size: _newsBool ? 30.0 : 25.0, + ), + ], + ), + ), + GestureDetector( + onTap: () { + _announcementsBool = false; + _newsBool = false; + _notificationsBool = true; + _homeBool = false; + + setState(() { + _announcementsBool = false; + _newsBool = false; + _notificationsBool = true; + _homeBool = false; + }); + Navigator.pushReplacementNamed(context, "/notification"); + }, + child: Padding( + padding: const EdgeInsets.only(right: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon( + Icons.notifications_active_rounded, + color: Colors.white, + size: _notificationsBool ? 30.0 : 25.0, + ), + ], + ), + ), + ), + GestureDetector( + onTap: () { + _announcementsBool = true; + _newsBool = false; + _notificationsBool = false; + _homeBool = false; + + setState(() { + _announcementsBool = true; + _newsBool = false; + _notificationsBool = false; + _homeBool = false; + }); + Navigator.pushReplacementNamed(context, "/announcement"); + }, + child: Padding( + padding: const EdgeInsets.only(right: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon( + Icons.campaign_rounded, + color: Colors.white, + size: _announcementsBool ? 30.0 : 25.0, + ), + ], + ), + ), + ), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/Components/side_drawer2.dart b/lib/Components/side_drawer2.dart new file mode 100644 index 00000000..97c80e8d --- /dev/null +++ b/lib/Components/side_drawer2.dart @@ -0,0 +1,264 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; + +class SideDrawer extends StatefulWidget { + final String curr_desig; + + const SideDrawer({ + Key? key, + required this.curr_desig, + }) : super(key: key); + + @override + _SideDrawerState createState() => _SideDrawerState(); +} + +class _SideDrawerState extends State { + bool _loading = false; + int count = 0; + late String name; + late String depttype; + late String type; + @override + void initState() { + super.initState(); + var service = locator(); + print(service.profileData); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name']; + + type = service.profileData.profile!['user_type']; + print(depttype); + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Container( + margin: const EdgeInsets.only(right: 50.0), + height: MediaQuery.of(context).size.height, + color: Colors.white, + child: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Column( + children: [ + Card( + elevation: 2.0, + margin: + EdgeInsets.symmetric(horizontal: 12.0, vertical: 30.0), + // shadowColor: Colors.black, + color: Colors.white, + + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 0.0), + width: 270.0, + height: 120.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/profile_pic.png'), + fit: BoxFit.contain, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, //Display name of User + style: TextStyle( + fontSize: 20.0, + color: Colors.black, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype + + " " + + widget.curr_desig, // Display Type of User + style: TextStyle( + fontSize: 17.0, + color: Colors.black, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + ], + ), + ModulesCard(cardLine: 'DashBoard', pageMover: '/dashboard'), + + if ((type != "staff" || widget.curr_desig=="acadmin"|| widget.curr_desig== "corelabcaretaker")) + ModulesCard( + cardLine: 'Academics Module', + pageMover: '/academic_home_page', + ), + + if ((type == "student" || widget.curr_desig=="acadmin")) + ModulesCard( + cardLine: 'Programme Curriculum', + pageMover: '/programme_curriculum_home', + ), + + if ((type == "student") || widget.curr_desig== "Dean_s" || widget.curr_desig== "DeanPnD" || widget.curr_desig== "dean_rspc" || widget.curr_desig== "dean_s" ) + ModulesCard( + cardLine: 'Gymkhana Module', + pageMover: '/gymkhana_homepage', + ), + + if ((type == "student" || widget.curr_desig== "mess_manager" || widget.curr_desig== "mess_warden")) + ModulesCard(cardLine: 'Central Mess Module',pageMover: '/central_mess_home'), + + + ModulesCard( + cardLine: 'Health Center Module', + pageMover: '/health_center', + ), + if ((type == "student" )) + ModulesCard(cardLine: 'Leave Module'), + + if ((type == "student" )) + ModulesCard(cardLine: 'Purchase and Store'), + + if ((type == "student" )) + ModulesCard(cardLine: 'Human Resource'), + + if(type == "student"|| widget.curr_desig=="placement chairman" || widget.curr_desig=="placement officer") + ModulesCard(cardLine: 'Placement Module'), + + ModulesCard(cardLine: 'Visitors Hostel Module',pageMover: '/visitor_hostel'), + + if(type != "student") + ModulesCard(cardLine: 'File Tracking Module',pageMover: '/compose_file'), + + ModulesCard( + cardLine: 'Establishment Module', pageMover: '/establishment'), + + ModulesCard( + cardLine: 'Library Module', pageMover: '/library_homepage'), + + if(type == "student" || widget.curr_desig== "spacsconvenor"|| widget.curr_desig== "spacsassistant") + ModulesCard(cardLine: 'Awards & Scholarship Module'), + + ModulesCard(cardLine: 'Complaint Module', pageMover: '/complaint'), + + ModulesCard(cardLine: 'Research Module'), + + ModulesCard(cardLine: 'Counselling Cell'), + + if ((type == "faculty" ||widget.curr_desig== "acadadmin" )) + ModulesCard(cardLine: 'Examination Module',pageMover: '/examination',), + + + + if ((widget.curr_desig== "Executive Engineer (Civil)" ||widget.curr_desig== "EE" || widget.curr_desig== "Admin IWD" || widget.curr_desig== "Electrical_AE" || widget.curr_desig== "mess_manager" || widget.curr_desig== "Electrical_JE" || widget.curr_desig== "Civil_AE" || widget.curr_desig== "Civil_JE" || widget.curr_desig== "Director" || widget.curr_desig== "dean_s" || widget.curr_desig== "Dean_s" || widget.curr_desig== "DeanPnD" )) + ModulesCard(cardLine: 'IWD',pageMover: '/iwd/home_page'), + + + ModulesCard(cardLine: 'Courses Module', pageMover: '/registered_courses', + ), + ModulesCard(cardLine: 'HR Module', pageMover: '/hr_homepage', + ), + + + // ModulesCard( + // cardLine: 'Profile', + // icon: Icons.account_circle, + // pageMover: '/profile'), + + // ModulesCard(cardLine: 'Office Of Dean Students'), + // ModulesCard(cardLine: 'Office Of Dean Academics'), + // ModulesCard(cardLine: 'Director Office'), + // ModulesCard(cardLine: 'Office Of Purchase Officer'), + // ModulesCard(cardLine: 'Office Of Registrar'), + // ModulesCard(cardLine: 'Office Of P&D'), + // ModulesCard(cardLine: 'Office Of HOD (Branch)'), + // ModulesCard(cardLine: 'Finance & Accounts'), + // ModulesCard(cardLine: 'Meet Our Team'), + ModulesCard(cardLine: 'Log Out', icon: Icons.logout), + ], + ), + ), + ); + } + +String _getGymkhanaPage() { + + // Determine the pageMover based on designation + print(widget.curr_desig); + if (widget.curr_desig == 'co-ordinator') { + + return '/gymkhana_coordinator'; + } + else if(widget.curr_desig == 'Counsellor'){ + return '/gymkhana_counsellor'; + } + else if(widget.curr_desig == 'Convenor'){ + return '/gymkhana_convenor'; + } + else if(widget.curr_desig == 'Dean Academic'){ + return '/gymkhana_dean'; + } + + else + return '/gymkhana_homepage'; + } +// ignore: must_be_immutable +} + +class ModulesCard extends StatelessWidget { + final String? cardLine; + final String? pageMover; + IconData? icon; + ModulesCard({this.cardLine, this.icon, this.pageMover}); + @override + Widget build(BuildContext context) { + return GestureDetector( + //behaviour to translucent to get Tap even on blank or empty space within container + behavior: HitTestBehavior.translucent, + child: Card( + color: Colors.white, + margin: const EdgeInsets.all(10.0), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + cardLine!, + style: TextStyle(fontSize: 16.0, color: Colors.black), + ), + Icon( + icon, + color: Colors.deepOrangeAccent, + ), + ], + ), + ), + ), + onTap: () async { + var _prefs = await StorageService.getInstance(); + String token = _prefs!.userInDB?.token ?? ""; + if (cardLine == 'Log Out') { + LoginService auth = LoginService(); + auth.logout(); + Navigator.pushReplacementNamed(context, "/landing"); + } + if (pageMover != null) + Navigator.pushReplacementNamed(context, pageMover!, arguments: token); + }, + ); + } +} \ No newline at end of file diff --git a/lib/DesignationProvider.dart b/lib/DesignationProvider.dart new file mode 100644 index 00000000..34031248 --- /dev/null +++ b/lib/DesignationProvider.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class DesignationProvider extends ChangeNotifier { + late String _designation; + + String get designation => _designation; + + void updateDesignation(String newDesignation) { + _designation = newDesignation; + notifyListeners(); // Notify listeners about the change + } +} \ No newline at end of file diff --git a/lib/api.dart b/lib/api.dart index 73d1c6bc..1f76a52b 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -21,6 +21,7 @@ String kComplaintRemove = "/complaint/api/removecomplain/"; //Dashboard String kDashboard = "/api/dashboard/"; +String kNotification = "/api/notification/"; String kNotificationRead = "/api/notification/read/"; //Gymkhana diff --git a/lib/main.dart b/lib/main.dart index 9ca81ff8..4cd5af87 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,7 +9,10 @@ import 'package:fusion/screens/Library/Book_Search.dart'; import 'package:fusion/screens/Library/dues.dart'; import 'package:fusion/screens/Library/issued_items.dart'; import 'package:fusion/screens/Library/lib_home_screen.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/news.dart'; import 'package:fusion/screens/LoginandDashboard/dashboard.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/notify.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/announcement.dart'; import 'package:fusion/screens/LoginandDashboard/login_page.dart'; import 'package:fusion/screens/Academic/academic_home_page.dart'; import 'package:fusion/screens/Academic/Current_Semester/current_semester_home_page.dart'; @@ -60,9 +63,9 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { MediaQueryData windowData = - MediaQueryData.fromWindow(WidgetsBinding.instance.window); + MediaQueryData.fromView(WidgetsBinding.instance.window); windowData = windowData.copyWith( - textScaleFactor: 1, + textScaler: TextScaler.linear(1), ); return MediaQuery( data: windowData, @@ -81,6 +84,9 @@ class MyApp extends StatelessWidget { routes: { '/landing': (context) => LandingPage(), '/login_page': (context) => LoginPage(), + '/notification':(context)=>Notify(), + '/news':(context)=>News(), + '/announcement':(context)=>Announcement(), '/dashboard': (context) => Dashboard(), '/academic_home_page': (context) => AcademicHomePage( ModalRoute.of(context)!.settings.arguments.toString()), @@ -131,4 +137,4 @@ class MyApp extends StatelessWidget { ), ); } -} +} \ No newline at end of file diff --git a/lib/screens/LoginandDashboard/DashboardComponents/announcement.dart b/lib/screens/LoginandDashboard/DashboardComponents/announcement.dart new file mode 100644 index 00000000..c0db276f --- /dev/null +++ b/lib/screens/LoginandDashboard/DashboardComponents/announcement.dart @@ -0,0 +1,200 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar2.dart'; +import 'package:fusion/Components/side_drawer2.dart'; +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 'package:fusion/Components/bottom_navigation_bar.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; + +class Announcement extends StatefulWidget { + static String tag = 'home-page'; + @override + _AnnouncementState createState() => _AnnouncementState(); +} + +class _AnnouncementState extends State { + bool _notificationsBool = false; + bool _newsBool = false; + bool _announcementsBool = true; + bool _homeBool = false; + + bool _loading = true; + late String name; + late String studentType; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + var service = locator(); + late String curr_desig = service.getFromDisk("Current_designation"); + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + print("gfsgsgd"); + Response response = await dashboardService.getDashboard(); + print("1"); + Response response2 = await profileService.getProfile(); + print("2"); + print(response); + print(response2); + + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + final GlobalKey scaffoldKey = new GlobalKey(); + showSnack() { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text('New Content Loaded'), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: CustomAppBar( + curr_desig: curr_desig, + headerTitle: "Announcement", + + onDesignationChanged: (newValue) { + setState(() { + curr_desig = newValue; + }); + }, + ), + bottomNavigationBar: MyBottomNavigationBar(), + drawer: SideDrawer(curr_desig: curr_desig), + body: _loading == true + ? Center(child: CircularProgressIndicator()) + : StreamBuilder( + stream: _dashboardController.stream, + builder: (context, AsyncSnapshot snapshot) { + return Stack(children: [ + Positioned( + left: 0, + child: Column( + children: [ + Card( + elevation: 0, + margin: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 10.0), + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 13.0, + right: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + setState(() { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + }); + Navigator.pushReplacementNamed( + context, "/notification"); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + // Only handle navigation when the icon is clicked + _notificationsBool = false; + _announcementsBool = true; + _newsBool = false; + setState(() { + _notificationsBool = false; + _announcementsBool = true; + _newsBool = false; + }); + Navigator.pushReplacementNamed( + context, "/landing"); + }, + child: Icon( + Icons.navigate_before_rounded, + color: Colors.black, + size: 25.0, + ), + ), + SizedBox(width: 20.0), + Text( + 'Announcement', + style: TextStyle( + fontSize: 22.0, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(width: 170.0), + ], + ), + ), + ], + ), + ), + ), + + + ], + ), + ), + ]); + }, + ), + ); + } + + @override + void dispose() { + _dashboardController.close(); + super.dispose(); + } +} \ No newline at end of file diff --git a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart index fffcde98..63afcdd9 100644 --- a/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart +++ b/lib/screens/LoginandDashboard/DashboardComponents/cardItems.dart @@ -1,36 +1,34 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'package:fusion/models/notification.dart' as notif; import 'package:fusion/services/dashboard_service.dart'; class NotificationCard extends StatelessWidget { final List? notifications; - const NotificationCard({Key? key, required this.notifications}) - : super(key: key); + const NotificationCard({Key? key, required this.notifications}) : super(key: key); @override Widget build(BuildContext context) { return Card( elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), shadowColor: Colors.black, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: getCards(), + child: SingleChildScrollView( // Added to allow scrolling + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: getCards(), + ), ), ); } - getCards() { - List cards = []; - for (int i = 0; i < notifications!.length; i++) { - cards.add(InfoCard( - notification: notifications![i], - )); - } - return cards; + List getCards() { + // Transforming the notifications into InfoCard widgets + return notifications!.map((notif.Notification notification) { + return InfoCard( + notification: notification, + ); + }).toList(); } } @@ -38,19 +36,20 @@ class NewsCard extends StatelessWidget { @override Widget build(BuildContext context) { return Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + elevation: 0, + margin: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 10.0), shadowColor: Colors.black, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Card( elevation: 3.0, - margin: EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0), + margin: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0), shadowColor: Colors.black, - child: Center( + child: const Center( child: Padding( - padding: const EdgeInsets.all(18.0), + padding: EdgeInsets.all(18.0), child: Text('Work in progress'), ), ), @@ -64,9 +63,10 @@ class NewsCard extends StatelessWidget { class InfoCard extends StatefulWidget { final notif.Notification notification; - InfoCard({ + const InfoCard({ + Key? key, required this.notification, - }); + }) : super(key: key); @override _InfoCardState createState() => _InfoCardState(); @@ -77,46 +77,38 @@ class _InfoCardState extends State { Widget build(BuildContext context) { return Card( elevation: 3.0, - margin: EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0), + margin: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0), shadowColor: Colors.black, child: Column( children: [ - SizedBox( - height: 10.0, - ), + const SizedBox(height: 10.0), Text( widget.notification.data!["module"], textAlign: TextAlign.left, - style: TextStyle( + style: const TextStyle( fontSize: 20.0, color: Colors.deepOrangeAccent, fontWeight: FontWeight.bold, ), ), - SizedBox( - height: 10.0, - ), + const SizedBox(height: 10.0), Padding( padding: const EdgeInsets.all(8.0), child: Text( widget.notification.verb!, - style: TextStyle(fontSize: 15.0, color: Colors.black), + style: const TextStyle(fontSize: 15.0, color: Colors.black), ), ), - SizedBox( - height: 10.0, - ), + const SizedBox(height: 10.0), ElevatedButton( - child: widget.notification.unread! - ? Text('Mark As Read') - : Text('Mark As Unread'), + child: Text(widget.notification.unread! ? 'Mark As Read' : 'Mark As Unread'), onPressed: () { // Respond to button press DashboardService service = DashboardService(); setState(() { try { service.markRead(widget.notification.id!.toString()); - }catch(e){ + } catch (e) { print(e); } }); @@ -124,10 +116,8 @@ class _InfoCardState extends State { style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.pressed)) - return Colors.deepOrange; - return Colors - .deepOrangeAccent; // Use the component's default. + if (states.contains(MaterialState.pressed)) return Colors.deepOrange; + return Colors.deepOrangeAccent; // Default Color }, ), ), diff --git a/lib/screens/LoginandDashboard/DashboardComponents/news.dart b/lib/screens/LoginandDashboard/DashboardComponents/news.dart new file mode 100644 index 00000000..268ae36a --- /dev/null +++ b/lib/screens/LoginandDashboard/DashboardComponents/news.dart @@ -0,0 +1,201 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar2.dart'; +import 'package:fusion/Components/side_drawer2.dart'; +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 'package:fusion/Components/bottom_navigation_bar.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; + +class News extends StatefulWidget { + static String tag = 'home-page'; + @override + _NewsState createState() => _NewsState(); +} + +class _NewsState extends State { + bool _notificationsBool = false; + bool _newsBool = true; + bool _announcementsBool = false; + bool _homeBool = false; + + bool _loading = true; + late String name; + late String studentType; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + var service = locator(); + late String curr_desig = service.getFromDisk("Current_designation"); + + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + print("gfsgsgd"); + Response response = await dashboardService.getDashboard(); + print("1"); + Response response2 = await profileService.getProfile(); + print("2"); + print(response); + print(response2); + + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + final GlobalKey scaffoldKey = new GlobalKey(); + showSnack() { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text('New Content Loaded'), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: CustomAppBar( + curr_desig: curr_desig, + headerTitle: "News", + + onDesignationChanged: (newValue) { + setState(() { + curr_desig = newValue; + }); + }, + ), + drawer: SideDrawer(curr_desig: curr_desig), + bottomNavigationBar: MyBottomNavigationBar(), + body: _loading == true + ? Center(child: CircularProgressIndicator()) + : StreamBuilder( + stream: _dashboardController.stream, + builder: (context, AsyncSnapshot snapshot) { + return Stack(children: [ + Positioned( + left: 0, + child: Column( + children: [ + Card( + elevation: 0, + margin: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 10.0), + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 13.0, + right: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + setState(() { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + }); + Navigator.pushReplacementNamed( + context, "/notification"); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + // Only handle navigation when the icon is clicked + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + setState(() { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + }); + Navigator.pushReplacementNamed( + context, "/landing"); + }, + child: Icon( + Icons.navigate_before_rounded, + color: Colors.black, + size: 25.0, + ), + ), + SizedBox(width: 20.0), + Text( + 'News', + style: TextStyle( + fontSize: 22.0, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(width: 170.0), + ], + ), + ), + ], + ), + ), + ), + + + ], + ), + ), + ]); + }, + ), + ); + } + + @override + void dispose() { + _dashboardController.close(); + super.dispose(); + } +} \ No newline at end of file diff --git a/lib/screens/LoginandDashboard/DashboardComponents/notify.dart b/lib/screens/LoginandDashboard/DashboardComponents/notify.dart new file mode 100644 index 00000000..198820b5 --- /dev/null +++ b/lib/screens/LoginandDashboard/DashboardComponents/notify.dart @@ -0,0 +1,152 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar2.dart'; +import 'package:fusion/Components/side_drawer2.dart'; +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 'package:fusion/Components/bottom_navigation_bar.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:fusion/models/notification.dart' as notif; +import 'package:intl/intl.dart'; + +class Notify extends StatefulWidget { + static String tag = 'home-page'; + @override + _NotifyState createState() => _NotifyState(); +} + +class _NotifyState extends State { + List _notifications = []; + bool _loading = true; + late String name; + late String studentType; + + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + var service = locator(); + late String curr_desig = service.getFromDisk("Current_designation"); + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + print("gfsgsgd"); + Response response = await dashboardService.getNotification(); + print("1"); + Response response2 = await profileService.getProfile(); + print("2"); + print(response); + print(response2); + + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + _notifications = notif.Notification.fromListJson(jsonDecode(response.body)['notifications']); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + final GlobalKey scaffoldKey = new GlobalKey(); + showSnack() { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text('New Content Loaded'), + ), + ); + } + + @override +Widget build(BuildContext context) { + return Scaffold( + appBar: CustomAppBar( + curr_desig: curr_desig, + headerTitle: "Notifications", + + onDesignationChanged: (newValue) { + setState(() { + curr_desig = newValue; + }); + }, + ), // This is default app bar used in all modules + drawer: SideDrawer(curr_desig: curr_desig), + bottomNavigationBar: + MyBottomNavigationBar(), // This is sideDrawer used in all modules + body: _loading + ? Center(child: CircularProgressIndicator()) + : ListView.builder( + itemCount: _notifications.length, + padding: EdgeInsets.all(8.0), // Add padding around the list for better spacing + itemBuilder: (context, index) { + final notification = _notifications[index]; + final formattedDate = notification.timestamp != null + ? DateFormat('yyyy-MM-dd – kk:mm').format(notification.timestamp!) + : "No Date"; + + return Card( + elevation: 4.0, // Adjust the shadow's elevation + margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 0), // Spacing between cards + child: ListTile( + leading: Icon(notification.unread ?? false ? Icons.notifications_active : Icons.notifications_off), + title: Text(notification.verb ?? "No Title"), + subtitle: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + notification.description ?? "No Description", + overflow: TextOverflow.ellipsis, + ), + ), + Text(formattedDate, textAlign: TextAlign.right), + ], + ), + onTap: () { + // Handle tap + }, + ), + ); + }, + ), + + + ); + } + + @override + void dispose() { + _dashboardController.close(); + super.dispose(); + } +} \ No newline at end of file diff --git a/lib/screens/LoginandDashboard/dashboard.dart b/lib/screens/LoginandDashboard/dashboard.dart index 80c2719f..24f372d5 100644 --- a/lib/screens/LoginandDashboard/dashboard.dart +++ b/lib/screens/LoginandDashboard/dashboard.dart @@ -2,15 +2,17 @@ import 'dart:async'; import 'dart:convert'; import 'package:fusion/models/profile.dart'; import 'package:fusion/services/profile_service.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:fusion/Components/appBar.dart'; -import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/Components/appBar2.dart'; +import 'package:fusion/Components/side_drawer2.dart'; 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 'package:fusion/services/appBar_services.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:fusion/Components/bottom_navigation_bar.dart'; class Dashboard extends StatefulWidget { static String tag = 'home-page'; @@ -20,9 +22,11 @@ class Dashboard extends StatefulWidget { } class _DashboardState extends State { - bool _notificationsBool = true; + bool _notificationsBool = false; bool _newsBool = false; bool _announcementsBool = false; + bool _homeBool = true; + bool _loading = true; late String name; late String studentType; @@ -33,6 +37,12 @@ class _DashboardState extends State { late StreamController _profileController; late ProfileService profileService; late ProfileData data2; + late List designationsArray; + var service = locator(); + late String curr_desig = service.getFromDisk("Current_designation"); + bool isStudent = false; + + final appBarServices _appBarServices = appBarServices(); @override void initState() { super.initState(); @@ -45,17 +55,28 @@ class _DashboardState extends State { getData() async { try { + print("gfsgsgd"); Response response = await dashboardService.getDashboard(); + print("1"); Response response2 = await profileService.getProfile(); + print("2"); + print(response); + print(response2); + setState(() { data = DashboardData.fromJson(jsonDecode(response.body)); data2 = ProfileData.fromJson(jsonDecode(response2.body)); _loading = false; }); + print(data2.user!); + print( + '-----------------------------------=---------------------------------------'); name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; - studentType = data2.profile!['department']!['name'] + - ' ' + - data2.profile!['user_type']; + studentType = data2.profile!['department']!['name']; + + if (data2.profile!['user_type'] == 'student') { + isStudent = true; + } } catch (e) { print(e); } @@ -68,6 +89,15 @@ class _DashboardState extends State { }); } + fetchDesignations() async { + try { + designationsArray = await _appBarServices.getDesignations(); + } catch (e) { + print("Error fetching designations: $e"); + return null; + } + } + final GlobalKey scaffoldKey = new GlobalKey(); showSnack() { ScaffoldMessenger.of(context).showSnackBar( @@ -80,174 +110,221 @@ class _DashboardState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: DefaultAppBar() - .buildAppBar(), // This is default app bar used in all modules - drawer: SideDrawer(), // This is sideDrawer used in all modules - body: _loading == true - ? Center(child: CircularProgressIndicator()) - : StreamBuilder( - stream: _dashboardController.stream, - builder: (context, AsyncSnapshot snapshot) { - return ListView( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - children: [ - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric( - horizontal: 50.0, vertical: 20.0), - shadowColor: Colors.black, - child: Column( + appBar: CustomAppBar( + curr_desig: curr_desig, + headerTitle: "Dashboard", + onDesignationChanged: (newValue) { + setState(() { + curr_desig = newValue; + }); + }, + ), // This is default app bar used in all modules + drawer: SideDrawer(curr_desig: curr_desig), + bottomNavigationBar: + MyBottomNavigationBar(), // This is sideDrawer used in all modules + body: Column( + children: [ + Expanded( + child: _loading == true + ? Center(child: CircularProgressIndicator()) + : StreamBuilder( + stream: _dashboardController.stream, + builder: (context, AsyncSnapshot snapshot) { + return ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), children: [ - Container( - margin: EdgeInsets.only(top: 20.0), - width: 170.0, - height: 170.0, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/profile_pic.png'), - fit: BoxFit.cover, - ), - ), - ), - SizedBox( - height: 10.0, - ), - Text( - name, //Display name of User - style: - TextStyle(fontSize: 20.0, color: Colors.black), - ), - SizedBox( - height: 10.0, - ), - Text( - studentType, // Display Type of User - style: - TextStyle(fontSize: 15.0, color: Colors.black), - ), - SizedBox( - height: 10.0, - ), - ], - ), - ), - Card( - color: Colors.black, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - GestureDetector( - onTap: () { - _notificationsBool = true; - _announcementsBool = false; - _newsBool = false; - setState(() { - _notificationsBool = true; - _announcementsBool = false; - _newsBool = false; - }); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Notifications', - style: TextStyle( - fontSize: 16.0, - color: Colors.white, + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 30.0), + // shadowColor: Colors.black, + color: Colors.white, + + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 190.0, + decoration: BoxDecoration( + image: DecorationImage( + image: + AssetImage('assets/profile_pic.png'), + fit: BoxFit.cover, ), ), - Icon( - Icons.notifications_active_rounded, - color: _notificationsBool - ? Colors.deepOrangeAccent - : Colors.white, - ), - ], - ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, //Display name of User + style: TextStyle( + fontSize: 20.0, + color: Colors.black, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 10.0, + ), + Text( + studentType + + " " + + curr_desig, // Display Type of User + style: TextStyle( + fontSize: 17.0, + color: Colors.black, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 10.0, + ), + ], ), - GestureDetector( - onTap: () { - _newsBool = true; - _announcementsBool = false; - _notificationsBool = false; - setState(() { - _newsBool = true; - _announcementsBool = false; - _notificationsBool = false; - }); - }, + ), + + Card( + margin: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 10.0), + color: Colors.deepOrangeAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 50.0), // Set the border radius here + ), + child: Padding( + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 13.0, + right: 10.0), child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment + .spaceEvenly, // Align the children along the main axis with space between them + crossAxisAlignment: CrossAxisAlignment + .center, // Align the children along the cross axis (vertically by default) + // mainAxisSize: MainAxisSize.max, children: [ - Text( - 'News', - style: TextStyle( - fontSize: 16.0, - color: Colors.white, + GestureDetector( + onTap: () { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + setState(() { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + }); + Navigator.pushReplacementNamed( + context, "/profile"); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Icon( + Icons.account_circle, + color: Colors.white, + size: 30.0, + ), + SizedBox(width: 40.0), + Text( + 'Professsional Profile', + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(width: 40.0), + Icon( + Icons.arrow_forward_ios_rounded, + color: Colors.white, + ), + ], ), ), - Icon( - Icons.email, - color: _newsBool - ? Colors.deepOrangeAccent - : Colors.white, - ), ], ), ), - GestureDetector( - onTap: () { - _announcementsBool = true; - _newsBool = false; - _notificationsBool = false; - setState(() { - _announcementsBool = true; - _newsBool = false; - _notificationsBool = false; - }); - }, + ), + + if (!isStudent) + Card( + margin: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 10.0), + color: Colors.deepOrangeAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 50.0), // Set the border radius here + ), child: Padding( - padding: const EdgeInsets.only(right: 16.0), + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 13.0, + right: 10.0), child: Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceEvenly, children: [ - Text( - 'Announcements', - style: TextStyle( - fontSize: 16.0, - color: Colors.white, + GestureDetector( + onTap: () { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + setState(() { + _notificationsBool = true; + _announcementsBool = false; + _newsBool = false; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .spaceEvenly, // Align the children along the main axis with space between them + crossAxisAlignment: CrossAxisAlignment + .center, // Align the children along the cross axis (vertically by default) + mainAxisSize: MainAxisSize.max, + children: [ + Icon( + Icons.notifications_active_rounded, + color: Colors.white, + ), + SizedBox(width: 40.0), + Text( + 'Admistrative Profile', + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(width: 40.0), + Icon( + Icons.arrow_forward_ios_rounded, + color: Colors.white, + ), + ], ), ), - Icon( - Icons.announcement, - color: _announcementsBool - ? Colors.deepOrangeAccent - : Colors.white, - ), ], ), ), ), - ], - ), - ), - ), - _notificationsBool - ? NotificationCard( - notifications: data.notifications, - ) - : NewsCard(), - ], - ); - }, - ), + + // _notificationsBool + // ? NotificationCard( + // notifications: data.notifications, + // ) + // : NewsCard(), + ], + ); + }, + ), + ), + // Place the BottomNavigationBar here + ], + ), ); } @@ -256,4 +333,4 @@ class _DashboardState extends State { _dashboardController.close(); super.dispose(); } -} +} \ No newline at end of file diff --git a/lib/screens/LoginandDashboard/login_page.dart b/lib/screens/LoginandDashboard/login_page.dart index ca09fee2..aff38280 100644 --- a/lib/screens/LoginandDashboard/login_page.dart +++ b/lib/screens/LoginandDashboard/login_page.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fusion/constants.dart'; @@ -10,7 +9,9 @@ class LoginPage extends StatefulWidget { _LoginPageState createState() => _LoginPageState(); } -bool checkBoxValue = false; +bool _focused = false; +bool _focused2 = false; +double bottom =10; class _LoginPageState extends State { final GlobalKey _formKey = GlobalKey(); @@ -23,21 +24,45 @@ class _LoginPageState extends State { final Widget logoWidget = CircleAvatar( backgroundColor: Colors.transparent, - radius: 54.0, - child: Image.asset('assets/logo.jpg'), + radius: (_focused || _focused2) ? 110.0 : 150.0, + child:Container( + + child: Image.asset('assets/logo.jpg'), + ), ); - final Widget emailFormField = TextFormField( + final Widget emailFormField = Focus( + onFocusChange: (focus) { + setState(() { + _focused = focus; + if (focus==true){ + bottom=400; + } + + }); + }, + child:TextFormField( keyboardType: TextInputType.emailAddress, autofocus: false, decoration: InputDecoration( label: Text('Username', style: TextStyle( - fontSize: 12.0, + fontSize: 18.0, ),), contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), - border: OutlineInputBorder( - // borderRadius: BorderRadius.circular(32.0), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 0, color: Color(0xFFf4f4f4)), + borderRadius: BorderRadius.circular(20.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(width: 0, color: Color(0xFFf4f4f4)), + borderRadius: BorderRadius.circular(20.0), ), + // enabledBorder: InputBorder.none, + fillColor: Color(0xFFf4f4f4), // Green color + filled: true, + floatingLabelBehavior: FloatingLabelBehavior.never, ), + cursorColor: Colors.black, + onChanged: (input) { username = input; }, @@ -48,23 +73,45 @@ class _LoginPageState extends State { else if (value?.contains('@') == true) { return 'Please enter username only'; } + return null; }, autofillHints: [AutofillHints.username], - ); + )); + + final Widget passwordFormField = Focus( + onFocusChange: (focus) { + setState(() { + _focused2 = focus; + if (focus==true){ + bottom=400; + } - final Widget passwordFormField = TextFormField( + }); + }, + child: TextFormField( autofocus: false, obscureText: true, decoration: InputDecoration( label: Text('Password', style: TextStyle( - fontSize: 12.0, + fontSize: 18.0, ),), contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), - border: OutlineInputBorder( - // borderRadius: BorderRadius.circular(32.0), + + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 0, color: Color(0xFFf4f4f4)), + borderRadius: BorderRadius.circular(20.0), ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(width: 0, color: Color(0xFFf4f4f4)), + borderRadius: BorderRadius.circular(20.0), + ), + // enabledBorder: InputBorder.none, + fillColor: Color(0xFFf4f4f4), // Green color + filled: true, + floatingLabelBehavior: FloatingLabelBehavior.never, ), + cursorColor: Colors.black, onChanged: (input) { pass = input; }, @@ -74,12 +121,13 @@ class _LoginPageState extends State { } else if (value.length < 6) { return 'Password must be at least 6 characters'; } + return null; }, autofillHints: [AutofillHints.password], - ); + )); final loginButton = Padding( - padding: EdgeInsets.symmetric(vertical: 16.0), + padding: EdgeInsets.only(top: 16.0), child: ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(kPrimaryColor), @@ -102,7 +150,8 @@ class _LoginPageState extends State { style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, - fontSize: 14.0, + fontSize: 22.0, + ), ), ), @@ -124,13 +173,16 @@ class _LoginPageState extends State { key: _formKey, child: ListView( shrinkWrap: true, - padding: EdgeInsets.only(left: 24.0, right: 24.0), + padding: EdgeInsets.only(top:8.0,left: 24.0, right: 24.0), children: [ - logoWidget, + Padding( + padding: const EdgeInsets.only(top: 0.0), // Change the top padding here + child: logoWidget, + ), Padding( padding: const EdgeInsets.only(bottom: 30.0), child: Text( - 'Fusion Login', + 'Fusion', style: TextStyle( color: kPrimaryColor, fontWeight: FontWeight.bold, @@ -141,14 +193,21 @@ class _LoginPageState extends State { ), Padding( padding: EdgeInsets.only(bottom: 15), - child: emailFormField, + child: emailFormField, ), Padding( padding: EdgeInsets.only(bottom: 15), child: passwordFormField, ), - loginButton, - forgotLabel, + Padding( + padding: EdgeInsets.only(bottom: 0.0), + child: loginButton, + ), + Padding( + padding: EdgeInsets.only(top:0.0,bottom: bottom), + child: forgotLabel, + ), + ], ), ), @@ -157,29 +216,29 @@ class _LoginPageState extends State { ); } - // void _showDialog() { - // // flutter defined function - // showDialog( - // context: context, - // builder: (BuildContext context) { - // // return object of type Dialog - // return AlertDialog( - // title: Text("Invalid Username/Password"), - // content: Text("Please enter correct Username or Password"), - // actions: [ - // // usually buttons at the bottom of the dialog - // new TextButton( - // child: new Text( - // "Close", - // style: TextStyle(color: Colors.deepOrangeAccent), - // ), - // onPressed: () { - // Navigator.of(context).pop(); - // }, - // ), - // ], - // ); - // }, - // ); - // } -} +// void _showDialog() { +// // flutter defined function +// showDialog( +// context: context, +// builder: (BuildContext context) { +// // return object of type Dialog +// return AlertDialog( +// title: Text("Invalid Username/Password"), +// content: Text("Please enter correct Username or Password"), +// actions: [ +// // usually buttons at the bottom of the dialog +// new TextButton( +// child: new Text( +// "Close", +// style: TextStyle(color: Colors.deepOrangeAccent), +// ), +// onPressed: () { +// Navigator.of(context).pop(); +// }, +// ), +// ], +// ); +// }, +// ); +// } +} \ No newline at end of file diff --git a/lib/services/appBar_services.dart b/lib/services/appBar_services.dart new file mode 100644 index 00000000..bc7ba3c0 --- /dev/null +++ b/lib/services/appBar_services.dart @@ -0,0 +1,14 @@ +import 'package:fusion/services/storage_service.dart'; + +class appBarServices { + getDesignations() async { + try { + var storageService = await StorageService.getInstance(); + List? designations = storageService!.getFromDisk('designations'); + + return designations; + } catch (e) { + rethrow; + } + } +} \ No newline at end of file diff --git a/lib/services/dashboard_service.dart b/lib/services/dashboard_service.dart index 8e4520a9..ef348125 100644 --- a/lib/services/dashboard_service.dart +++ b/lib/services/dashboard_service.dart @@ -7,12 +7,12 @@ import 'package:http/http.dart' as http; class DashboardService { getDashboard() async { try { - var storage_service = locator(); - if (storage_service.userInDB?.token == null) + var storageService = locator(); + if (storageService.userInDB?.token == null) throw Exception('Token Error'); Map headers = { - 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + 'Authorization': 'Token ' + (storageService.userInDB?.token ?? "") }; var client = http.Client(); http.Response response = await client.get( @@ -24,6 +24,43 @@ class DashboardService { ); if (response.statusCode == 200) { print("success"); + print(response); + return response; + } + throw Exception('Can\'t load'); + } catch (e) { + rethrow; + } + } + + + getNotification() async { + try { + print("gett"); + var storageService = locator(); + if (storageService.userInDB?.token == null) + throw Exception('Token Error'); + + + Map headers = { + 'Authorization': 'Token ' + (storageService.userInDB?.token ?? "") + }; + print("gett2"); + + var client = http.Client(); + http.Response response = await client.get( + Uri.http( + getLink(), + kNotification, // constant dashboard path + ), + headers: headers, + ); + + print("gett3"); + + if (response.statusCode == 200) { + print("success"); + print(response); return response; } throw Exception('Can\'t load'); @@ -34,12 +71,12 @@ class DashboardService { markRead(String id) async { try { - StorageService? storage_service = await StorageService.getInstance(); + StorageService? storageService = await StorageService.getInstance(); - if (storage_service?.userInDB?.token == null) + if (storageService?.userInDB?.token == null) throw Exception('Token Error'); - String token = storage_service?.userInDB?.token ?? ""; + String token = storageService?.userInDB?.token ?? ""; Map headers = {'Authorization': 'Token ' + token}; Map body = {"id": id}; var client = http.Client(); @@ -60,4 +97,4 @@ class DashboardService { rethrow; } } -} +} \ No newline at end of file diff --git a/lib/services/login_service.dart b/lib/services/login_service.dart index 17d79b42..97277ffc 100644 --- a/lib/services/login_service.dart +++ b/lib/services/login_service.dart @@ -1,6 +1,5 @@ import 'dart:convert'; -import 'package:fusion/constants.dart'; import 'package:fusion/api.dart'; import 'package:fusion/models/user.dart'; import 'package:fusion/services/storage_service.dart'; @@ -25,8 +24,15 @@ class LoginService { var prefs = await StorageService.getInstance(); print("response.body: ${response.body}"); - var storage_service = await StorageService.getInstance(); - storage_service!.saveUserInDB(User((jsonDecode(response.body))["token"])); + var storageService = await StorageService.getInstance(); + storageService!.saveUserInDB(User((jsonDecode(response.body))["token"])); + storageService.saveToDisk>( + 'designations', + (jsonDecode(response.body)["designations"] as List) + .map((dynamic item) => item.toString()) + .toList(), + ); + storageService.saveStringToDisk("Current_designation",jsonDecode(response.body)["designations"][0]); return true; } catch (e) { rethrow; @@ -35,8 +41,8 @@ class LoginService { void logout() async { try { - var storage_service = await StorageService.getInstance(); - storage_service!.deleteKey("user"); + var storageService = await StorageService.getInstance(); + storageService!.deleteKey("user"); } catch (e) { rethrow; } diff --git a/lib/services/storage_service.dart b/lib/services/storage_service.dart index 94d39ea4..9d118326 100644 --- a/lib/services/storage_service.dart +++ b/lib/services/storage_service.dart @@ -13,19 +13,19 @@ class StorageService with ChangeNotifier { static const String ProfileKey = "ProfileKey"; User? get userInDB { - var userJson = _getFromDisk(UserKey); + var userJson = getFromDisk(UserKey); return userJson == null ? null : User.fromJson(jsonDecode(userJson)); } ProfileData get profileData { - var profileJson = _getFromDisk(ProfileKey); + var profileJson = getFromDisk(ProfileKey); // print(jsonDecode(profileJson)); return ProfileData.fromJson(jsonDecode(profileJson)); } AcademicData get academicData { - var profileJson = _getFromDisk(ProfileKey); + var profileJson = getFromDisk(ProfileKey); // print(jsonDecode(profileJson)); return AcademicData.fromJson(jsonDecode(profileJson)); } @@ -49,9 +49,9 @@ class StorageService with ChangeNotifier { return _instance; } - dynamic _getFromDisk(String key) { + dynamic getFromDisk(String key) { var value = _sharedPreferences?.get(key); - // print('(TRACE) LocalStorageService:_getFromDisk. key: $key value: $value'); + // print('(TRACE) LocalStorageService:getFromDisk. key: $key value: $value'); return value; } @@ -62,7 +62,7 @@ class StorageService with ChangeNotifier { void deleteKey(String key) { print( - '(TRACE) StorageService: deleteKey. key: $key value: ${_getFromDisk(key)}'); + '(TRACE) StorageService: deleteKey. key: $key value: ${getFromDisk(key)}'); _sharedPreferences!.remove(key); } @@ -84,4 +84,4 @@ class StorageService with ChangeNotifier { _sharedPreferences!.setStringList(key, content); } } -} +} \ No newline at end of file From a02edca530c1367d39bf6fa5136966351d56033e Mon Sep 17 00:00:00 2001 From: Risgabh Nigam Date: Mon, 22 Apr 2024 23:52:38 +0530 Subject: [PATCH 4/5] Initial Commit --- lib/Components/side_drawer.dart | 37 +- lib/api.dart | 4 + lib/main.dart | 7 + lib/screens/IWD/Create_Request.dart | 128 +++++++ lib/screens/IWD/Created_Requests.dart | 116 +++++++ lib/screens/IWD/Dean_Homepage.dart | 113 ++++++ lib/screens/IWD/Dean_budget.dart | 127 +++++++ lib/screens/IWD/Director_Budget.dart | 148 ++++++++ .../IWD/Director_Deanproceessedrequest.dart | 159 +++++++++ lib/screens/IWD/Director_homepage.dart | 112 ++++++ lib/screens/IWD/Director_requeststatus.dart | 328 ++++++++++++++++++ lib/screens/IWD/Engineer_Process_Request.dart | 179 ++++++++++ lib/screens/IWD/Er_Homepage.dart | 314 +++++++++++++++++ lib/screens/IWD/Generated_Bill_Req.dart | 238 +++++++++++++ lib/screens/IWD/Issue_Work_Order.dart | 238 +++++++++++++ lib/screens/IWD/Rejected_Requests.dart | 254 ++++++++++++++ lib/screens/IWD/Request_In_Progress.dart | 254 ++++++++++++++ lib/screens/IWD/Request_Status.dart | 280 +++++++++++++++ lib/screens/IWD/Request_status_dean.dart | 171 +++++++++ lib/screens/IWD/engineer1.dart | 229 ++++++++++++ lib/services/iwd_services.dart | 193 +++++++++++ 21 files changed, 3623 insertions(+), 6 deletions(-) create mode 100644 lib/screens/IWD/Create_Request.dart create mode 100644 lib/screens/IWD/Created_Requests.dart create mode 100644 lib/screens/IWD/Dean_Homepage.dart create mode 100644 lib/screens/IWD/Dean_budget.dart create mode 100644 lib/screens/IWD/Director_Budget.dart create mode 100644 lib/screens/IWD/Director_Deanproceessedrequest.dart create mode 100644 lib/screens/IWD/Director_homepage.dart create mode 100644 lib/screens/IWD/Director_requeststatus.dart create mode 100644 lib/screens/IWD/Engineer_Process_Request.dart create mode 100644 lib/screens/IWD/Er_Homepage.dart create mode 100644 lib/screens/IWD/Generated_Bill_Req.dart create mode 100644 lib/screens/IWD/Issue_Work_Order.dart create mode 100644 lib/screens/IWD/Rejected_Requests.dart create mode 100644 lib/screens/IWD/Request_In_Progress.dart create mode 100644 lib/screens/IWD/Request_Status.dart create mode 100644 lib/screens/IWD/Request_status_dean.dart create mode 100644 lib/screens/IWD/engineer1.dart create mode 100644 lib/services/iwd_services.dart diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..68859691 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -25,6 +25,20 @@ class _SideDrawerState extends State { service.profileData.profile!['user_type']; } + String determinePageRoute(String? name) { + switch (name) { + case 'Ajay Singh': + return '/IWD_Homepage'; + case 'IIITDMJ Director': + return '/IWD_Director'; + case 'Dean (P&D)': + return '/IWD_Dean'; + // // Add more cases for other names and corresponding routes + default: + return '/IWD_Homepage'; // Default route if name does not match specific cases + } + } + @override Widget build(BuildContext context) { return SafeArea( @@ -122,14 +136,20 @@ 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'), @@ -142,6 +162,11 @@ class _SideDrawerState extends State { ModulesPadding(line: 'Leave Module'), ModulesPadding(line: 'Placement Module'), ModulesPadding(line: 'Visitors Hostel Module'), + ModulesPadding( + line: 'IWD', + pageMover: determinePageRoute(name), + isActive: true, + ), ModulesPadding(line: 'File Tracking Module'), ], ), diff --git a/lib/api.dart b/lib/api.dart index 1f76a52b..22627ae2 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -31,6 +31,10 @@ const kGymkhanaMemberRecords = '/api/gymkhana/members_record'; //HealthCentre String kHealthCentreStudent = "/healthcenter/api/student"; +//IWD +String kIwd = 'foal-cheerful-optionally.ngrok-free.app'; +String kCreatedReq = '/iwdModuleV2/api/createdRequestsView/'; + //------------Screens------------ //screens/Academic/Current_Semester diff --git a/lib/main.dart b/lib/main.dart index 4cd5af87..0eb5e28e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; import 'dart:async'; +import 'package:fusion/screens/IWD/Dean_Homepage.dart'; +import 'package:fusion/screens/IWD/Director_homepage.dart'; +import 'package:fusion/screens/IWD/Er_Homepage.dart'; import 'package:fusion/screens/Academic/Add_Drop_Courses/add_drop_courses.dart'; import 'package:fusion/screens/Complaint/ComplaintHistory/complain_history.dart'; import 'package:fusion/screens/Complaint/Feedback/feedback.dart'; @@ -82,6 +85,10 @@ class MyApp extends StatelessWidget { ), initialRoute: '/landing', routes: { + '/iwd': (context) => MyHomePage(), + '/IWD_Homepage': (context) => MyHomePage(), + '/IWD_Director': (context) => Dir_Homepage(), + '/IWD_Dean':(context)=> Dean_Homepage(), '/landing': (context) => LandingPage(), '/login_page': (context) => LoginPage(), '/notification':(context)=>Notify(), diff --git a/lib/screens/IWD/Create_Request.dart b/lib/screens/IWD/Create_Request.dart new file mode 100644 index 00000000..900ae03d --- /dev/null +++ b/lib/screens/IWD/Create_Request.dart @@ -0,0 +1,128 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +void main() { + runApp(RequestsUI()); +} + +class RequestsUI extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + title: 'Requests:', + theme: ThemeData( + primarySwatch: Colors.deepOrange, + ), + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: RequestForm(), + ), + ); + } +} + +class RequestForm extends StatefulWidget { + @override + _RequestFormState createState() => _RequestFormState(); +} + +class _RequestFormState extends State { + String _selectedRecipient = 'Director'; + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // Title moved from app bar to the body + Text( + 'Requests', + style: TextStyle( + fontSize: 20.0, // Increase font size for title + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + ), + SizedBox(height: 20.0), + Text( + 'Name:', + style: TextStyle(fontSize: 18.0), + ), + TextField( + decoration: InputDecoration( + hintText: 'Enter your name', + ), + ), + SizedBox(height: 20.0), + Text( + 'Description:', + style: TextStyle(fontSize: 18.0), + ), + TextField( + decoration: InputDecoration( + hintText: 'Enter description', + ), + ), + SizedBox(height: 20.0), + Text( + 'Area:', + style: TextStyle(fontSize: 18.0), + ), + TextField( + decoration: InputDecoration( + hintText: 'Enter area', + ), + ), + SizedBox(height: 20.0), + Text( + 'Send to:', + style: TextStyle(fontSize: 18.0), + ), + DropdownButton( + value: _selectedRecipient, + onChanged: (String? newValue) { + setState(() { + _selectedRecipient = newValue!; + }); + }, + items: [ + 'Director', + 'Dean', + 'Junior Engineer', + 'Executive Engineer', + 'Electrical AE', + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + SizedBox(height: 20.0), + Align( + alignment: Alignment.bottomRight, + child: SizedBox( + width: 100.0, + child: ElevatedButton( + onPressed: () { + // Add functionality for submit button + }, + style: ElevatedButton.styleFrom( + padding: EdgeInsets.all(12.0), + ), + child: Text('Submit', style: TextStyle(fontSize: 14.0)), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/IWD/Created_Requests.dart b/lib/screens/IWD/Created_Requests.dart new file mode 100644 index 00000000..1ba494f7 --- /dev/null +++ b/lib/screens/IWD/Created_Requests.dart @@ -0,0 +1,116 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/services/iwd_services.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; + +class CreatedRequestsWidget extends StatefulWidget { + @override + _CreatedRequestsWidgetState createState() => _CreatedRequestsWidgetState(); +} + +class _CreatedRequestsWidgetState extends State { + IwdServices iwdServices = IwdServices(); + List> _map_obj = []; + + @override + void initState() { + super.initState(); + _getCreatedRequests(); + } + + void _getCreatedRequests() async { + http.Response response = await iwdServices.getCreated(); + var data = json.decode(response.body)['obj']; + + List> mappedObjects = []; + + data.forEach((item) { + String id = item[0].toString(); + String name = item[1]; + String area = item[2]; + String description = item[3]; + String createdBy = item[4]; + + Map mappedObject = { + 'id': id, + 'Name': name, + 'Area': area, + 'Description': description, + 'Created By': createdBy, + }; + + mappedObjects.add(mappedObject); + }); + + setState(() { + _map_obj = mappedObjects; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: _buildWidget(), + ), + ), + ), + ); + } + + Widget _buildWidget() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Created Requests', + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.orange[50], + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.deepOrange), + ), + child: DataTable( + columns: [ + DataColumn(label: Text('ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Area')), + DataColumn(label: Text('Created By')), + ], + rows: _map_obj.map((data) { + return DataRow(cells: [ + DataCell(Text(data['id'].toString())), + DataCell(Text(data['Name'] ?? '')), + DataCell(Text(data['Description'] ?? '')), + DataCell(Text(data['Area'] ?? '')), + DataCell(Text(data['Created By'] ?? '')), + ]); + }).toList(), + ), + ), + ], + ); + } +} diff --git a/lib/screens/IWD/Dean_Homepage.dart b/lib/screens/IWD/Dean_Homepage.dart new file mode 100644 index 00000000..a2b1b869 --- /dev/null +++ b/lib/screens/IWD/Dean_Homepage.dart @@ -0,0 +1,113 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/IWD/Dean_budget.dart'; +import 'package:fusion/screens/IWD/Request_status_dean.dart'; +import 'package:fusion/screens/IWD/Engineer_Process_Request.dart'; + +class Dean_Homepage extends StatelessWidget { + const Dean_Homepage({Key? key}) : super(key: key); + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('IWD Department'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Container( + padding: const EdgeInsets.all(20.0), + child: Container( + child: GridView( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 1.0, + mainAxisSpacing: 5.0, + crossAxisSpacing: 5.0, + ), + children: [ + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => BudgetPage()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'View Budget', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Er_Process_Request()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Engineer Process', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Request', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Requests_Dean()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Requests', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Status', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + ]), + ), + ), + ); + } +} diff --git a/lib/screens/IWD/Dean_budget.dart b/lib/screens/IWD/Dean_budget.dart new file mode 100644 index 00000000..7c83ae5e --- /dev/null +++ b/lib/screens/IWD/Dean_budget.dart @@ -0,0 +1,127 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'dart:convert'; +import 'dart:math'; + +class Dean_budget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp(debugShowCheckedModeBanner: false, home: BudgetPage()); + } +} + +class BudgetPage extends StatefulWidget { + @override + _BudgetPageState createState() => _BudgetPageState(); +} + +class _BudgetPageState extends State { + List> _budgetData = []; + + @override + void initState() { + super.initState(); + fetchData(); // Fetch data when the page is initialized + } + + Future fetchData() async { + // Simulate a network request delay of 2 seconds + await Future.delayed(Duration(seconds: 2)); + + // Simulated response data + List> responseData = [ + {'id': 1, 'name': 'John Doe', 'budget_issued': 1000}, + {'id': 2, 'name': 'Jane Smith', 'budget_issued': 2000}, + {'id': 3, 'name': 'Alice Johnson', 'budget_issued': 1500}, + {'id': 4, 'name': 'Bob Brown', 'budget_issued': 1800}, + {'id': 5, 'name': 'Eva Lee', 'budget_issued': 2200}, + ]; + + setState(() { + _budgetData = responseData; // Update state with fetched data + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('IWD Department'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Budget', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.orange[50], + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.deepOrange), + ), + child: DataTable( + columns: [ + DataColumn(label: Text('ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Budget Issued')), + ], + rows: _budgetData + .map( + (data) => DataRow( + cells: [ + DataCell(Text(data['id'].toString())), + DataCell(Text(data['name'].toString())), + DataCell(Text(data['budget_issued'].toString())), + ], + ), + ) + .toList(), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(5), + ), + child: TextButton( + onPressed: () { + // Add your back button action here + print('Back button pressed'); + }, + child: Text( + 'BACK', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/IWD/Director_Budget.dart b/lib/screens/IWD/Director_Budget.dart new file mode 100644 index 00000000..1a814c39 --- /dev/null +++ b/lib/screens/IWD/Director_Budget.dart @@ -0,0 +1,148 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class BudgetApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Dashboard'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Budget', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container(), + SizedBox( + height: + 10), // Added spacing between heading and columns + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: + Colors.deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Id', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Budget Issued', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + ], + ), + ), + SizedBox( + height: 10), // Added spacing between columns and data + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('2'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Electrical'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('30000'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + ], + ), + SizedBox( + height: 10), // Added spacing between columns and data + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Civil'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('30000'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + ], + ), + // You can add more rows here for additional data + ], + ), + ), + ], + ), + ), + ), + ); + } +} + +void main() { + runApp(BudgetApp()); +} diff --git a/lib/screens/IWD/Director_Deanproceessedrequest.dart b/lib/screens/IWD/Director_Deanproceessedrequest.dart new file mode 100644 index 00000000..0f1d3a7d --- /dev/null +++ b/lib/screens/IWD/Director_Deanproceessedrequest.dart @@ -0,0 +1,159 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class ProcessRequest extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Dashboard'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Dean Proposed Requests', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: + Colors.deepOrange), // Bottom partition line + ), + ), + child: Text( + 'Details :', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox( + height: + 10), // Added spacing between heading and columns + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: + Colors.deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Id', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Created By', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + ], + ), + ), + SizedBox( + height: 10), // Added spacing between columns and data + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Proposal 1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Description 1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Area 1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('John Doe'), + ], + ), + // You can add more rows here for additional data + ], + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/IWD/Director_homepage.dart b/lib/screens/IWD/Director_homepage.dart new file mode 100644 index 00000000..5800f443 --- /dev/null +++ b/lib/screens/IWD/Director_homepage.dart @@ -0,0 +1,112 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/IWD/Director_Budget.dart'; +import 'package:fusion/screens/IWD/Director_Deanproceessedrequest.dart'; +import 'package:fusion/screens/IWD/Director_requeststatus.dart'; + +class Dir_Homepage extends StatelessWidget { + const Dir_Homepage({Key? key}) : super(key: key); + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('IWD Department'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Container( + padding: const EdgeInsets.all(20.0), + child: Container( + child: GridView( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 1.0, + mainAxisSpacing: 5.0, + crossAxisSpacing: 5.0, + ), + children: [ + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => BudgetApp()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'View Budget', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => ProcessRequest()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Approve/Reject', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Request', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => RequestsApp()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Requests', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Status', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + ]), + ), + ), + ); + } +} diff --git a/lib/screens/IWD/Director_requeststatus.dart b/lib/screens/IWD/Director_requeststatus.dart new file mode 100644 index 00000000..4496c3f2 --- /dev/null +++ b/lib/screens/IWD/Director_requeststatus.dart @@ -0,0 +1,328 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class RequestsApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Dashboard'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Request Status', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: + Colors.deepOrange), // Bottom partition line + ), + ), + child: Text( + 'Details :', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox( + height: + 10), // Added spacing between heading and columns + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: + Colors.deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Id', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Created By', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Status', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + ], + ), + ), + SizedBox( + height: 10), // Added spacing between columns and data + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Proposal 1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Description 1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Area 1'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('John doe'), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Final Bill Settled'), + ], + ), + // You can add more rows here for additional data + ], + ), + ), + ], + ), + ), + ), + ); + } +} + +void main() { + runApp(MaterialApp( + home: Scaffold( + appBar: null, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Request Status', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.deepOrange), // Bottom partition line + ), + ), + child: Text( + 'Details :', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox( + height: 10), // Added spacing between heading and columns + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Id', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Created By', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox(width: 5), // Added spacing between columns + Container( + width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text( + 'Status', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold), // Bold font + ), + ], + ), + ), + SizedBox( + height: 10), // Added spacing between columns and data + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('1'), + SizedBox(width: 5), // Added spacing between columns + Container(width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Proposal 1'), + SizedBox(width: 5), // Added spacing between columns + Container(width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Description 1'), + SizedBox(width: 5), // Added spacing between columns + Container(width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Area 1'), + SizedBox(width: 5), // Added spacing between columns + Container(width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('John doe'), + SizedBox(width: 5), // Added spacing between columns + Container(width: 1, color: Colors.grey), // Vertical line + SizedBox(width: 5), // Added spacing between columns + Text('Final Bill Settled'), + ], + ), + // You can add more rows here for additional data + ], + ), + ), + ], + ), + ), + ), + )); +} diff --git a/lib/screens/IWD/Engineer_Process_Request.dart b/lib/screens/IWD/Engineer_Process_Request.dart new file mode 100644 index 00000000..0e3a3115 --- /dev/null +++ b/lib/screens/IWD/Engineer_Process_Request.dart @@ -0,0 +1,179 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'dart:convert'; +import 'dart:math'; + +class Er_Process_Request extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp(debugShowCheckedModeBanner: false, home: RequestsPage()); + } +} + +void main() { + runApp(MaterialApp( + debugShowCheckedModeBanner: false, + home: RequestsPage(), // Changed the page to RequestsPage + )); +} + +class RequestsPage extends StatefulWidget { + @override + _RequestsPageState createState() => _RequestsPageState(); +} + +class _RequestsPageState extends State { + List> _requestData = []; + + @override + void initState() { + super.initState(); + fetchData(); // Fetch data when the page is initialized + } + + Future fetchData() async { + // Simulate a network request delay of 2 seconds + await Future.delayed(Duration(seconds: 2)); + + // Simulated response data + List> responseData = [ + { + 'id': 1, + 'name': 'Request 1', + 'description': 'Description 1', + 'area': 'Area A', + 'createdBy': 'User 1', + }, + { + 'id': 2, + 'name': 'Request 2', + 'description': 'Description 2', + 'area': 'Area B', + 'createdBy': 'User 2', + }, + { + 'id': 3, + 'name': 'Request 3', + 'description': 'Description 3', + 'area': 'Area C', + 'createdBy': 'User 3', + }, + { + 'id': 4, + 'name': 'Request 4', + 'description': 'Description 4', + 'area': 'Area D', + 'createdBy': 'User 4', + }, + { + 'id': 5, + 'name': 'Request 5', + 'description': 'Description 5', + 'area': 'Area E', + 'createdBy': 'User 5', + }, + ]; + + setState(() { + _requestData = responseData; // Update state with fetched data + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('IWD Department'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Engineer Processed Requests', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Text( + 'Details', + style: TextStyle( + fontSize: 18, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 10), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.orange[50], + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.deepOrange), + ), + child: DataTable( + columns: [ + DataColumn(label: Text('ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Area')), + DataColumn(label: Text('Created By')), + ], + rows: _requestData + .map( + (data) => DataRow( + cells: [ + DataCell(Text(data['id'].toString())), + DataCell(Text(data['name'].toString())), + DataCell(Text(data['description'].toString())), + DataCell(Text(data['area'].toString())), + DataCell(Text(data['createdBy'].toString())), + ], + ), + ) + .toList(), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(5), + ), + child: TextButton( + onPressed: () { + // Add your back button action here + print('Back button pressed'); + }, + child: Text( + 'BACK', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/IWD/Er_Homepage.dart b/lib/screens/IWD/Er_Homepage.dart new file mode 100644 index 00000000..48e402e8 --- /dev/null +++ b/lib/screens/IWD/Er_Homepage.dart @@ -0,0 +1,314 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/IWD/Create_Request.dart'; +import 'package:fusion/screens/IWD/Created_Requests.dart'; +import 'package:fusion/screens/IWD/Generated_Bill_Req.dart'; +import 'package:fusion/screens/IWD/Issue_Work_Order.dart'; +import 'package:fusion/screens/IWD/Rejected_Requests.dart'; +import 'package:fusion/screens/IWD/Request_In_Progress.dart'; +import 'package:fusion/screens/IWD/Request_Status.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; + +// void main() { +// runApp(MyApp()); +// } + +// class MyApp extends StatelessWidget { +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// debugShowCheckedModeBanner: false, +// title: 'Flutter Demo', +// theme: ThemeData( +// primarySwatch: Colors.deepOrange, // Set primary color to deep orange +// ), +// routes: { +// '/': (context) => MyHomePage(), +// '/create_request': (context) => RequestPage(title: 'Create Request'), +// '/created_requests': (context) => +// RequestPage(title: 'Created Requests'), +// '/rejected_requests': (context) => +// RequestPage(title: 'Rejected Requests'), +// '/issue_work_order': (context) => +// RequestPage(title: 'Issue Work Order'), +// '/requests_in_progress': (context) => +// RequestPage(title: 'Requests in Progress'), +// '/generate_bills': (context) => RequestPage(title: 'Generate Bills'), +// '/requests_status': (context) => RequestPage(title: 'Requests Status'), +// }, +// initialRoute: '/', +// ); +// } +// } + +class MyHomePage extends StatefulWidget { + @override + _MyHomePageState createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + // const MyHomePage({Key? key}) : super(key: key); + + // var service = locator(); + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('IWD Department'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Container( + padding: const EdgeInsets.all(20.0), + child: Container( + child: GridView( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 1.0, + mainAxisSpacing: 5.0, + crossAxisSpacing: 5.0, + ), + children: [ + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => RequestsUI()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Create Request', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CreatedRequestsWidget()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Created Requests', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => GeneratedBillsRequestsWidget()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Generated Bills', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Requests', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => IssueWorkWidget()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Issue Work', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Order', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => RequestsScreen()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Rejected Requests', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => RequestsInProgressScreen()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Requests in', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Progress', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => RequestStatus()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Request', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Status', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + ]), + ), + ), + ); + } +} + +// class CustomButton extends StatelessWidget { +// final String title; +// final String route; + +// const CustomButton({ +// Key? key, +// required this.title, +// required this.route, +// }) : super(key: key); + +// @override +// Widget build(BuildContext context) { +// return Container( +// margin: EdgeInsets.symmetric(vertical: 10), +// width: 200, +// height: 50, +// child: ElevatedButton( +// onPressed: () { +// Navigator.pushNamed(context, route); +// }, +// child: Text( +// title, +// style: TextStyle(fontSize: 16), +// ), +// ), +// ); +// } +// } + +// class RequestPage extends StatelessWidget { +// final String title; + +// const RequestPage({ +// Key? key, +// required this.title, +// }) : super(key: key); + +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: AppBar( +// title: Text(title), +// ), +// body: Center( +// child: Text( +// title, +// style: TextStyle(fontSize: 24), +// ), +// ), +// ); +// } +// } diff --git a/lib/screens/IWD/Generated_Bill_Req.dart b/lib/screens/IWD/Generated_Bill_Req.dart new file mode 100644 index 00000000..e691e96d --- /dev/null +++ b/lib/screens/IWD/Generated_Bill_Req.dart @@ -0,0 +1,238 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class GeneratedBillsRequestsWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Generated Bills Requests', // Changed heading to "Generated Bills Requests" + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: FutureBuilder>>( + future: fetchData(), // Function to fetch data from backend + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors + .deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ID', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Created By', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Bill', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Send to', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + ], + ), + ), + SizedBox( + height: + 10), // Added spacing between columns and data + Column( + children: snapshot.data!.map((data) { + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text(data['id']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['name']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['createdBy']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['bill']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['sendTo']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ); + }).toList(), + ), + ], + ); + } + }, + ), + ), + ], + ), + ), + ), + ), + ); + } + + // Dummy function to simulate fetching data from backend + Future>> fetchData() async { + // Simulating network delay + await Future.delayed(Duration(seconds: 2)); + + // Dummy data + List> data = [ + { + 'id': '1', + 'name': 'Request 1', + 'createdBy': 'User 1', + 'bill': 'Bill 1', + 'sendTo': 'Recipient 1', + }, + { + 'id': '2', + 'name': 'Request 2', + 'createdBy': 'User 2', + 'bill': 'Bill 2', + 'sendTo': 'Recipient 2', + }, + // Add more data as needed + ]; + + return data; + } +} diff --git a/lib/screens/IWD/Issue_Work_Order.dart b/lib/screens/IWD/Issue_Work_Order.dart new file mode 100644 index 00000000..d3d44acb --- /dev/null +++ b/lib/screens/IWD/Issue_Work_Order.dart @@ -0,0 +1,238 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class IssueWorkWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Issue Work Order', // Changed heading to "Issue Work Order" + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: FutureBuilder>>( + future: fetchData(), // Function to fetch data from backend + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors + .deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ID', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + Text( + 'Created by', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), // Bold font + ), + SizedBox( + width: 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: 5), // Added spacing between columns + ], + ), + ), + SizedBox( + height: + 10), // Added spacing between columns and data + Column( + children: snapshot.data!.map((data) { + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text(data['id']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['name']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['description']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['area']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['createdBy']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ); + }).toList(), + ), + ], + ); + } + }, + ), + ), + ], + ), + ), + ), + ), + ); + } + + // Dummy function to simulate fetching data from backend + Future>> fetchData() async { + // Simulating network delay + await Future.delayed(Duration(seconds: 2)); + + // Dummy data + List> data = [ + { + 'id': '1', + 'name': 'Request 1', + 'description': 'Description 1', + 'area': 'Area 1', + 'createdBy': 'User 1', + }, + { + 'id': '2', + 'name': 'Request 2', + 'description': 'Description 2', + 'area': 'Area 2', + 'createdBy': 'User 2', + }, + // Add more data as needed + ]; + + return data; + } +} diff --git a/lib/screens/IWD/Rejected_Requests.dart b/lib/screens/IWD/Rejected_Requests.dart new file mode 100644 index 00000000..9f91bf7d --- /dev/null +++ b/lib/screens/IWD/Rejected_Requests.dart @@ -0,0 +1,254 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class RequestsScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Rejected Requests', // Changed heading to "Rejected Requests" + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: FutureBuilder>>( + future: fetchData(), // Function to fetch data from backend + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors + .deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ID', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Created by', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ), + ), + SizedBox( + height: + 10), // Added spacing between columns and data + Column( + children: snapshot.data!.map((data) { + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text(data['id']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['name']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['description']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['area']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['createdBy']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ); + }).toList(), + ), + ], + ); + } + }, + ), + ), + ], + ), + ), + ), + ), + ); + } + + // Dummy function to simulate fetching data from backend + Future>> fetchData() async { + // Simulating network delay + await Future.delayed(Duration(seconds: 2)); + + // Dummy data + List> data = [ + { + 'id': '1', + 'name': 'Request 1', + 'description': 'Description 1', + 'area': 'Area 1', + 'createdBy': 'User 1', + }, + { + 'id': '2', + 'name': 'Request 2', + 'description': 'Description 2', + 'area': 'Area 2', + 'createdBy': 'User 2', + }, + // Add more data as needed + ]; + + return data; + } +} diff --git a/lib/screens/IWD/Request_In_Progress.dart b/lib/screens/IWD/Request_In_Progress.dart new file mode 100644 index 00000000..75765ad9 --- /dev/null +++ b/lib/screens/IWD/Request_In_Progress.dart @@ -0,0 +1,254 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class RequestsInProgressScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Requests in Progress', // Changed heading to "Requests in Progress" + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: FutureBuilder>>( + future: fetchData(), // Function to fetch data from backend + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors + .deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ID', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Created by', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ), + ), + SizedBox( + height: + 10), // Added spacing between columns and data + Column( + children: snapshot.data!.map((data) { + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text(data['id']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['name']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['description']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['area']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['createdBy']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ); + }).toList(), + ), + ], + ); + } + }, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +// Dummy function to simulate fetching data from backend +Future>> fetchData() async { + // Simulating network delay + await Future.delayed(Duration(seconds: 2)); + + // Dummy data + List> data = [ + { + 'id': '1', + 'name': 'Request 1', + 'description': 'Description 1', + 'area': 'Area 1', + 'createdBy': 'User 1', + }, + { + 'id': '2', + 'name': 'Request 2', + 'description': 'Description 2', + 'area': 'Area 2', + 'createdBy': 'User 2', + }, + // Add more data as needed + ]; + + return data; +} diff --git a/lib/screens/IWD/Request_Status.dart b/lib/screens/IWD/Request_Status.dart new file mode 100644 index 00000000..646a1c0e --- /dev/null +++ b/lib/screens/IWD/Request_Status.dart @@ -0,0 +1,280 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class RequestStatus extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Requests Status', // Changed heading to "Requests Status" + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), // Added spacing between heading and box + Container( + margin: EdgeInsets.symmetric(horizontal: 30), // Added margin + padding: EdgeInsets.all(10), // Added padding + decoration: BoxDecoration( + color: Colors.orange[50], // Background color of the box + borderRadius: BorderRadius.circular(10), // Border radius + border: Border.all( + color: Colors.deepOrange), // Border color and width + ), + child: FutureBuilder>>( + future: fetchData(), // Function to fetch data from backend + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors + .deepOrange), // Bottom partition line + ), + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ID', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Name', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Description', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Area', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Created By', + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text( + 'Status', // Added Status column heading + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.bold), // Bold font + ), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ), + ), + SizedBox( + height: + 10), // Added spacing between columns and data + Column( + children: snapshot.data!.map((data) { + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text(data['id']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['name']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['description']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['area']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text(data['createdBy']!), + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + Text('Pending'), // Dummy status text + SizedBox( + width: + 5), // Added spacing between columns + Container( + width: 1, + color: Colors.grey), // Vertical line + SizedBox( + width: + 5), // Added spacing between columns + ], + ); + }).toList(), + ), + ], + ); + } + }, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +// Dummy function to simulate fetching data from backend +Future>> fetchData() async { + // Simulating network delay + await Future.delayed(Duration(seconds: 2)); + + // Dummy data + List> data = [ + { + 'id': '1', + 'name': 'Request 1', + 'description': 'Description 1', + 'area': 'Area 1', + 'createdBy': 'User 1', + }, + { + 'id': '2', + 'name': 'Request 2', + 'description': 'Description 2', + 'area': 'Area 2', + 'createdBy': 'User 2', + }, + // Add more data as needed + ]; + + return data; +} diff --git a/lib/screens/IWD/Request_status_dean.dart b/lib/screens/IWD/Request_status_dean.dart new file mode 100644 index 00000000..f7f678d0 --- /dev/null +++ b/lib/screens/IWD/Request_status_dean.dart @@ -0,0 +1,171 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'dart:convert'; +import 'dart:math'; + +class Requests_Dean extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( +debugShowCheckedModeBanner: false, + home: Request_Status_Dean(), + ); + } +} + +class Request_Status_Dean extends StatefulWidget { + @override + _BudgetPageState createState() => _BudgetPageState(); +} + +class _BudgetPageState extends State { + List> _budgetData = []; + + @override + void initState() { + super.initState(); + fetchData(); // Fetch data when the page is initialized + } + + Future fetchData() async { + // Simulate a network request delay of 2 seconds + await Future.delayed(Duration(seconds: 2)); + + // Simulated response data + List> responseData = [ + { + 'id': 1, + 'name': 'John Doe', + 'description': 'Description 1', + 'area': 'Area A', + 'createdBy': 'User 1', + 'status': 'Pending' + }, + { + 'id': 2, + 'name': 'Jane Smith', + 'description': 'Description 2', + 'area': 'Area B', + 'createdBy': 'User 2', + 'status': 'Approved' + }, + { + 'id': 3, + 'name': 'Alice Johnson', + 'description': 'Description 3', + 'area': 'Area C', + 'createdBy': 'User 3', + 'status': 'Rejected' + }, + { + 'id': 4, + 'name': 'Bob Brown', + 'description': 'Description 4', + 'area': 'Area D', + 'createdBy': 'User 4', + 'status': 'Pending' + }, + { + 'id': 5, + 'name': 'Eva Lee', + 'description': 'Description 5', + 'area': 'Area E', + 'createdBy': 'User 5', + 'status': 'Approved' + }, + ]; + + setState(() { + _budgetData = responseData; // Update state with fetched data + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('IWD Department'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Requests Status', + style: TextStyle( + fontSize: 25, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.orange[50], + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.deepOrange), + ), + child: DataTable( + columns: [ + DataColumn(label: Text('ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Area')), + DataColumn(label: Text('Created By')), + DataColumn(label: Text('Status')), + ], + rows: _budgetData + .map( + (data) => DataRow( + cells: [ + DataCell(Text(data['id'].toString())), + DataCell(Text(data['name'].toString())), + DataCell(Text(data['description'].toString())), + DataCell(Text(data['area'].toString())), + DataCell(Text(data['createdBy'].toString())), + DataCell(Text(data['status'].toString())), + ], + ), + ) + .toList(), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(5), + ), + child: TextButton( + onPressed: () { + // Add your back button action here + print('Back button pressed'); + }, + child: Text( + 'BACK', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/IWD/engineer1.dart b/lib/screens/IWD/engineer1.dart new file mode 100644 index 00000000..e3ec5b1c --- /dev/null +++ b/lib/screens/IWD/engineer1.dart @@ -0,0 +1,229 @@ +import 'package:flutter/material.dart'; + +class engineer1 extends StatelessWidget { + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 40), // Adjusted for larger space + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 180, // Adjusted for larger space + height: 180, // Adjusted for larger space + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), // Adjusted for larger border radius + image: DecorationImage( + image: NetworkImage( + 'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png', + ), + fit: BoxFit.cover, + ), + ), + + child: CircleAvatar( + radius: 60, // Adjusted for larger space + backgroundColor: Colors.transparent, + ), + ), + SizedBox(width: 30), // Adjusted for larger space + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Manoj Kumar', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 24, // Adjusted for larger font size + ), + ), + Text( + 'Software Engineer', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, // Adjusted for larger font size + ), + ), + ], + ), + ], + ), + SizedBox(height: 40), // Adjusted for larger space + Container( + padding: EdgeInsets.all(20), // Adjusted for larger padding + color: Colors.orange, + child: Text( + 'Complaints Inbox', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 24, // Adjusted for larger font size + ), + textAlign: TextAlign.center, + ), + ), + SizedBox(height: 20), // Adjusted for larger space + // Here goes the section for complaints + MailWidget( + sender: 'John Doe', + details: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + ), + MailWidget( + sender: 'Jane Smith', + details: 'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', + ), + MailWidget( + sender: 'Emma Johnson', + details: 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.', + ), + // Add more MailWidget instances for additional complaints + SizedBox(height: 20), // Adjusted for larger space + ], + ), + ); + } +} + +class MailWidget extends StatelessWidget { + final String sender; + final String details; + + const MailWidget({ + Key? key, + required this.sender, + required this.details, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(20), // Adjusted for larger padding + margin: EdgeInsets.symmetric(vertical: 10, horizontal: 20), // Adjusted for larger margin + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), // Adjusted for larger border radius + border: Border.all(color: Colors.grey), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'From: $sender', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, // Adjusted for larger font size + ), + ), + ElevatedButton( + onPressed: () { + // Handle forwarding complaints + }, + style: ElevatedButton.styleFrom( + primary: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Text( + 'Forward', + style: TextStyle( + color: Colors.black, + fontSize: 18, // Adjusted for larger font size + ), + ), + ), + ], + ), + SizedBox(height: 10), // Adjusted for larger space + Text( + details, + style: TextStyle( + fontSize: 18, // Adjusted for larger font size + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ); + } +} + +class CustomNavBar extends StatelessWidget implements PreferredSizeWidget { + @override + Size get preferredSize => Size.fromHeight(kToolbarHeight); + + @override + Widget build(BuildContext context) { + return AppBar( + backgroundColor: Colors.black, + title: Row( + children: [ + IconButton( + icon: Icon( + Icons.menu, + color: Colors.white, + ), + onPressed: () { + // Handle menu button press + }, + ), + Text( + 'Fusion', + style: TextStyle( + color: Colors.white, + fontSize: 18.0, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + actions: [ + IconButton( + icon: Icon( + Icons.search, + color: Colors.white, + ), + onPressed: () { + // Handle search button press + }, + ), + IconButton( + icon: Icon( + Icons.notifications, + color: Colors.white, + ), + onPressed: () { + // Handle notification button press + }, + ), + IconButton( + icon: Icon( + Icons.more_vert, + color: Colors.white, + ), + onPressed: () { + // Handle dropdown menu button press + }, + ), + ], + ); + } +} + +void main() { + runApp(MaterialApp( + home: Scaffold( + appBar: PreferredSize( + preferredSize: Size.fromHeight(kToolbarHeight), + child: CustomNavBar(), + ), + body: engineer1(), + ), + )); +} \ No newline at end of file diff --git a/lib/services/iwd_services.dart b/lib/services/iwd_services.dart new file mode 100644 index 00000000..42655189 --- /dev/null +++ b/lib/services/iwd_services.dart @@ -0,0 +1,193 @@ +// import 'dart:convert'; +import 'dart:convert'; +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 IwdServices { + Future getCreated() async { + print("hello"); + try { + var storage_service = locator(); + + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + print('token : ${storage_service.userInDB?.token}'); + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + Map body = { + "eligible" : "Junior Engineer" + }; + print("fetching Created Requests"); + var client = http.Client(); + + http.Response response = await client.post( + Uri.http( + kIwd, + kCreatedReq, //constant api path + ), + headers: headers, + body: jsonEncode(body), + ); + + if (response.statusCode == 200) { + print("successfully fetched Created Requests"); + return response; + } + throw Exception('Can\'t load. Status code: ${response.statusCode}'); + } catch (e) { + rethrow; + } + } + + Future lodgeComplaint( + // ignore: non_constant_identifier_names + String? complaint_finish, + // ignore: non_constant_identifier_names + String? complaint_type, + String? location, + // ignore: non_constant_identifier_names + String? specific_location, + String? details, + String? status, + String? remarks, + String? flag, + String? reason, + String? feedback, + String? comment, + String? complainer, + // ignore: non_constant_identifier_names + String? worker_id, + ) async { + try { + Map data = { + "complaint_finish": complaint_finish!, + "complaint_type": complaint_type!, + "location": location!, + "specific_location": specific_location!, + "details": details!, + "status": status!, + "remarks": remarks!, + "flag": flag!, + "reason": reason!, + "feedback": feedback!, + "comment": comment!, + "complainer": complainer!, + "worker_id": worker_id!, + }; + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + + var client = http.Client(); + var response = await client.post( + Uri.http( + getLink(), + kComplaintNew, //constant new complaint path + ), + headers: headers, + body: data); + // print(response.statusCode); + + if (response.statusCode == 201) return true; + return false; + } catch (e) { + rethrow; + } + } + + Future updateComplaint( + int? id, + // ignore: non_constant_identifier_names + String? complaint_date, + // ignore: non_constant_identifier_names + String? complaint_finish, + // ignore: non_constant_identifier_names + String? complaint_type, + String? location, + // ignore: non_constant_identifier_names + String? specific_location, + String? details, + String? status, + String? remarks, + String? flag, + String? reason, + String? feedback, + String? comment, + String? complainer, + ) async { + try { + Map data = { + "complaint_date": complaint_date!, + "complaint_finish": complaint_finish!, + "complaint_type": complaint_type!, + "location": location!, + "specific_location": specific_location!, + "details": details!, + "status": status!, + "remarks": remarks!, + "flag": flag!, + "reason": reason!, + "feedback": feedback!, + "comment": comment!, + "complainer": complainer!, + }; + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + + var client = http.Client(); + var response = await client.put( + Uri.http( + getLink(), + "$kComplaintUpdate$id", //constant update path + ), + headers: headers, + body: data); + print("Fetched Data"); + if (response.statusCode == 200) return true; + return false; + } catch (e) { + rethrow; + } + } + + Future deleteComplaint(int? id) async { + try { + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + var client = http.Client(); + print(id); + var response = await client.delete( + Uri.http( + getLink(), + "$kComplaintRemove$id", //constant remove path + ), + headers: headers, + ); + // print(response.statusCode); + if (response.statusCode == 404) return true; + return false; + } catch (e) { + rethrow; + } + } +} From 3473560802c894166739db8221dc75bba7904e11 Mon Sep 17 00:00:00 2001 From: Risgabh Nigam Date: Sat, 27 Apr 2024 23:12:40 +0530 Subject: [PATCH 5/5] Added new features --- android/app/build.gradle | 2 +- lib/Components/side_drawer2.dart | 4 +- lib/api.dart | 8 +- lib/screens/IWD/Created_Requests.dart | 79 +++++- lib/screens/IWD/Request_Status.dart | 354 +++++++------------------- lib/services/iwd_services.dart | 78 +++++- 6 files changed, 254 insertions(+), 271 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 2b47ce25..02566a58 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 33 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/lib/Components/side_drawer2.dart b/lib/Components/side_drawer2.dart index 97c80e8d..d33b3990 100644 --- a/lib/Components/side_drawer2.dart +++ b/lib/Components/side_drawer2.dart @@ -163,8 +163,8 @@ class _SideDrawerState extends State { - if ((widget.curr_desig== "Executive Engineer (Civil)" ||widget.curr_desig== "EE" || widget.curr_desig== "Admin IWD" || widget.curr_desig== "Electrical_AE" || widget.curr_desig== "mess_manager" || widget.curr_desig== "Electrical_JE" || widget.curr_desig== "Civil_AE" || widget.curr_desig== "Civil_JE" || widget.curr_desig== "Director" || widget.curr_desig== "dean_s" || widget.curr_desig== "Dean_s" || widget.curr_desig== "DeanPnD" )) - ModulesCard(cardLine: 'IWD',pageMover: '/iwd/home_page'), + if ((widget.curr_desig== "Executive Engineer (Civil)" ||widget.curr_desig== "EE" || widget.curr_desig== "Admin IWD" || widget.curr_desig== "Electrical_AE" || widget.curr_desig== "mess_manager" || widget.curr_desig== "Electrical_JE" || widget.curr_desig== "Civil_AE" || widget.curr_desig== "Civil_JE" || widget.curr_desig== "Director" || widget.curr_desig== "dean_s" || widget.curr_desig== "Dean_s" || widget.curr_desig== "DeanPnD" ||widget.curr_desig== "Junior Engineer")) + ModulesCard(cardLine: 'IWD',pageMover: '/IWD_Homepage'), ModulesCard(cardLine: 'Courses Module', pageMover: '/registered_courses', diff --git a/lib/api.dart b/lib/api.dart index 22627ae2..9e9480e1 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.214:8000"; +//String kserverLink = "172.27.16.214:8000"; +String kserverLink = "foal-cheerful-optionally.ngrok-free.app"; //Login Service -String kAuthUrl = "172.27.16.214:8000"; +String kAuthUrl = "foal-cheerful-optionally.ngrok-free.app"; +// String kAuthUrl = "172.27.16.214:8000"; String kAuthLogin = "/api/auth/login/"; // String kAuthLogin = "/accounts/login"; @@ -34,6 +36,8 @@ String kHealthCentreStudent = "/healthcenter/api/student"; //IWD String kIwd = 'foal-cheerful-optionally.ngrok-free.app'; String kCreatedReq = '/iwdModuleV2/api/createdRequestsView/'; +String kReqStatus = '/iwdModuleV2/api/requestsStatus/'; +String kDesignations = '/iwdModuleV2/api/fetchDesignationsapi/'; //------------Screens------------ diff --git a/lib/screens/IWD/Created_Requests.dart b/lib/screens/IWD/Created_Requests.dart index 1ba494f7..e13bec4c 100644 --- a/lib/screens/IWD/Created_Requests.dart +++ b/lib/screens/IWD/Created_Requests.dart @@ -11,13 +11,16 @@ class CreatedRequestsWidget extends StatefulWidget { } class _CreatedRequestsWidgetState extends State { + String? selectedSendToOption; IwdServices iwdServices = IwdServices(); List> _map_obj = []; + List _sendToOptions = []; @override void initState() { super.initState(); _getCreatedRequests(); + _getSendToOptions(); } void _getCreatedRequests() async { @@ -49,6 +52,26 @@ class _CreatedRequestsWidgetState extends State { }); } + Future _getSendToOptions() async { + try { + http.Response response = await iwdServices.getDesignations(); + if (response.statusCode == 200) { + List data = json.decode(response.body)['holdsDesignations']; + List designations = + data.map((item) => '${item[1]}(${item[0]})').toList(); + setState(() { + _sendToOptions = designations; + }); + } else { + // Handle error + print('Error fetching "Send To" options: ${response.statusCode}'); + } + } catch (e) { + // Handle exception + print('Error fetching "Send To" options: $e'); + } + } + @override Widget build(BuildContext context) { return MaterialApp( @@ -98,15 +121,57 @@ class _CreatedRequestsWidgetState extends State { DataColumn(label: Text('Description')), DataColumn(label: Text('Area')), DataColumn(label: Text('Created By')), + DataColumn(label: Text('Send To')), ], rows: _map_obj.map((data) { - return DataRow(cells: [ - DataCell(Text(data['id'].toString())), - DataCell(Text(data['Name'] ?? '')), - DataCell(Text(data['Description'] ?? '')), - DataCell(Text(data['Area'] ?? '')), - DataCell(Text(data['Created By'] ?? '')), - ]); + + return DataRow( + cells: [ + DataCell(Text(data['id'].toString())), + DataCell(Text(data['Name'] ?? '')), + DataCell(Text(data['Description'] ?? '')), + DataCell(Text(data['Area'] ?? '')), + DataCell(Text(data['Created By'] ?? '')), + DataCell( + Row( + children: [ + DropdownButton( + hint: Text("-SELECT-"), + onChanged: (String? newValue) { + print(newValue); + setState(() { + selectedSendToOption = newValue; + }); + print(selectedSendToOption); + }, + value: selectedSendToOption, + items: _sendToOptions.map((String option) { + return DropdownMenuItem( + value: option, + child: Text(option), + ); + }).toList(), + ), + SizedBox(width: 10), + ElevatedButton( + onPressed: () { + // Add your forward button logic here + print( + 'Forward button pressed for request: ${data['id']}'); + print( + 'Selected "Send To" option: $selectedSendToOption'); + }, + style: ElevatedButton.styleFrom( + primary: Colors.orange, + onPrimary: Colors.white, + ), + child: Icon(Icons.forward), + ), + ], + ), + ), + ], + ); }).toList(), ), ), diff --git a/lib/screens/IWD/Request_Status.dart b/lib/screens/IWD/Request_Status.dart index 646a1c0e..8fdfc950 100644 --- a/lib/screens/IWD/Request_Status.dart +++ b/lib/screens/IWD/Request_Status.dart @@ -1,8 +1,55 @@ import 'package:flutter/material.dart'; import 'package:fusion/Components/appBar.dart'; import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/services/iwd_services.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; -class RequestStatus extends StatelessWidget { +class RequestStatus extends StatefulWidget { + @override + _RequestStatusState createState() => _RequestStatusState(); +} + +class _RequestStatusState extends State { + IwdServices iwdServices = IwdServices(); + List> _map_obj = []; + + @override + void initState() { + super.initState(); + _getReqStatus(); + } + + void _getReqStatus() async { + http.Response response = await iwdServices.getRequestStatus(); + var data = json.decode(response.body)['obj']; + + List> mappedObjects = []; + + data.forEach((item) { + String id = item[0].toString(); + String name = item[1]; + String area = item[2]; + String description = item[3]; + String createdBy = item[4]; + String status = item[5]; + + Map mappedObject = { + 'id': id, + 'Name': name, + 'Area': area, + 'Description': description, + 'Created By': createdBy, + 'Status': status, + }; + + mappedObjects.add(mappedObject); + }); + + setState(() { + _map_obj = mappedObjects; + }); + } @override Widget build(BuildContext context) { return MaterialApp( @@ -14,267 +61,60 @@ class RequestStatus extends StatelessWidget { scrollDirection: Axis.vertical, child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(16.0), - child: Text( - 'Requests Status', // Changed heading to "Requests Status" - style: TextStyle( - fontSize: 20, - color: Color.fromARGB(255, 74, 73, 73), - fontWeight: FontWeight.bold, - ), - ), - ), - SizedBox(height: 20), // Added spacing between heading and box - Container( - margin: EdgeInsets.symmetric(horizontal: 30), // Added margin - padding: EdgeInsets.all(10), // Added padding - decoration: BoxDecoration( - color: Colors.orange[50], // Background color of the box - borderRadius: BorderRadius.circular(10), // Border radius - border: Border.all( - color: Colors.deepOrange), // Border color and width - ), - child: FutureBuilder>>( - future: fetchData(), // Function to fetch data from backend - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Center( - child: CircularProgressIndicator(), - ); - } else if (snapshot.hasError) { - return Center( - child: Text('Error: ${snapshot.error}'), - ); - } else { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors - .deepOrange), // Bottom partition line - ), - ), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - 'ID', - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight.bold), // Bold font - ), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text( - 'Name', - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight.bold), // Bold font - ), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text( - 'Description', - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight.bold), // Bold font - ), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text( - 'Area', - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight.bold), // Bold font - ), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text( - 'Created By', - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight.bold), // Bold font - ), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text( - 'Status', // Added Status column heading - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight.bold), // Bold font - ), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - ], - ), - ), - SizedBox( - height: - 10), // Added spacing between columns and data - Column( - children: snapshot.data!.map((data) { - return Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text(data['id']!), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text(data['name']!), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text(data['description']!), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text(data['area']!), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text(data['createdBy']!), - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - Text('Pending'), // Dummy status text - SizedBox( - width: - 5), // Added spacing between columns - Container( - width: 1, - color: Colors.grey), // Vertical line - SizedBox( - width: - 5), // Added spacing between columns - ], - ); - }).toList(), - ), - ], - ); - } - }, - ), - ), - ], - ), + child: _buildWidget(), ), ), ), ); } -} -// Dummy function to simulate fetching data from backend -Future>> fetchData() async { - // Simulating network delay - await Future.delayed(Duration(seconds: 2)); - - // Dummy data - List> data = [ - { - 'id': '1', - 'name': 'Request 1', - 'description': 'Description 1', - 'area': 'Area 1', - 'createdBy': 'User 1', - }, - { - 'id': '2', - 'name': 'Request 2', - 'description': 'Description 2', - 'area': 'Area 2', - 'createdBy': 'User 2', - }, - // Add more data as needed - ]; + Widget _buildWidget() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Request Status', + style: TextStyle( + fontSize: 20, + color: Color.fromARGB(255, 74, 73, 73), + fontWeight: FontWeight.bold, + ), + ), + ), + SizedBox(height: 20), + Container( + margin: EdgeInsets.symmetric(horizontal: 30), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.orange[50], + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.deepOrange), + ), + child: DataTable( + columns: [ + DataColumn(label: Text('ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Area')), + DataColumn(label: Text('Created By')), + DataColumn(label: Text('Status')), - return data; + ], + rows: _map_obj.map((data) { + return DataRow(cells: [ + DataCell(Text(data['id'].toString())), + DataCell(Text(data['Name'] ?? '')), + DataCell(Text(data['Description'] ?? '')), + DataCell(Text(data['Area'] ?? '')), + DataCell(Text(data['Created By'] ?? '')), + DataCell(Text(data['Status'] ?? '')), + ]); + }).toList(), + ), + ), + ], + ); + } } diff --git a/lib/services/iwd_services.dart b/lib/services/iwd_services.dart index 42655189..08916020 100644 --- a/lib/services/iwd_services.dart +++ b/lib/services/iwd_services.dart @@ -9,14 +9,14 @@ import 'package:http/http.dart' as http; class IwdServices { Future getCreated() async { - print("hello"); + // print("hello"); try { var storage_service = locator(); if (storage_service.userInDB?.token == null) throw Exception('Token Error'); - print('token : ${storage_service.userInDB?.token}'); + // print('token : ${storage_service.userInDB?.token}'); Map headers = { 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") }; @@ -45,6 +45,80 @@ class IwdServices { } } + Future getRequestStatus() async { + // print("hello"); + try { + var storage_service = locator(); + + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + // print('token : ${storage_service.userInDB?.token}'); + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + Map body = { + "eligible" : "Junior Engineer" + }; + print("fetching Request Status"); + var client = http.Client(); + + http.Response response = await client.post( + Uri.http( + kIwd, + kReqStatus, //constant api path + ), + headers: headers, + body: jsonEncode(body), + ); + + if (response.statusCode == 200) { + print("successfully fetched Request Status"); + return response; + } + throw Exception('Can\'t load. Status code: ${response.statusCode}'); + } catch (e) { + rethrow; + } + } + Future getDesignations() async { + // print("hello"); + try { + var storage_service = locator(); + + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + // print('token : ${storage_service.userInDB?.token}'); + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + Map body = { + "eligible" : "Junior Engineer" + }; + print("fetching Designations"); + var client = http.Client(); + + http.Response response = await client.post( + Uri.http( + kIwd, + kDesignations, //constant api path + ), + headers: headers, + body: jsonEncode(body), + ); + + if (response.statusCode == 200) { + print("successfully fetched Designations"); + return response; + } + throw Exception('Can\'t load. Status code: ${response.statusCode}'); + } catch (e) { + rethrow; + } + } + + Future lodgeComplaint( // ignore: non_constant_identifier_names String? complaint_finish,