From 75f5fbfa48d3c8c8e591c2400354d32490607c76 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:47:49 +0530 Subject: [PATCH 01/11] Create managestudent.dart --- .../Hostel/caretaker/managestudent.dart | 509 ++++++++++++++++++ 1 file changed, 509 insertions(+) create mode 100644 lib/screens/Hostel/caretaker/managestudent.dart diff --git a/lib/screens/Hostel/caretaker/managestudent.dart b/lib/screens/Hostel/caretaker/managestudent.dart new file mode 100644 index 00000000..285ae555 --- /dev/null +++ b/lib/screens/Hostel/caretaker/managestudent.dart @@ -0,0 +1,509 @@ +//All the 4 functionalities like add new student,edit existing student details,delete a student,search a student +// by his/her name via search bar are all perfectly working in this code.No need further debugging except to integrate API's. + +import 'dart:convert'; +import 'package:flutter/material.dart'; + + + +class Student { + final String rollNo; + String name; + int batch; + String program; + String specialization; + String hallNo; + String roomNo; + String contactNo; + String address; + + Student({ + required this.rollNo, + required this.name, + required this.batch, + required this.program, + required this.specialization, + required this.hallNo, + required this.roomNo, + required this.contactNo, + required this.address, + }); +} + +class Managestudent extends StatefulWidget { + const Managestudent({Key? key}) : super(key: key); + + @override + _ManagestudentState createState() => _ManagestudentState(); +} + +class _ManagestudentState extends State { + List students = []; + List filteredStudents = []; + + @override + void initState() { + super.initState(); + _fetchStudentDetails(); + } + + Future _fetchStudentDetails() async { + // Simulating GET API call to fetch student details + final String studentData = ''' + [ + {"rollNo": "21bcs001", "name": "Rahul", "batch": 2021, "program": "B.Tech", "specialization": "CSE", "hallNo": "Hall-4", "roomNo": "G-31", "contactNo": "+911234567890", "address": "Address 1, City 1, State 1, Country 1"}, + {"rollNo": "21bme002", "name": "Kiran", "batch": 2021, "program": "B.Tech", "specialization": "MEE", "hallNo": "Hall-4", "roomNo": "F-24", "contactNo": "+919876543210", "address": "Address 2, City 2, State 2, Country 2"}, + {"rollNo": "21bcs003", "name": "Amit", "batch": 2021, "program": "B.Tech", "specialization": "CSE", "hallNo": "Hall-4", "roomNo": "S-12", "contactNo": "+914561237890", "address": "Address 3, City 3, State 3, Country 3"}, + {"rollNo": "21sm004", "name": "Kunal", "batch": 2021, "program": "B.Tech", "specialization": "SM", "hallNo": "Hall-4", "roomNo": "G-31", "contactNo": "+911234567890", "address": "Address 4, City 4, State 4, Country 4"}, + {"rollNo": "21bcs005", "name": "Vishal", "batch": 2021, "program": "B.Tech", "specialization": "CSE", "hallNo": "Hall-4", "roomNo": "F-24", "contactNo": "+919876543210", "address": "Address 5, City 5, State 5, Country 5"}, + {"rollNo": "23me116", "name": "Divyanshu", "batch": 2023, "program": "B.Tech", "specialization": "ME", "hallNo": "Hall-4", "roomNo": "S-12", "contactNo": "+914561237890", "address": "Address 6, City 6, State 6, Country 6"}, + {"rollNo": "23bec117", "name": "Raj", "batch": 2023, "program": "B.Tech", "specialization": "ECE", "hallNo": "Hall-4", "roomNo": "G-31", "contactNo": "+911234567890", "address": "Address 7, City 7, State 7, Country 7"}, + {"rollNo": "23bds118", "name": "Anurag", "batch": 2023, "program": "B.Des", "specialization": "DS", "hallNo": "Hall-4", "roomNo": "F-24", "contactNo": "+919876543210", "address": "Address 8, City 8, State 8, Country 8"} + ] + '''; + final List studentList = json.decode(studentData); + setState(() { + students = studentList.map((student) => Student( + rollNo: student['rollNo'], + name: student['name'], + batch: student['batch'], + program: student['program'], + specialization: student['specialization'], + hallNo: student['hallNo'], + roomNo: student['roomNo'], + contactNo: student['contactNo'], + address: student['address'], + )).toList(); + filteredStudents = List.from(students); + }); + } + + Future _editStudentDetails(Student student) async { + // Display dialog to edit student details + showDialog( + context: context, + builder: (BuildContext context) { + String name = student.name; + int batch = student.batch; + String program = student.program; + String specialization = student.specialization; + String hallNo = student.hallNo; + String roomNo = student.roomNo; + String contactNo = student.contactNo; + String address = student.address; + + return AlertDialog( + title: Text('Edit Student Details'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration(labelText: 'Name'), + controller: TextEditingController(text: name), + onChanged: (value) { + name = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Batch'), + controller: TextEditingController(text: batch.toString()), + onChanged: (value) { + batch = int.tryParse(value) ?? 0; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Program'), + controller: TextEditingController(text: program), + onChanged: (value) { + program = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Specialization'), + controller: TextEditingController(text: specialization), + onChanged: (value) { + specialization = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Hall No'), + controller: TextEditingController(text: hallNo), + onChanged: (value) { + hallNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Room No'), + controller: TextEditingController(text: roomNo), + onChanged: (value) { + roomNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Contact No'), + controller: TextEditingController(text: contactNo), + onChanged: (value) { + contactNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Address'), + controller: TextEditingController(text: address), + onChanged: (value) { + address = value; + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the edit operation here + setState(() { + student.name = name; + student.batch = batch; + student.program = program; + student.specialization = specialization; + student.hallNo = hallNo; + student.roomNo = roomNo; + student.contactNo = contactNo; + student.address = address; + }); + // Simulate POST API call to update student details + // _updateStudentDetails(student); + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + Future _deleteStudentDetails(Student student) async { + // Show confirmation dialog before deleting the student + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Confirm Deletion'), + content: Text('Are you sure you want to delete this student?'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Delete the student + _deleteStudent(student); + Navigator.of(context).pop(); + }, + child: Text('Delete'), + ), + ], + ); + }, + ); + } + + void _deleteStudent(Student student) { + setState(() { + students.remove(student); + filteredStudents.remove(student); + }); + // Simulate DELETE API call to delete student details + // _invokeDeleteAPI(student.rollNo); + } + + Future _showAddDialog() async { + String rollNo = ''; + String name = ''; + int batch = 0; + String program = ''; + String specialization = ''; + String hallNo = ''; + String roomNo = ''; + String contactNo = ''; + String address = ''; + + await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Add New Student'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration(labelText: 'Roll No'), + onChanged: (value) { + rollNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Name'), + onChanged: (value) { + name = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Batch'), + onChanged: (value) { + batch = int.tryParse(value) ?? 0; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Program'), + onChanged: (value) { + program = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Specialization'), + onChanged: (value) { + specialization = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Hall No'), + onChanged: (value) { + hallNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Room No'), + onChanged: (value) { + roomNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Contact No'), + onChanged: (value) { + contactNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Address'), + onChanged: (value) { + address = value; + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the add operation here + setState(() { + final newStudent = Student( + rollNo: rollNo, + name: name, + batch: batch, + program: program, + specialization: specialization, + hallNo: hallNo, + roomNo: roomNo, + contactNo: contactNo, + address: address, + ); + students.add(newStudent); + filteredStudents.add(newStudent); + }); + // Simulate POST API call to add new student details + // _addStudentDetails(rollNo, name, batch, program, specialization, hallNo, roomNo, contactNo, address); + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + void _searchStudents(String query) { + setState(() { + if (query.isNotEmpty) { + filteredStudents = students.where((student) { + return student.rollNo.contains(query) || student.name.contains(query); + }).toList(); + } else { + filteredStudents = List.from(students); + } + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Manage Students'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () async { + final String? result = await showSearch( + context: context, + delegate: StudentSearchDelegate(students: students), + ); + if (result != null) { + _searchStudents(result); + } + }, + ), + ], + ), + body: SingleChildScrollView( + child: DataTable( + columns: const [ + DataColumn(label: Text('Roll No')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Batch')), + DataColumn(label: Text('Program')), + DataColumn(label: Text('Specialization')), + DataColumn(label: Text('Hall No')), + DataColumn(label: Text('Room No')), + DataColumn(label: Text('Contact No')), + DataColumn(label: Text('Address')), + DataColumn(label: Text('Edit')), + DataColumn(label: Text('Remove')), + ], + rows: List.generate( + filteredStudents.length, + (index) => DataRow( + cells: [ + DataCell(Text(filteredStudents[index].rollNo)), + DataCell(Text(filteredStudents[index].name)), + DataCell(Text(filteredStudents[index].batch.toString())), + DataCell(Text(filteredStudents[index].program)), + DataCell(Text(filteredStudents[index].specialization)), + DataCell(Text(filteredStudents[index].hallNo)), + DataCell(Text(filteredStudents[index].roomNo)), + DataCell(Text(filteredStudents[index].contactNo)), + DataCell(Text(filteredStudents[index].address)), + DataCell( + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + _editStudentDetails(filteredStudents[index]); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.delete), + onPressed: () { + _deleteStudentDetails(filteredStudents[index]); + }, + ), + ), + ], + ), + ), + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _showAddDialog, + child: Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + ), + ); + } +} + +class StudentSearchDelegate extends SearchDelegate { + final List students; + + StudentSearchDelegate({required this.students}); + + @override + ThemeData appBarTheme(BuildContext context) { + final ThemeData theme = Theme.of(context); + return theme.copyWith( + appBarTheme: AppBarTheme( + backgroundColor: theme.scaffoldBackgroundColor, // Match with screen's UI theme + iconTheme: IconThemeData(color: theme.primaryColor), // Match with screen's UI theme + ), + ); + } + + @override + List buildActions(BuildContext context) { + return [ + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + query = ''; + }, + ), + ]; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, null); + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + return _buildSearchResults(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + return _buildSearchResults(context); + } + + Widget _buildSearchResults(BuildContext context) { + final List filteredStudents = students.where((student) { + final String lowercaseQuery = query.toLowerCase(); + return student.rollNo.toLowerCase().contains(lowercaseQuery) || student.name.toLowerCase().contains(lowercaseQuery); + }).toList(); + return ListView.builder( + itemCount: filteredStudents.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(filteredStudents[index].name), + subtitle: Text(filteredStudents[index].rollNo), + onTap: () { + close(context, filteredStudents[index].rollNo); + }, + ); + }, + ); + } +} + + + +void main() { + runApp(MaterialApp( + home: Managestudent(), + )); +} From 11a833bb9e292ffc0859b9f6d9b7d62c29492318 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:54:52 +0530 Subject: [PATCH 02/11] Create noticeboard.dart Added Notice Board screen to the Caretaker and the screen is fully functional to view/add/remove any notice. --- lib/screens/Hostel/caretaker/noticeboard.dart | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 lib/screens/Hostel/caretaker/noticeboard.dart diff --git a/lib/screens/Hostel/caretaker/noticeboard.dart b/lib/screens/Hostel/caretaker/noticeboard.dart new file mode 100644 index 00000000..2fe8bb5d --- /dev/null +++ b/lib/screens/Hostel/caretaker/noticeboard.dart @@ -0,0 +1,215 @@ +//All the 2 functionalities like add new notice,remove existing notice are all perfectly +//working in this code with proper formatting.No need further debugging on this code. + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Notice { + final String headline; + final String description; + final DateTime date; + + Notice(this.headline, this.description, this.date); +} + +class Noticeboard extends StatefulWidget { + const Noticeboard({Key? key}) : super(key: key); + + @override + _NoticeboardState createState() => _NoticeboardState(); +} + +class _NoticeboardState extends State { + List notices = []; // Define the 'notices' list + + @override + void initState() { + super.initState(); + // Populate with sample notice boards + _populateNoticeBoards(); + } + + // Method to populate sample notice boards + void _populateNoticeBoards() { + // Sample notice board 1 + notices.add( + Notice( + 'Important Announcement', + 'All students are hereby informed that using Alcohol,Cigaretts andElectical Items are prohibited in hostels.If found heavy fine will be imposed.', + DateTime(2024, 4, 22), + ), + ); + + // Sample notice board 2 + notices.add( + Notice( + 'Republic Day 2k24', + 'As you all are aware today is Republic day,so interested students can attend the flag hosting infront of hostel which will be starting at 8:00am.', + DateTime(2024, 1, 26), + ), + ); + + // Notify the UI about the changes + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Notice Board'), + backgroundColor: const Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Padding( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: ListView.builder( + itemCount: notices.length, + itemBuilder: (context, index) { + return Card( + margin: EdgeInsets.only(bottom: 20), + color: Color.fromARGB(255, 255, 229, 218), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: BorderSide( + color: Color.fromARGB(255, 245, 103, 47), + width: 2.0, + ), + ), + child: Padding( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + notices[index].headline, + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + Text( + '${notices[index].date.day}/${notices[index].date.month}/${notices[index].date.year}', + style: TextStyle(fontSize: 16), + ), + ], + ), + SizedBox(height: 10), + Text( + notices[index].description, + style: TextStyle(fontSize: 18), + ), + SizedBox(height: 20), + ElevatedButton( + onPressed: () { + // Handle file upload logic here + }, + child: Text('View Uploaded File'), + ), + SizedBox(height: 10), + Align( + alignment: Alignment.bottomRight, + child: ElevatedButton( + onPressed: () { + // Remove notice board logic here + setState(() { + notices.removeAt(index); + }); + }, + child: Text('Remove Notice'), + ), + ), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + // Display dialog to add a new notice + showDialog( + context: context, + builder: (BuildContext context) { + String headline = ''; + String description = ''; + + return AlertDialog( + title: Text('Add New Notice'), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration( + labelText: 'Headline', + ), + onChanged: (value) { + headline = value; + }, + ), + SizedBox(height: 10), + TextField( + decoration: InputDecoration( + labelText: 'Description', + ), + onChanged: (value) { + description = value; + }, + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: () { + // Handle file upload logic here + }, + child: Text('Upload File'), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Add new notice logic here + setState(() { + notices.add(Notice(headline, description, DateTime.now())); + }); + // Invoke sample POST API + // _invokePostAPI(headline, description, file); + Navigator.of(context).pop(); + }, + child: Text('Add'), + ), + ], + ); + }, + ); + }, + child: const Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + ); + } + + // Method to invoke a POST API + void _invokePostAPI(String headline, String description, String file) { + // Your implementation to invoke POST API + // Example: http.post(url, body: {'headline': headline, 'description': description, 'file': file}); + } +} From f1237fb980e370eb8d794df320de6b7dedebbcea Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:57:12 +0530 Subject: [PATCH 03/11] Update managestudent.dart Added Manage Student screen to Caretaker which is fully functional with add/edit/remove and search students operations.Also included sample data to see these operations in action. --- lib/screens/Hostel/caretaker/managestudent.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/Hostel/caretaker/managestudent.dart b/lib/screens/Hostel/caretaker/managestudent.dart index 285ae555..11b48b8a 100644 --- a/lib/screens/Hostel/caretaker/managestudent.dart +++ b/lib/screens/Hostel/caretaker/managestudent.dart @@ -1,5 +1,5 @@ //All the 4 functionalities like add new student,edit existing student details,delete a student,search a student -// by his/her name via search bar are all perfectly working in this code.No need further debugging except to integrate API's. +// by his/her name via search bar are all perfectly working in this code.No need further debugging except to integrate API's from web team. import 'dart:convert'; import 'package:flutter/material.dart'; From 4ac29b6f9e8fd5ad7ac30ddef7ed54174f54bcb0 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:00:40 +0530 Subject: [PATCH 04/11] Update noticeboard.dart Added the Notice Board screen for the Caretaker which is fully functional with option to add/remove notice.Also added sample data in JSON format to see these operations in action. --- lib/screens/Hostel/caretaker/noticeboard.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/Hostel/caretaker/noticeboard.dart b/lib/screens/Hostel/caretaker/noticeboard.dart index 2fe8bb5d..b1e3ac41 100644 --- a/lib/screens/Hostel/caretaker/noticeboard.dart +++ b/lib/screens/Hostel/caretaker/noticeboard.dart @@ -1,4 +1,4 @@ -//All the 2 functionalities like add new notice,remove existing notice are all perfectly +//All the 2 functionalities add new notice,remove existing notice are all perfectly //working in this code with proper formatting.No need further debugging on this code. import 'package:flutter/material.dart'; From e34c99df511b9f6637d1d2fb282d1db6295e2e77 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:03:05 +0530 Subject: [PATCH 05/11] Add files via upload --- .../Hostel/caretaker/complaintregister.dart | 96 ++++ lib/screens/Hostel/caretaker/guestroom.dart | 226 +++++++++ .../Hostel/caretaker/hostel_caretaker.dart | 343 ++++++++++++++ lib/screens/Hostel/caretaker/inventory.dart | 71 +++ .../Hostel/caretaker/leaveapplication.dart | 227 +++++++++ lib/screens/Hostel/caretaker/managefines.dart | 436 ++++++++++++++++++ lib/screens/Hostel/caretaker/managerooms.dart | 293 ++++++++++++ lib/screens/Hostel/caretaker/report.dart | 224 +++++++++ lib/screens/Hostel/caretaker/staffinfo.dart | 66 +++ 9 files changed, 1982 insertions(+) create mode 100644 lib/screens/Hostel/caretaker/complaintregister.dart create mode 100644 lib/screens/Hostel/caretaker/guestroom.dart create mode 100644 lib/screens/Hostel/caretaker/hostel_caretaker.dart create mode 100644 lib/screens/Hostel/caretaker/inventory.dart create mode 100644 lib/screens/Hostel/caretaker/leaveapplication.dart create mode 100644 lib/screens/Hostel/caretaker/managefines.dart create mode 100644 lib/screens/Hostel/caretaker/managerooms.dart create mode 100644 lib/screens/Hostel/caretaker/report.dart create mode 100644 lib/screens/Hostel/caretaker/staffinfo.dart diff --git a/lib/screens/Hostel/caretaker/complaintregister.dart b/lib/screens/Hostel/caretaker/complaintregister.dart new file mode 100644 index 00000000..90bec5c0 --- /dev/null +++ b/lib/screens/Hostel/caretaker/complaintregister.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Complaintregister extends StatelessWidget { + const Complaintregister({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Complaint Register'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Padding( + padding: const EdgeInsets.fromLTRB(20, 30, 20, 0), // Add padding to the body + child: GridView.count( + crossAxisCount: 2, + childAspectRatio: 1.5, // Adjust the aspect ratio to make the cards horizontally rectangular + children: List.generate( + roomNumbers.length, + (index) => InkWell( + onTap: () { + // Navigate to a new screen when the card is tapped + Navigator.push( + context, + MaterialPageRoute(builder: (context) => DetailScreen(roomNumber: roomNumbers[index])), + ); + }, + child: Card( + color: Color.fromARGB(255, 245, 103, 47), + child: Padding( + padding: const EdgeInsets.all(8.0), // Add padding to make the cards compact + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + roomNumbers[index], + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white, // Set the text color to white + ), + ), + Icon(Icons.arrow_forward, color: Colors.white), // Set the arrow color to white + ], + ), + ), + ), + ), + ), + ), + ), + ), + ); + } +} + +class DetailScreen extends StatelessWidget { + final String roomNumber; + + const DetailScreen({Key? key, required this.roomNumber}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Room $roomNumber Details'), + ), + body: Center( + child: Text( + 'Room $roomNumber Details', + style: TextStyle( + color: Colors.white, // Set the text color to white + ), + ), + ), + ); + } +} + +List roomNumbers = [ + '101', + '102', + '103', + '104', + '105', + '106', + '107', + '108', + '109', + '110', +]; diff --git a/lib/screens/Hostel/caretaker/guestroom.dart b/lib/screens/Hostel/caretaker/guestroom.dart new file mode 100644 index 00000000..0d764690 --- /dev/null +++ b/lib/screens/Hostel/caretaker/guestroom.dart @@ -0,0 +1,226 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; +class Guestroom extends StatelessWidget { + const Guestroom({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Guest Room'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Container( + child: Padding( + padding: const EdgeInsets.fromLTRB(20, 40, 20, 20), + child: Container( + width: double.infinity, // Prevent horizontal scrolling + child: Expanded( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + alignment: Alignment.topLeft, + child: const Text( + 'Status', + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + ), + Container( + width: MediaQuery.of(context).size.width - 40, + height: 250, + decoration: BoxDecoration( + color: Color.fromARGB( + 255, 245, 103, 47), // Change to orange color + borderRadius: BorderRadius.circular(8), + ), + padding: const EdgeInsets.all(8), + margin: const EdgeInsets.symmetric(vertical: 4), + child: const Text( + '', + style: TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + Container( + alignment: Alignment.topLeft, + padding: const EdgeInsets.only(top: 30, bottom: 10), + child: const Text( + 'Guest Room 1', + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + ), + Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment + .center, // Align vertically center + children: [ + Column( + children: [ + Container( + width: MediaQuery.of(context).size.width - 40, + height: 70, // Set the height to 30px + padding: const EdgeInsets.only(top: 10, bottom: 10), + child: ElevatedButton( + onPressed: () { + // View Documents + }, + child: const Text('View Documents', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Color.fromARGB(255, 245, 103, 47), // Add background color + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + + ), + ), + ), + Container( + child: Row( + children: [ + ElevatedButton.icon( + onPressed: () { + // Approve + }, + icon: Icon(Icons.check, color: Colors.white), + label: const Text('Approve', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + SizedBox(width: 10), + ElevatedButton.icon( + onPressed: () { + // Cancel + }, + icon: Icon(Icons.close, color: Colors.white), + label: const Text('Cancel', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + Container( + alignment: Alignment.topLeft, + padding: const EdgeInsets.only(top: 30, bottom: 10), + child: const Text( + 'Guest Room 2', + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + ), + Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment + .center, // Align vertically center + children: [ + Column( + children: [ + Container( + width: MediaQuery.of(context).size.width - 40, + height: 70, // Set the height to 30px + padding: const EdgeInsets.only(top: 10, bottom: 10), + child: ElevatedButton( + onPressed: () { + // View Documents + }, + child: const Text('View Documents', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Color.fromARGB(255, 245, 103, 47), // Add background color + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + + ), + ), + ), + Container( + child: Row( + children: [ + ElevatedButton.icon( + onPressed: () { + // Approve + }, + icon: Icon(Icons.check, color: Colors.white), + label: const Text('Approve', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + SizedBox(width: 10), + ElevatedButton.icon( + onPressed: () { + // Cancel + }, + icon: Icon(Icons.close, color: Colors.white), + label: const Text('Cancel', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/screens/Hostel/caretaker/hostel_caretaker.dart b/lib/screens/Hostel/caretaker/hostel_caretaker.dart new file mode 100644 index 00000000..72a73f02 --- /dev/null +++ b/lib/screens/Hostel/caretaker/hostel_caretaker.dart @@ -0,0 +1,343 @@ +import 'package:flutter/material.dart'; +// import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/Hostel/caretaker/guestroom.dart'; +import 'package:fusion/screens/Hostel/caretaker/inventory.dart'; +import 'package:fusion/screens/Hostel/caretaker/managefines.dart'; +import 'package:fusion/screens/Hostel/caretaker/managerooms.dart'; +import 'package:fusion/screens/Hostel/caretaker/leaveapplication.dart'; +import 'package:fusion/screens/Hostel/caretaker/staffinfo.dart'; +import 'package:fusion/screens/Hostel/caretaker/managestudent.dart'; +import 'package:fusion/screens/Hostel/caretaker/noticeboard.dart'; +import 'package:fusion/screens/Hostel/caretaker/report.dart'; +import 'package:fusion/screens/Hostel/caretaker/complaintregister.dart'; + +class HostelHomepage extends StatelessWidget { + const HostelHomepage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Hostel'), + 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) => Guestroom()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.add_home, + color: Colors.white, + size: 30, + ), + Text( + 'Guest Room', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Staffinfo()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.person, + color: Colors.white, + size: 30, + ), + Text( + 'Staff Info', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Managerooms()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.home, + color: Colors.white, + size: 30, + ), + Text( + 'Manage Rooms', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Managefines()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.monetization_on, + color: Colors.white, + size: 30, + ), + Text( + 'Manage Fines', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Report()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.report, + color: Colors.white, + size: 30, + ), + Text( + 'Report', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Leaveapplication()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.card_travel, + color: Colors.white, + size: 30, + ), + Text( + 'Leave', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Application', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Complaintregister()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.report_problem_rounded, + color: Colors.white, + size: 30, + ), + Text( + 'Complaint', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Register', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Managestudent()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.school, + color: Colors.white, + size: 30, + ), + Text( + 'Manage', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Student', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Noticeboard()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.dashboard, + color: Colors.white, + size: 30, + ), + Text( + 'Notice Board', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Inventory()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.inventory, + color: Colors.white, + size: 30, + ), + Text( + 'Inventory', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + ]), + ), + ), + ); + } +} diff --git a/lib/screens/Hostel/caretaker/inventory.dart b/lib/screens/Hostel/caretaker/inventory.dart new file mode 100644 index 00000000..8358b8c3 --- /dev/null +++ b/lib/screens/Hostel/caretaker/inventory.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Inventory extends StatelessWidget { + const Inventory({ Key? key }) : super(key: key); + + @override + Widget build(BuildContext context){ + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Inventory'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), // Set the background color to orange + foregroundColor: Colors.white, + ), + body: Padding( + padding: const EdgeInsets.only(top: 30, left: 20, right: 20, bottom: 30), + child: Column( + children: [ + Text( + 'Inventory Amount: \$1000', // Replace with actual inventory amount + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 245, 103, 47)), + ), + SizedBox(height: 16), + Text( + 'Expense History:', // Replace with actual expense history + style: TextStyle(fontSize: 18), + ), + Expanded( + child: ListView( + children: [ + ListTile( + title: Text('Expense 1'), // Replace with actual expense details + ), + ListTile( + title: Text('Expense 2'), // Replace with actual expense details + ), + // Add more ListTiles for additional expenses + ], + ), + ), + Padding( + padding: const EdgeInsets.only(top: 10), + child: ElevatedButton( + onPressed: () { + // Add logic to create a new expense + }, + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: Color.fromARGB(255, 245, 103, 47), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: BorderSide( + color: Color.fromARGB(255, 245, 103, 47), + width: 2, + ), + ), + ), + child: Text( + 'Create New Expense', + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/Hostel/caretaker/leaveapplication.dart b/lib/screens/Hostel/caretaker/leaveapplication.dart new file mode 100644 index 00000000..c1c71542 --- /dev/null +++ b/lib/screens/Hostel/caretaker/leaveapplication.dart @@ -0,0 +1,227 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Leaveapplication extends StatelessWidget { + const Leaveapplication({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Leave Application'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Container( + child: Padding( + padding: const EdgeInsets.fromLTRB(20, 40, 20, 20), + child: Container( + width: double.infinity, // Prevent horizontal scrolling + child: Expanded( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + alignment: Alignment.topLeft, + child: const Text( + 'Status', + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + ), + Container( + width: MediaQuery.of(context).size.width - 40, + height: 250, + decoration: BoxDecoration( + color: Color.fromARGB( + 255, 245, 103, 47), // Change to orange color + borderRadius: BorderRadius.circular(8), + ), + padding: const EdgeInsets.all(8), + margin: const EdgeInsets.symmetric(vertical: 4), + child: const Text( + '', + style: TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + Container( + alignment: Alignment.topLeft, + padding: const EdgeInsets.only(top: 30, bottom: 10), + child: const Text( + '21bcs198', + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + ), + Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment + .center, // Align vertically center + children: [ + Column( + children: [ + Container( + width: MediaQuery.of(context).size.width - 40, + height: 70, // Set the height to 30px + padding: const EdgeInsets.only(top: 10, bottom: 10), + child: ElevatedButton( + onPressed: () { + // Leave Form + }, + child: const Text('Leave Form', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Color.fromARGB(255, 245, 103, 47), // Add background color + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + + ), + ), + ), + Container( + child: Row( + children: [ + ElevatedButton.icon( + onPressed: () { + // Approve + }, + icon: Icon(Icons.check, color: Colors.white), + label: const Text('Approve', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + SizedBox(width: 10), + ElevatedButton.icon( + onPressed: () { + // Cancel + }, + icon: Icon(Icons.close, color: Colors.white), + label: const Text('Cancel', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + Container( + alignment: Alignment.topLeft, + padding: const EdgeInsets.only(top: 30, bottom: 10), + child: const Text( + '21bcs199', + style: TextStyle( + fontSize: 23, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + ), + Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment + .center, // Align vertically center + children: [ + Column( + children: [ + Container( + width: MediaQuery.of(context).size.width - 40, + height: 70, // Set the height to 30px + padding: const EdgeInsets.only(top: 10, bottom: 10), + child: ElevatedButton( + onPressed: () { + // Leave Form + }, + child: const Text('Leave Form', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Color.fromARGB(255, 245, 103, 47), // Add background color + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + + ), + ), + ), + Container( + child: Row( + children: [ + ElevatedButton.icon( + onPressed: () { + // Approve + }, + icon: Icon(Icons.check, color: Colors.white), + label: const Text('Approve', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + SizedBox(width: 10), + ElevatedButton.icon( + onPressed: () { + // Cancel + }, + icon: Icon(Icons.close, color: Colors.white), + label: const Text('Cancel', style: TextStyle(color: Colors.white)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), // Set border radius to 5px + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/screens/Hostel/caretaker/managefines.dart b/lib/screens/Hostel/caretaker/managefines.dart new file mode 100644 index 00000000..33ffd727 --- /dev/null +++ b/lib/screens/Hostel/caretaker/managefines.dart @@ -0,0 +1,436 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; + +class Student { + late final String name; + late final String rollNo; + late final double fineAmount; + late final String reason; + late final String description; + + Student({ + required this.name, + required this.rollNo, + required this.fineAmount, + required this.reason, + required this.description, + }); +} + +class Managefines extends StatefulWidget { + const Managefines({Key? key}) : super(key: key); + + @override + _ManagefinesState createState() => _ManagefinesState(); +} + +class _ManagefinesState extends State { + List students = []; + List filteredStudents = []; + + @override + void initState() { + super.initState(); + _fetchFines(); + } + + Future _fetchFines() async { + // Simulating API call to fetch fines + final String finesData = ''' + [ + {"name": "Raju", "rollNo": "21bcs001", "fineAmount": 50.0, "reason": "Late Entry", "description": "Late by 15 minutes"}, + {"name": "Keerthan", "rollNo": "21bme002", "fineAmount": 30.0, "reason": "Hostel Damage", "description": "Broken window glass"}, + {"name": "Aravind", "rollNo": "21bcs003", "fineAmount": 20.0, "reason": "Misbehaviour", "description": "Argument with warden"} + ] + '''; + final List finesList = json.decode(finesData); + setState(() { + students = finesList.map((fine) => Student( + name: fine['name'], + rollNo: fine['rollNo'], + fineAmount: fine['fineAmount'], + reason: fine['reason'], + description: fine['description'], + )).toList(); + filteredStudents = List.from(students); + }); + } + + Future _editFineDetails(Student student) async { + // Display dialog to edit fine details + showDialog( + context: context, + builder: (BuildContext context) { + double fineAmount = student.fineAmount; + String reason = student.reason; + String description = student.description; + + return AlertDialog( + title: Text('Edit Fine Details'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration(labelText: 'Fine Amount'), + controller: TextEditingController(text: fineAmount.toString()), + onChanged: (value) { + fineAmount = double.tryParse(value) ?? 0.0; + }, + ), + Text('Reason'), + DropdownButtonFormField( + value: reason, + onChanged: (value) { + setState(() { + reason = value!; + }); + }, + items: ['Late Entry', 'Hostel Damage', 'Misbehaviour', 'Others'] + .map>( + (String value) => DropdownMenuItem( + value: value, + child: Text(value), + ), + ) + .toList(), + ), + TextField( + decoration: InputDecoration(labelText: 'Description'), + controller: TextEditingController(text: description), + onChanged: (value) { + description = value; + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the edit operation here + setState(() { + // Find the index of the student in the list + int index = students.indexWhere((s) => s.rollNo == student.rollNo); + if (index != -1) { + // Update the properties of the student object directly + students[index].fineAmount = fineAmount; + students[index].reason = reason; + students[index].description = description; + // Update the filteredStudents list as well + int filteredIndex = filteredStudents.indexWhere((s) => s.rollNo == student.rollNo); + if (filteredIndex != -1) { + filteredStudents[filteredIndex].fineAmount = fineAmount; + filteredStudents[filteredIndex].reason = reason; + filteredStudents[filteredIndex].description = description; + } + } + }); + // Simulate PUT API call to update fine details + // _updateFineDetails(student); + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + + Future _deleteFineDetails(Student student) async { + // Show confirmation dialog before deleting the fine + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Confirm Deletion'), + content: Text('Are you sure you want to delete this fine?'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Delete the fine + _deleteFine(student); + Navigator.of(context).pop(); + }, + child: Text('Delete'), + ), + ], + ); + }, + ); + } + + void _deleteFine(Student student) { + setState(() { + students.remove(student); + filteredStudents.remove(student); + }); + // Simulate DELETE API call to delete fine details + // _invokeDeleteAPI(student.rollNo); + } + + Future _showAddDialog() async { + String name = ''; + String rollNo = ''; + double fineAmount = 0.0; + String reason = 'Late Entry'; + String description = ''; + + await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Add New Fine'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration(labelText: 'Name'), + onChanged: (value) { + name = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Roll No'), + onChanged: (value) { + rollNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Fine Amount'), + onChanged: (value) { + fineAmount = double.tryParse(value) ?? 0.0; + }, + ), + DropdownButtonFormField( + value: reason, + onChanged: (value) { + setState(() { + reason = value!; + }); + }, + items: ['Late Entry', 'Hostel Damage', 'Misbehaviour', 'Others'] + .map>( + (String value) => DropdownMenuItem( + value: value, + child: Text(value), + ), + ) + .toList(), + ), + TextField( + decoration: InputDecoration(labelText: 'Description'), + onChanged: (value) { + description = value; + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the add operation here + setState(() { + final newFine = Student( + name: name, + rollNo: rollNo, + fineAmount: fineAmount, + reason: reason, + description: description, + ); + students.add(newFine); + filteredStudents.add(newFine); + }); + // Simulate POST API call to add new fine details + // _addFineDetails(name, rollNo, fineAmount, reason, description); + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + void _searchFines(String query) { + setState(() { + if (query.isNotEmpty) { + filteredStudents = students.where((student) { + return student.name.toLowerCase().contains(query.toLowerCase()) || + student.rollNo.toLowerCase().contains(query.toLowerCase()); + }).toList(); + } else { + filteredStudents = List.from(students); + } + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Manage Fines'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () async { + final String? result = await showSearch( + context: context, + delegate: FineSearchDelegate(students: students), + ); + if (result != null) { + _searchFines(result); + } + }, + ), + ], + ), + body: SingleChildScrollView( + child: DataTable( + columns: const [ + DataColumn(label: Text('Name')), + DataColumn(label: Text('Roll No')), + DataColumn(label: Text('Fine Amount')), + DataColumn(label: Text('Reason')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Edit')), + DataColumn(label: Text('Remove')), + ], + rows: List.generate( + filteredStudents.length, + (index) => DataRow( + cells: [ + DataCell(Text(filteredStudents[index].name)), + DataCell(Text(filteredStudents[index].rollNo)), + DataCell(Text('₹${filteredStudents[index].fineAmount.toString()}')), + DataCell(Text(filteredStudents[index].reason)), + DataCell(Text(filteredStudents[index].description)), + DataCell( + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + _editFineDetails(filteredStudents[index]); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.delete), + onPressed: () { + _deleteFineDetails(filteredStudents[index]); + }, + ), + ), + ], + ), + ), + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _showAddDialog, + child: Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + ), + ); + } +} + +class FineSearchDelegate extends SearchDelegate { + final List students; + + FineSearchDelegate({required this.students}); + + @override + ThemeData appBarTheme(BuildContext context) { + final ThemeData theme = Theme.of(context); + return theme.copyWith( + appBarTheme: AppBarTheme( + backgroundColor: theme.scaffoldBackgroundColor, // Match with screen's UI theme + iconTheme: IconThemeData(color: theme.primaryColor), // Match with screen's UI theme + ), + ); + } + + @override + List buildActions(BuildContext context) { + return [ + + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + query = ''; + }, + ), + ]; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, ''); // Pass an empty string as a result to indicate closing the search screen + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + return _buildSearchResults(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + return _buildSearchResults(context); + } + + Widget _buildSearchResults(BuildContext context) { + final List filteredStudents = students.where((student) { + final String lowercaseQuery = query.toLowerCase(); + return student.name.toLowerCase().contains(lowercaseQuery) || + student.rollNo.toLowerCase().contains(lowercaseQuery); + }).toList(); + return ListView.builder( + itemCount: filteredStudents.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(filteredStudents[index].name), + subtitle: Text(filteredStudents[index].rollNo), + onTap: () { + close(context, filteredStudents[index].rollNo); + }, + ); + }, + ); + } +} + +void main() { + runApp(MaterialApp( + home: Managefines(), + )); +} diff --git a/lib/screens/Hostel/caretaker/managerooms.dart b/lib/screens/Hostel/caretaker/managerooms.dart new file mode 100644 index 00000000..9d149eb5 --- /dev/null +++ b/lib/screens/Hostel/caretaker/managerooms.dart @@ -0,0 +1,293 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; + +class Room { + final int roomNumber; + final int capacity; + final int currentOccupancy; + final String status; + final List studentNames; + final int numberOfStudents; + + Room({ + required this.roomNumber, + required this.capacity, + required this.currentOccupancy, + required this.status, + required this.studentNames, + required this.numberOfStudents, + }); +} + +class Managerooms extends StatefulWidget { + const Managerooms({Key? key}) : super(key: key); + + @override + _ManageroomsState createState() => _ManageroomsState(); +} + +class _ManageroomsState extends State { + List rooms = []; + List filteredRooms = []; + + @override + void initState() { + super.initState(); + _fetchRoomDetails(); + } + + Future _fetchRoomDetails() async { + // Simulating GET API call to fetch room details + final String roomData = ''' + [ + {"roomNumber": 101, "capacity": 2, "currentOccupancy": 1, "status": "Partially Allotted", "studentNames": ["John Doe"], "numberOfStudents": 1}, + {"roomNumber": 102, "capacity": 3, "currentOccupancy": 2, "status": "Fully Allotted", "studentNames": ["Alice", "Bob"], "numberOfStudents": 2}, + {"roomNumber": 103, "capacity": 4, "currentOccupancy": 4, "status": "Fully Allotted", "studentNames": ["Charlie", "David", "Eve", "Frank"], "numberOfStudents": 4}, + ] + '''; + final List roomList = json.decode(roomData); + setState(() { + rooms = roomList.map((room) => Room( + roomNumber: room['roomNumber'], + capacity: room['capacity'], + currentOccupancy: room['currentOccupancy'], + status: room['status'], + studentNames: List.from(room['studentNames']), + numberOfStudents: room['numberOfStudents'], + )).toList(); + filteredRooms = List.from(rooms); + }); + } + + Future _editStudentDetails(Room room) async { + // Display dialog to edit student details + showDialog( + context: context, + builder: (BuildContext context) { + // Implement the edit room details dialog + return AlertDialog( + title: Text('Edit Student Details'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Add fields to edit student details + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the edit operation here + // Update the room details + // Simulate POST API call to update room details + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + Future _deleteStudentDetails(Room room) async { + // Show confirmation dialog before deleting the student + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Confirm Deletion'), + content: Text('Are you sure you want to delete the student?'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Delete the student from the room + _deleteStudent(room); + Navigator.of(context).pop(); + }, + child: Text('Delete'), + ), + ], + ); + }, + ); + } + + void _deleteStudent(Room room) { + setState(() { + // Implement logic to delete the student from the room + }); + // Simulate DELETE API call to delete student details + } + + Future _showAddDialog() async { + // Implement add student to room dialog + } + + void _searchRooms(int roomNumber) { + setState(() { + if (roomNumber != 0) { + filteredRooms = rooms.where((room) => room.roomNumber == roomNumber).toList(); + } else { + filteredRooms.clear(); // Clear filtered list if no search is active + filteredRooms.addAll(rooms); // Repopulate with all rooms + } + }); + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Manage Rooms'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () async { + final int? result = await showSearch( + context: context, + delegate: RoomSearchDelegate(rooms: rooms), + ); + if (result != null) { + _searchRooms(result); + } + }, + ), + ], + ), + body: SingleChildScrollView( + child: DataTable( + columns: const [ + DataColumn(label: Text('Room No')), + DataColumn(label: Text('Capacity')), + DataColumn(label: Text('Current Occupancy')), + DataColumn(label: Text('Status')), + DataColumn(label: Text('Student Names')), + DataColumn(label: Text('No of Students')), + DataColumn(label: Text('Edit')), + DataColumn(label: Text('Delete')), + DataColumn(label: Text('Add')), + ], + rows: filteredRooms.map((room) { + return DataRow(cells: [ + DataCell(Text(room.roomNumber.toString())), + DataCell(Text(room.capacity.toString())), + DataCell(Text(room.currentOccupancy.toString())), + DataCell(Text(room.status)), + DataCell(Text(room.studentNames.join(', '))), + DataCell(Text(room.numberOfStudents.toString())), + DataCell( + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + _editStudentDetails(room); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.delete), + onPressed: () { + _deleteStudentDetails(room); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.add), + onPressed: () { + _showAddDialog(); + }, + ), + ), + ]); + }).toList(), + ), + ), + ); + } +} + +class RoomSearchDelegate extends SearchDelegate { + final List rooms; + + RoomSearchDelegate({required this.rooms}); + + @override + ThemeData appBarTheme(BuildContext context) { + final ThemeData theme = Theme.of(context); + return theme.copyWith( + appBarTheme: AppBarTheme( + backgroundColor: theme.scaffoldBackgroundColor, // Match with screen's UI theme + iconTheme: IconThemeData(color: theme.primaryColor), // Match with screen's UI theme + ), + ); + } + + @override + List buildActions(BuildContext context) { + return [ + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + query = ''; + }, + ), + ]; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, null); + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + return _buildSearchResults(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + return _buildSearchResults(context); + } + + Widget _buildSearchResults(BuildContext context) { + return ListView.builder( + itemCount: rooms.length, + itemBuilder: (context, index) { + return ListTile( + title: Text('Room No: ${rooms[index].roomNumber}'), + onTap: () { + close(context, rooms[index].roomNumber); + }, + ); + }, + ); + } +} + +void main() { + runApp(MaterialApp( + home: Managerooms(), + )); +} diff --git a/lib/screens/Hostel/caretaker/report.dart b/lib/screens/Hostel/caretaker/report.dart new file mode 100644 index 00000000..db8a7a89 --- /dev/null +++ b/lib/screens/Hostel/caretaker/report.dart @@ -0,0 +1,224 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Student { + final String name; + final int rollNumber; + bool isPresent; + + Student({ + required this.name, + required this.rollNumber, + this.isPresent = false, + }); +} + +class Report extends StatefulWidget { + const Report({Key? key}) : super(key: key); + + @override + _ReportState createState() => _ReportState(); +} + +class _ReportState extends State { + late DateTime selectedDate; + late List students; + late List filteredStudents; + + @override + void initState() { + super.initState(); + selectedDate = DateTime.now(); + _fetchStudentDetails(); + } + + Future _fetchStudentDetails() async { + // Simulating fetching student data from an API + final String studentData = ''' + [ + {"name": "John Doe", "rollNumber": 101}, + {"name": "Alice Smith", "rollNumber": 102}, + {"name": "Bob Johnson", "rollNumber": 103} + ] + '''; + final List studentList = json.decode(studentData); + setState(() { + students = studentList.map((student) => Student( + name: student['name'], + rollNumber: student['rollNumber'], + )).toList(); + filteredStudents = List.from(students); + }); + } + + void _searchStudents(String query) { + setState(() { + if (query.isEmpty) { + filteredStudents = List.from(students); + } else { + filteredStudents = students + .where((student) => + student.name.toLowerCase().contains(query.toLowerCase()) || + student.rollNumber.toString().contains(query)) + .toList(); + } + }); + } + + Future _selectDate(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(2000), + lastDate: DateTime.now(), + selectableDayPredicate: (DateTime date) { + // Allow only past dates to be selected + return date.isBefore(DateTime.now()); + }, + ); + if (picked != null && picked != selectedDate) { + setState(() { + selectedDate = picked; + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Report'), + ), + body: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + Expanded( + child: TextButton( + onPressed: () => _selectDate(context), + child: Text( + 'Selected Date: ${selectedDate.year}-${selectedDate.month}-${selectedDate.day}', + style: TextStyle(fontSize: 16), + ), + ), + ), + IconButton( + icon: Icon(Icons.search), + onPressed: () { + showSearch( + context: context, + delegate: StudentSearchDelegate(students: students), + ); + }, + ), + ], + ), + ), + Expanded( + child: ListView.builder( + itemCount: filteredStudents.length, + itemBuilder: (context, index) { + return ListTile( + title: Text( + filteredStudents[index].name, + style: TextStyle(fontSize: 18), + ), + subtitle: Text( + 'Roll No: ${filteredStudents[index].rollNumber}', + style: TextStyle(fontSize: 14), + ), + trailing: IconButton( + icon: filteredStudents[index].isPresent + ? Icon(Icons.check_circle, color: Colors.green) + : Icon(Icons.cancel, color: Colors.red), + onPressed: () { + setState(() { + filteredStudents[index].isPresent = + !filteredStudents[index].isPresent; + }); + }, + ), + ); + }, + ), + ), + ], + ), + ); + } +} + +class StudentSearchDelegate extends SearchDelegate { + final List students; + + StudentSearchDelegate({required this.students}); + + @override + ThemeData appBarTheme(BuildContext context) { + final ThemeData theme = Theme.of(context); + return theme.copyWith( + appBarTheme: AppBarTheme( + backgroundColor: theme.scaffoldBackgroundColor, + iconTheme: IconThemeData(color: theme.primaryColor), + ), + ); + } + + @override + List buildActions(BuildContext context) { + return [ + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + query = ''; + }, + ), + ]; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, null); + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + return _buildSearchResults(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + return _buildSearchResults(context); + } + + Widget _buildSearchResults(BuildContext context) { + return ListView.builder( + itemCount: students.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(students[index].name), + subtitle: Text('Roll No: ${students[index].rollNumber}'), + onTap: () { + close(context, students[index]); + }, + ); + }, + ); + } +} + +void main() { + runApp(MaterialApp( + home: Report(), + )); +} diff --git a/lib/screens/Hostel/caretaker/staffinfo.dart b/lib/screens/Hostel/caretaker/staffinfo.dart new file mode 100644 index 00000000..49caf93a --- /dev/null +++ b/lib/screens/Hostel/caretaker/staffinfo.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Staffinfo extends StatelessWidget { + const Staffinfo({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Staff Info'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Padding( + padding: EdgeInsets.only(left: 20, right: 20, top: 50), + child: SingleChildScrollView( + child: Center( + child: Column( + children: [ + for (int i = 1; i < 15; i++) + Card( + color: Color.fromARGB(255, 245, 103, 47), + child: ListTile( + title: Row( + children: [ + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Staff $i', + style: TextStyle( + color: Colors.white, + fontSize: 20, + ), + ), + Icon( + Icons.arrow_forward_ios, + color: Colors.white, + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + // Add new staff info logic here + }, + child: Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 255, 152, 111), + foregroundColor: Color(0xffffffff), + ), + ); + } +} From f2e17cdb31fd9b50ed697e05236e556f702663eb Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:16:45 +0530 Subject: [PATCH 06/11] Create demo.txt --- lib/screens/Hostel/demo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 lib/screens/Hostel/demo.txt diff --git a/lib/screens/Hostel/demo.txt b/lib/screens/Hostel/demo.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/lib/screens/Hostel/demo.txt @@ -0,0 +1 @@ + From a5f68824b579e59ccf25db7f8f3ffaedca789415 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:18:51 +0530 Subject: [PATCH 07/11] Create managestudent.dart --- lib/screens/Hostel/warden/managestudent.dart | 509 +++++++++++++++++++ 1 file changed, 509 insertions(+) create mode 100644 lib/screens/Hostel/warden/managestudent.dart diff --git a/lib/screens/Hostel/warden/managestudent.dart b/lib/screens/Hostel/warden/managestudent.dart new file mode 100644 index 00000000..285ae555 --- /dev/null +++ b/lib/screens/Hostel/warden/managestudent.dart @@ -0,0 +1,509 @@ +//All the 4 functionalities like add new student,edit existing student details,delete a student,search a student +// by his/her name via search bar are all perfectly working in this code.No need further debugging except to integrate API's. + +import 'dart:convert'; +import 'package:flutter/material.dart'; + + + +class Student { + final String rollNo; + String name; + int batch; + String program; + String specialization; + String hallNo; + String roomNo; + String contactNo; + String address; + + Student({ + required this.rollNo, + required this.name, + required this.batch, + required this.program, + required this.specialization, + required this.hallNo, + required this.roomNo, + required this.contactNo, + required this.address, + }); +} + +class Managestudent extends StatefulWidget { + const Managestudent({Key? key}) : super(key: key); + + @override + _ManagestudentState createState() => _ManagestudentState(); +} + +class _ManagestudentState extends State { + List students = []; + List filteredStudents = []; + + @override + void initState() { + super.initState(); + _fetchStudentDetails(); + } + + Future _fetchStudentDetails() async { + // Simulating GET API call to fetch student details + final String studentData = ''' + [ + {"rollNo": "21bcs001", "name": "Rahul", "batch": 2021, "program": "B.Tech", "specialization": "CSE", "hallNo": "Hall-4", "roomNo": "G-31", "contactNo": "+911234567890", "address": "Address 1, City 1, State 1, Country 1"}, + {"rollNo": "21bme002", "name": "Kiran", "batch": 2021, "program": "B.Tech", "specialization": "MEE", "hallNo": "Hall-4", "roomNo": "F-24", "contactNo": "+919876543210", "address": "Address 2, City 2, State 2, Country 2"}, + {"rollNo": "21bcs003", "name": "Amit", "batch": 2021, "program": "B.Tech", "specialization": "CSE", "hallNo": "Hall-4", "roomNo": "S-12", "contactNo": "+914561237890", "address": "Address 3, City 3, State 3, Country 3"}, + {"rollNo": "21sm004", "name": "Kunal", "batch": 2021, "program": "B.Tech", "specialization": "SM", "hallNo": "Hall-4", "roomNo": "G-31", "contactNo": "+911234567890", "address": "Address 4, City 4, State 4, Country 4"}, + {"rollNo": "21bcs005", "name": "Vishal", "batch": 2021, "program": "B.Tech", "specialization": "CSE", "hallNo": "Hall-4", "roomNo": "F-24", "contactNo": "+919876543210", "address": "Address 5, City 5, State 5, Country 5"}, + {"rollNo": "23me116", "name": "Divyanshu", "batch": 2023, "program": "B.Tech", "specialization": "ME", "hallNo": "Hall-4", "roomNo": "S-12", "contactNo": "+914561237890", "address": "Address 6, City 6, State 6, Country 6"}, + {"rollNo": "23bec117", "name": "Raj", "batch": 2023, "program": "B.Tech", "specialization": "ECE", "hallNo": "Hall-4", "roomNo": "G-31", "contactNo": "+911234567890", "address": "Address 7, City 7, State 7, Country 7"}, + {"rollNo": "23bds118", "name": "Anurag", "batch": 2023, "program": "B.Des", "specialization": "DS", "hallNo": "Hall-4", "roomNo": "F-24", "contactNo": "+919876543210", "address": "Address 8, City 8, State 8, Country 8"} + ] + '''; + final List studentList = json.decode(studentData); + setState(() { + students = studentList.map((student) => Student( + rollNo: student['rollNo'], + name: student['name'], + batch: student['batch'], + program: student['program'], + specialization: student['specialization'], + hallNo: student['hallNo'], + roomNo: student['roomNo'], + contactNo: student['contactNo'], + address: student['address'], + )).toList(); + filteredStudents = List.from(students); + }); + } + + Future _editStudentDetails(Student student) async { + // Display dialog to edit student details + showDialog( + context: context, + builder: (BuildContext context) { + String name = student.name; + int batch = student.batch; + String program = student.program; + String specialization = student.specialization; + String hallNo = student.hallNo; + String roomNo = student.roomNo; + String contactNo = student.contactNo; + String address = student.address; + + return AlertDialog( + title: Text('Edit Student Details'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration(labelText: 'Name'), + controller: TextEditingController(text: name), + onChanged: (value) { + name = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Batch'), + controller: TextEditingController(text: batch.toString()), + onChanged: (value) { + batch = int.tryParse(value) ?? 0; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Program'), + controller: TextEditingController(text: program), + onChanged: (value) { + program = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Specialization'), + controller: TextEditingController(text: specialization), + onChanged: (value) { + specialization = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Hall No'), + controller: TextEditingController(text: hallNo), + onChanged: (value) { + hallNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Room No'), + controller: TextEditingController(text: roomNo), + onChanged: (value) { + roomNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Contact No'), + controller: TextEditingController(text: contactNo), + onChanged: (value) { + contactNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Address'), + controller: TextEditingController(text: address), + onChanged: (value) { + address = value; + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the edit operation here + setState(() { + student.name = name; + student.batch = batch; + student.program = program; + student.specialization = specialization; + student.hallNo = hallNo; + student.roomNo = roomNo; + student.contactNo = contactNo; + student.address = address; + }); + // Simulate POST API call to update student details + // _updateStudentDetails(student); + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + Future _deleteStudentDetails(Student student) async { + // Show confirmation dialog before deleting the student + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Confirm Deletion'), + content: Text('Are you sure you want to delete this student?'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Delete the student + _deleteStudent(student); + Navigator.of(context).pop(); + }, + child: Text('Delete'), + ), + ], + ); + }, + ); + } + + void _deleteStudent(Student student) { + setState(() { + students.remove(student); + filteredStudents.remove(student); + }); + // Simulate DELETE API call to delete student details + // _invokeDeleteAPI(student.rollNo); + } + + Future _showAddDialog() async { + String rollNo = ''; + String name = ''; + int batch = 0; + String program = ''; + String specialization = ''; + String hallNo = ''; + String roomNo = ''; + String contactNo = ''; + String address = ''; + + await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Add New Student'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration(labelText: 'Roll No'), + onChanged: (value) { + rollNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Name'), + onChanged: (value) { + name = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Batch'), + onChanged: (value) { + batch = int.tryParse(value) ?? 0; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Program'), + onChanged: (value) { + program = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Specialization'), + onChanged: (value) { + specialization = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Hall No'), + onChanged: (value) { + hallNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Room No'), + onChanged: (value) { + roomNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Contact No'), + onChanged: (value) { + contactNo = value; + }, + ), + TextField( + decoration: InputDecoration(labelText: 'Address'), + onChanged: (value) { + address = value; + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the add operation here + setState(() { + final newStudent = Student( + rollNo: rollNo, + name: name, + batch: batch, + program: program, + specialization: specialization, + hallNo: hallNo, + roomNo: roomNo, + contactNo: contactNo, + address: address, + ); + students.add(newStudent); + filteredStudents.add(newStudent); + }); + // Simulate POST API call to add new student details + // _addStudentDetails(rollNo, name, batch, program, specialization, hallNo, roomNo, contactNo, address); + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + void _searchStudents(String query) { + setState(() { + if (query.isNotEmpty) { + filteredStudents = students.where((student) { + return student.rollNo.contains(query) || student.name.contains(query); + }).toList(); + } else { + filteredStudents = List.from(students); + } + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Manage Students'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () async { + final String? result = await showSearch( + context: context, + delegate: StudentSearchDelegate(students: students), + ); + if (result != null) { + _searchStudents(result); + } + }, + ), + ], + ), + body: SingleChildScrollView( + child: DataTable( + columns: const [ + DataColumn(label: Text('Roll No')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Batch')), + DataColumn(label: Text('Program')), + DataColumn(label: Text('Specialization')), + DataColumn(label: Text('Hall No')), + DataColumn(label: Text('Room No')), + DataColumn(label: Text('Contact No')), + DataColumn(label: Text('Address')), + DataColumn(label: Text('Edit')), + DataColumn(label: Text('Remove')), + ], + rows: List.generate( + filteredStudents.length, + (index) => DataRow( + cells: [ + DataCell(Text(filteredStudents[index].rollNo)), + DataCell(Text(filteredStudents[index].name)), + DataCell(Text(filteredStudents[index].batch.toString())), + DataCell(Text(filteredStudents[index].program)), + DataCell(Text(filteredStudents[index].specialization)), + DataCell(Text(filteredStudents[index].hallNo)), + DataCell(Text(filteredStudents[index].roomNo)), + DataCell(Text(filteredStudents[index].contactNo)), + DataCell(Text(filteredStudents[index].address)), + DataCell( + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + _editStudentDetails(filteredStudents[index]); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.delete), + onPressed: () { + _deleteStudentDetails(filteredStudents[index]); + }, + ), + ), + ], + ), + ), + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _showAddDialog, + child: Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + ), + ); + } +} + +class StudentSearchDelegate extends SearchDelegate { + final List students; + + StudentSearchDelegate({required this.students}); + + @override + ThemeData appBarTheme(BuildContext context) { + final ThemeData theme = Theme.of(context); + return theme.copyWith( + appBarTheme: AppBarTheme( + backgroundColor: theme.scaffoldBackgroundColor, // Match with screen's UI theme + iconTheme: IconThemeData(color: theme.primaryColor), // Match with screen's UI theme + ), + ); + } + + @override + List buildActions(BuildContext context) { + return [ + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + query = ''; + }, + ), + ]; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, null); + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + return _buildSearchResults(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + return _buildSearchResults(context); + } + + Widget _buildSearchResults(BuildContext context) { + final List filteredStudents = students.where((student) { + final String lowercaseQuery = query.toLowerCase(); + return student.rollNo.toLowerCase().contains(lowercaseQuery) || student.name.toLowerCase().contains(lowercaseQuery); + }).toList(); + return ListView.builder( + itemCount: filteredStudents.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(filteredStudents[index].name), + subtitle: Text(filteredStudents[index].rollNo), + onTap: () { + close(context, filteredStudents[index].rollNo); + }, + ); + }, + ); + } +} + + + +void main() { + runApp(MaterialApp( + home: Managestudent(), + )); +} From bc5ff0e6317f0c733a4831243422b3acf21d9a87 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:21:44 +0530 Subject: [PATCH 08/11] Update managestudent.dart Both caretaker and warden have same "managestudent " functionalities --- lib/screens/Hostel/warden/managestudent.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/Hostel/warden/managestudent.dart b/lib/screens/Hostel/warden/managestudent.dart index 285ae555..35dff3f3 100644 --- a/lib/screens/Hostel/warden/managestudent.dart +++ b/lib/screens/Hostel/warden/managestudent.dart @@ -1,5 +1,5 @@ //All the 4 functionalities like add new student,edit existing student details,delete a student,search a student -// by his/her name via search bar are all perfectly working in this code.No need further debugging except to integrate API's. +// by his/her name (or) roll.no via search bar are all perfectly working in this code.No need further debugging except to integrate API's. import 'dart:convert'; import 'package:flutter/material.dart'; From 46022d6329e0f01767f1f8dffc68f71de9ae6370 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:22:58 +0530 Subject: [PATCH 09/11] Create noticeboard.dart Both Caretaker and Warden have same Noticeboard functionalities. --- lib/screens/Hostel/warden/noticeboard.dart | 215 +++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 lib/screens/Hostel/warden/noticeboard.dart diff --git a/lib/screens/Hostel/warden/noticeboard.dart b/lib/screens/Hostel/warden/noticeboard.dart new file mode 100644 index 00000000..2fe8bb5d --- /dev/null +++ b/lib/screens/Hostel/warden/noticeboard.dart @@ -0,0 +1,215 @@ +//All the 2 functionalities like add new notice,remove existing notice are all perfectly +//working in this code with proper formatting.No need further debugging on this code. + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Notice { + final String headline; + final String description; + final DateTime date; + + Notice(this.headline, this.description, this.date); +} + +class Noticeboard extends StatefulWidget { + const Noticeboard({Key? key}) : super(key: key); + + @override + _NoticeboardState createState() => _NoticeboardState(); +} + +class _NoticeboardState extends State { + List notices = []; // Define the 'notices' list + + @override + void initState() { + super.initState(); + // Populate with sample notice boards + _populateNoticeBoards(); + } + + // Method to populate sample notice boards + void _populateNoticeBoards() { + // Sample notice board 1 + notices.add( + Notice( + 'Important Announcement', + 'All students are hereby informed that using Alcohol,Cigaretts andElectical Items are prohibited in hostels.If found heavy fine will be imposed.', + DateTime(2024, 4, 22), + ), + ); + + // Sample notice board 2 + notices.add( + Notice( + 'Republic Day 2k24', + 'As you all are aware today is Republic day,so interested students can attend the flag hosting infront of hostel which will be starting at 8:00am.', + DateTime(2024, 1, 26), + ), + ); + + // Notify the UI about the changes + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Notice Board'), + backgroundColor: const Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Padding( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: ListView.builder( + itemCount: notices.length, + itemBuilder: (context, index) { + return Card( + margin: EdgeInsets.only(bottom: 20), + color: Color.fromARGB(255, 255, 229, 218), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: BorderSide( + color: Color.fromARGB(255, 245, 103, 47), + width: 2.0, + ), + ), + child: Padding( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + notices[index].headline, + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + Text( + '${notices[index].date.day}/${notices[index].date.month}/${notices[index].date.year}', + style: TextStyle(fontSize: 16), + ), + ], + ), + SizedBox(height: 10), + Text( + notices[index].description, + style: TextStyle(fontSize: 18), + ), + SizedBox(height: 20), + ElevatedButton( + onPressed: () { + // Handle file upload logic here + }, + child: Text('View Uploaded File'), + ), + SizedBox(height: 10), + Align( + alignment: Alignment.bottomRight, + child: ElevatedButton( + onPressed: () { + // Remove notice board logic here + setState(() { + notices.removeAt(index); + }); + }, + child: Text('Remove Notice'), + ), + ), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + // Display dialog to add a new notice + showDialog( + context: context, + builder: (BuildContext context) { + String headline = ''; + String description = ''; + + return AlertDialog( + title: Text('Add New Notice'), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration( + labelText: 'Headline', + ), + onChanged: (value) { + headline = value; + }, + ), + SizedBox(height: 10), + TextField( + decoration: InputDecoration( + labelText: 'Description', + ), + onChanged: (value) { + description = value; + }, + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: () { + // Handle file upload logic here + }, + child: Text('Upload File'), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Add new notice logic here + setState(() { + notices.add(Notice(headline, description, DateTime.now())); + }); + // Invoke sample POST API + // _invokePostAPI(headline, description, file); + Navigator.of(context).pop(); + }, + child: Text('Add'), + ), + ], + ); + }, + ); + }, + child: const Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + ); + } + + // Method to invoke a POST API + void _invokePostAPI(String headline, String description, String file) { + // Your implementation to invoke POST API + // Example: http.post(url, body: {'headline': headline, 'description': description, 'file': file}); + } +} From 7ccd606a0e92a0de674737dc73def683b67c5e06 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:24:06 +0530 Subject: [PATCH 10/11] Add files via upload --- lib/screens/Hostel/warden/hostel_warden.dart | 187 ++++++++++++ lib/screens/Hostel/warden/managerooms.dart | 293 +++++++++++++++++++ lib/screens/Hostel/warden/report.dart | 18 ++ lib/screens/Hostel/warden/staffinfo.dart | 65 ++++ 4 files changed, 563 insertions(+) create mode 100644 lib/screens/Hostel/warden/hostel_warden.dart create mode 100644 lib/screens/Hostel/warden/managerooms.dart create mode 100644 lib/screens/Hostel/warden/report.dart create mode 100644 lib/screens/Hostel/warden/staffinfo.dart diff --git a/lib/screens/Hostel/warden/hostel_warden.dart b/lib/screens/Hostel/warden/hostel_warden.dart new file mode 100644 index 00000000..d28e38d9 --- /dev/null +++ b/lib/screens/Hostel/warden/hostel_warden.dart @@ -0,0 +1,187 @@ +// ignore_for_file: prefer_const_constructors + +import 'package:flutter/material.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/Hostel/warden/managerooms.dart'; +import 'package:fusion/screens/Hostel/warden/managestudent.dart'; +import 'package:fusion/screens/Hostel/warden/noticeboard.dart'; +import 'package:fusion/screens/Hostel/warden/report.dart'; + +import 'package:fusion/screens/Hostel/warden/staffinfo.dart'; + +class Account extends StatelessWidget { + const Account({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Account'), + 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) => Staffinfo()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.person, + color: Colors.white, + size: 30, + ), + Text( + 'Staff Info', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Managerooms()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.person, + color: Colors.white, + size: 30, + ), + Text( + 'Staff Info', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Report()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.report, + color: Colors.white, + size: 30, + ), + Text( + 'Report', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Managestudent()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.school, + color: Colors.white, + size: 30, + ), + Text( + 'Manage', + style: TextStyle(color: Colors.white, fontSize: 15), + ), + Text( + 'Student', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Noticeboard()), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Color.fromARGB(255, 245, 103, 47), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.dashboard, + color: Colors.white, + size: 30, + ), + Text( + 'Notice Board', + style: TextStyle(color: Colors.white, fontSize: 15), + ) + ], + ), + ), + ), + + ]), + ), + ), + ); + } +} diff --git a/lib/screens/Hostel/warden/managerooms.dart b/lib/screens/Hostel/warden/managerooms.dart new file mode 100644 index 00000000..9d149eb5 --- /dev/null +++ b/lib/screens/Hostel/warden/managerooms.dart @@ -0,0 +1,293 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; + +class Room { + final int roomNumber; + final int capacity; + final int currentOccupancy; + final String status; + final List studentNames; + final int numberOfStudents; + + Room({ + required this.roomNumber, + required this.capacity, + required this.currentOccupancy, + required this.status, + required this.studentNames, + required this.numberOfStudents, + }); +} + +class Managerooms extends StatefulWidget { + const Managerooms({Key? key}) : super(key: key); + + @override + _ManageroomsState createState() => _ManageroomsState(); +} + +class _ManageroomsState extends State { + List rooms = []; + List filteredRooms = []; + + @override + void initState() { + super.initState(); + _fetchRoomDetails(); + } + + Future _fetchRoomDetails() async { + // Simulating GET API call to fetch room details + final String roomData = ''' + [ + {"roomNumber": 101, "capacity": 2, "currentOccupancy": 1, "status": "Partially Allotted", "studentNames": ["John Doe"], "numberOfStudents": 1}, + {"roomNumber": 102, "capacity": 3, "currentOccupancy": 2, "status": "Fully Allotted", "studentNames": ["Alice", "Bob"], "numberOfStudents": 2}, + {"roomNumber": 103, "capacity": 4, "currentOccupancy": 4, "status": "Fully Allotted", "studentNames": ["Charlie", "David", "Eve", "Frank"], "numberOfStudents": 4}, + ] + '''; + final List roomList = json.decode(roomData); + setState(() { + rooms = roomList.map((room) => Room( + roomNumber: room['roomNumber'], + capacity: room['capacity'], + currentOccupancy: room['currentOccupancy'], + status: room['status'], + studentNames: List.from(room['studentNames']), + numberOfStudents: room['numberOfStudents'], + )).toList(); + filteredRooms = List.from(rooms); + }); + } + + Future _editStudentDetails(Room room) async { + // Display dialog to edit student details + showDialog( + context: context, + builder: (BuildContext context) { + // Implement the edit room details dialog + return AlertDialog( + title: Text('Edit Student Details'), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Add fields to edit student details + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Perform the edit operation here + // Update the room details + // Simulate POST API call to update room details + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ], + ); + }, + ); + } + + Future _deleteStudentDetails(Room room) async { + // Show confirmation dialog before deleting the student + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Confirm Deletion'), + content: Text('Are you sure you want to delete the student?'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('Cancel'), + ), + ElevatedButton( + onPressed: () { + // Delete the student from the room + _deleteStudent(room); + Navigator.of(context).pop(); + }, + child: Text('Delete'), + ), + ], + ); + }, + ); + } + + void _deleteStudent(Room room) { + setState(() { + // Implement logic to delete the student from the room + }); + // Simulate DELETE API call to delete student details + } + + Future _showAddDialog() async { + // Implement add student to room dialog + } + + void _searchRooms(int roomNumber) { + setState(() { + if (roomNumber != 0) { + filteredRooms = rooms.where((room) => room.roomNumber == roomNumber).toList(); + } else { + filteredRooms.clear(); // Clear filtered list if no search is active + filteredRooms.addAll(rooms); // Repopulate with all rooms + } + }); + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Manage Rooms'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () async { + final int? result = await showSearch( + context: context, + delegate: RoomSearchDelegate(rooms: rooms), + ); + if (result != null) { + _searchRooms(result); + } + }, + ), + ], + ), + body: SingleChildScrollView( + child: DataTable( + columns: const [ + DataColumn(label: Text('Room No')), + DataColumn(label: Text('Capacity')), + DataColumn(label: Text('Current Occupancy')), + DataColumn(label: Text('Status')), + DataColumn(label: Text('Student Names')), + DataColumn(label: Text('No of Students')), + DataColumn(label: Text('Edit')), + DataColumn(label: Text('Delete')), + DataColumn(label: Text('Add')), + ], + rows: filteredRooms.map((room) { + return DataRow(cells: [ + DataCell(Text(room.roomNumber.toString())), + DataCell(Text(room.capacity.toString())), + DataCell(Text(room.currentOccupancy.toString())), + DataCell(Text(room.status)), + DataCell(Text(room.studentNames.join(', '))), + DataCell(Text(room.numberOfStudents.toString())), + DataCell( + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + _editStudentDetails(room); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.delete), + onPressed: () { + _deleteStudentDetails(room); + }, + ), + ), + DataCell( + IconButton( + icon: Icon(Icons.add), + onPressed: () { + _showAddDialog(); + }, + ), + ), + ]); + }).toList(), + ), + ), + ); + } +} + +class RoomSearchDelegate extends SearchDelegate { + final List rooms; + + RoomSearchDelegate({required this.rooms}); + + @override + ThemeData appBarTheme(BuildContext context) { + final ThemeData theme = Theme.of(context); + return theme.copyWith( + appBarTheme: AppBarTheme( + backgroundColor: theme.scaffoldBackgroundColor, // Match with screen's UI theme + iconTheme: IconThemeData(color: theme.primaryColor), // Match with screen's UI theme + ), + ); + } + + @override + List buildActions(BuildContext context) { + return [ + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + query = ''; + }, + ), + ]; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, null); + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + return _buildSearchResults(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + return _buildSearchResults(context); + } + + Widget _buildSearchResults(BuildContext context) { + return ListView.builder( + itemCount: rooms.length, + itemBuilder: (context, index) { + return ListTile( + title: Text('Room No: ${rooms[index].roomNumber}'), + onTap: () { + close(context, rooms[index].roomNumber); + }, + ); + }, + ); + } +} + +void main() { + runApp(MaterialApp( + home: Managerooms(), + )); +} diff --git a/lib/screens/Hostel/warden/report.dart b/lib/screens/Hostel/warden/report.dart new file mode 100644 index 00000000..dd3f1934 --- /dev/null +++ b/lib/screens/Hostel/warden/report.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/side_drawer.dart'; +class Report extends StatelessWidget { +const Report ({Key?key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer:SideDrawer(), + appBar: AppBar( + title: const Text('Report'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + ); + } +} + diff --git a/lib/screens/Hostel/warden/staffinfo.dart b/lib/screens/Hostel/warden/staffinfo.dart new file mode 100644 index 00000000..2f53a24a --- /dev/null +++ b/lib/screens/Hostel/warden/staffinfo.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Staffinfo extends StatelessWidget { + const Staffinfo({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SideDrawer(), + appBar: AppBar( + title: const Text('Staff Info'), + backgroundColor: Color.fromARGB(255, 245, 103, 47), + foregroundColor: Colors.white, + ), + body: Padding( + padding: EdgeInsets.only(left: 20, right: 20, top: 50), + child: SingleChildScrollView( + child: Center( + child: Column( + children: [ + for (int i = 1; i < 15; i++) + Card( + color: Color.fromARGB(255, 245, 103, 47), + child: ListTile( + title: Row( + children: [ + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Staff $i', + style: TextStyle( + color: Colors.white, + fontSize: 20, + ), + ), + Icon( + Icons.arrow_forward_ios, + color: Colors.white, + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + // Add new staff info logic here + }, + child: Icon(Icons.add), + backgroundColor: Color.fromARGB(255, 255, 152, 111), + foregroundColor: Color(0xffffffff), + ), + ); + } +} From 92e7e2816a1308c6167e329ca52a655c2e29f6a0 Mon Sep 17 00:00:00 2001 From: Kishor <114857702+root-reborn@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:26:13 +0530 Subject: [PATCH 11/11] Delete lib/screens/Hostel/demo.txt --- lib/screens/Hostel/demo.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lib/screens/Hostel/demo.txt diff --git a/lib/screens/Hostel/demo.txt b/lib/screens/Hostel/demo.txt deleted file mode 100644 index 8b137891..00000000 --- a/lib/screens/Hostel/demo.txt +++ /dev/null @@ -1 +0,0 @@ -