From c8488c61098906bf8d7c9b8586e17119237baa70 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Fri, 9 Feb 2024 00:13:37 +0530 Subject: [PATCH 01/20] conflicts resolved --- frontend/lib/screens/home.dart | 3 +++ frontend/pubspec.lock | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/frontend/lib/screens/home.dart b/frontend/lib/screens/home.dart index 8d93b4d..36db926 100644 --- a/frontend/lib/screens/home.dart +++ b/frontend/lib/screens/home.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:smart_insti_app/components/menu_tile.dart'; import '../constants/constants.dart'; import '../provider/student_provider.dart'; diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index 81936a4..9206370 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -169,14 +169,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" - equatable: - dependency: transitive - description: - name: equatable - sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 - url: "https://pub.dev" - source: hosted - version: "2.0.5" dio: dependency: "direct main" description: @@ -185,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.4.0" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -217,14 +217,6 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.1" - fl_chart: - dependency: "direct main" - description: - name: fl_chart - sha256: b5e2b0f13d93f8c532b5a2786bfb44580de1f50b927bf95813fa1af617e9caf8 - url: "https://pub.dev" - source: hosted - version: "0.66.1" file_selector_linux: dependency: transitive description: @@ -257,6 +249,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.3+1" + fl_chart: + dependency: "direct main" + description: + name: fl_chart + sha256: b5e2b0f13d93f8c532b5a2786bfb44580de1f50b927bf95813fa1af617e9caf8 + url: "https://pub.dev" + source: hosted + version: "0.66.1" flutter: dependency: "direct main" description: flutter From 9d7c1cff93fd57aa4a6a1c032e73de8aad1f9dc6 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Fri, 9 Feb 2024 19:51:50 +0530 Subject: [PATCH 02/20] broadcast schema added and provider, repository files --- frontend/lib/models/broadcast_schema.dart | 21 +++++++++++ frontend/lib/provider/broadcast_provider.dart | 8 +++++ .../repositories/broadcast_repository.dart | 27 ++++++++++++++ frontend/lib/routes/routes.dart | 1 - frontend/lib/screens/broadcast.dart | 36 +++++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 frontend/lib/models/broadcast_schema.dart create mode 100644 frontend/lib/provider/broadcast_provider.dart create mode 100644 frontend/lib/repositories/broadcast_repository.dart create mode 100644 frontend/lib/screens/broadcast.dart diff --git a/frontend/lib/models/broadcast_schema.dart b/frontend/lib/models/broadcast_schema.dart new file mode 100644 index 0000000..006683b --- /dev/null +++ b/frontend/lib/models/broadcast_schema.dart @@ -0,0 +1,21 @@ +import 'package:flutter/foundation.dart'; + +class Broadcast { + final String title; + final String body; + final DateTime time; + + Broadcast({ + required this.title, + required this.body, + required this.time, + }); + + factory Broadcast.fromJson(Map json) { + return Broadcast( + title: json['title'], + body: json['body'], + time: DateTime.parse(json['time']), + ); + } +} diff --git a/frontend/lib/provider/broadcast_provider.dart b/frontend/lib/provider/broadcast_provider.dart new file mode 100644 index 0000000..9ecf71b --- /dev/null +++ b/frontend/lib/provider/broadcast_provider.dart @@ -0,0 +1,8 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:smart_insti_app/models/broadcast_schema.dart'; +import 'package:smart_insti_app/repository/broadcast_repository.dart'; + +final broadcastProvider = FutureProvider>((ref) async { + final repository = ref.read(broadcastRepositoryProvider); + return repository.fetchBroadcasts(); +}); diff --git a/frontend/lib/repositories/broadcast_repository.dart b/frontend/lib/repositories/broadcast_repository.dart new file mode 100644 index 0000000..38997e2 --- /dev/null +++ b/frontend/lib/repositories/broadcast_repository.dart @@ -0,0 +1,27 @@ +import 'package:dio/dio.dart'; +import 'package:logger/logger.dart'; +import 'package:smart_insti_app/models/broadcast_schema.dart'; + +final broadcastRepositoryProvider = + Provider((_) => BroadcastRepository()); + +class BroadcastRepository { + final _client = Dio( + BaseOptions( + baseUrl: 'http://10.0.2.2:3000', + ), + ); + + Future> fetchBroadcasts() async { + try { + final response = await _client.get('/broadcasts'); + final List broadcasts = List.from( + response.data.map((broadcastJson) => Broadcast.fromJson(broadcastJson)), + ); + return broadcasts; + } catch (e) { + Logger().e(e); + throw Exception('Failed to fetch broadcasts'); + } + } +} diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index c561d1a..869c023 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -13,7 +13,6 @@ import '../screens/admin/view_courses.dart'; import '../screens/admin/view_faculty.dart'; import '../screens/admin/view_menu.dart'; import '../screens/user_profile.dart'; -import '../screens/home.dart'; import '../screens/auth/signin_page.dart'; import '../screens/room_vacancy.dart'; diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/broadcast.dart new file mode 100644 index 0000000..85e9006 --- /dev/null +++ b/frontend/lib/screens/broadcast.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:smart_insti_app/provider/broadcast_provider.dart'; +import 'package:smart_insti_app/models/broadcast_schema.dart'; + +class BroadcastPage extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final broadcasts = ref.watch(broadcastProvider); + + return Scaffold( + appBar: AppBar( + title: Text('Broadcasts'), + ), + body: broadcasts.when( + data: (broadcasts) { + return ListView.builder( + itemCount: broadcasts.length, + itemBuilder: (context, index) { + final broadcast = broadcasts[index]; + return ListTile( + title: Text(broadcast.title), + subtitle: Text(broadcast.body), + trailing: Text( + '${broadcast.time.hour}:${broadcast.time.minute}', + ), + ); + }, + ); + }, + loading: () => Center(child: CircularProgressIndicator()), + error: (error, stackTrace) => Center(child: Text('Error: $error')), + ), + ); + } +} From 57d25f3cde13b53295f9826a4217ece11569a7a5 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Sat, 10 Feb 2024 02:51:51 +0530 Subject: [PATCH 03/20] added routes and few changes --- frontend/lib/provider/broadcast_provider.dart | 2 +- frontend/lib/repositories/broadcast_repository.dart | 1 + frontend/lib/routes/routes.dart | 10 ++++++++-- frontend/lib/screens/home.dart | 10 ++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/lib/provider/broadcast_provider.dart b/frontend/lib/provider/broadcast_provider.dart index 9ecf71b..433ebbe 100644 --- a/frontend/lib/provider/broadcast_provider.dart +++ b/frontend/lib/provider/broadcast_provider.dart @@ -1,6 +1,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smart_insti_app/models/broadcast_schema.dart'; -import 'package:smart_insti_app/repository/broadcast_repository.dart'; +import '../repositories/broadcast_repository.dart'; final broadcastProvider = FutureProvider>((ref) async { final repository = ref.read(broadcastRepositoryProvider); diff --git a/frontend/lib/repositories/broadcast_repository.dart b/frontend/lib/repositories/broadcast_repository.dart index 38997e2..4329585 100644 --- a/frontend/lib/repositories/broadcast_repository.dart +++ b/frontend/lib/repositories/broadcast_repository.dart @@ -1,6 +1,7 @@ import 'package:dio/dio.dart'; import 'package:logger/logger.dart'; import 'package:smart_insti_app/models/broadcast_schema.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; final broadcastRepositoryProvider = Provider((_) => BroadcastRepository()); diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 869c023..74e42b9 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -15,14 +15,20 @@ import '../screens/admin/view_menu.dart'; import '../screens/user_profile.dart'; import '../screens/auth/signin_page.dart'; import '../screens/room_vacancy.dart'; +import '../screens/broadcast.dart'; final GoRouter routes = GoRouter( - initialLocation: '/home', + // initialLocation: '/home', routes: [ GoRoute( path: '/', - pageBuilder: (context, state) => MaterialPage(child: SignIn()), + pageBuilder: (context, state) => const MaterialPage(child: Home()), + // pageBuilder: (context, state) => MaterialPage(child: SignIn()), routes: [ + GoRoute( + path: 'broadcast', + pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), + ), GoRoute( path: 'user_profile', pageBuilder: (context, state) => diff --git a/frontend/lib/screens/home.dart b/frontend/lib/screens/home.dart index 36db926..2dd3067 100644 --- a/frontend/lib/screens/home.dart +++ b/frontend/lib/screens/home.dart @@ -62,6 +62,16 @@ class Home extends ConsumerWidget { primaryColor: Colors.orangeAccent.shade100, secondaryColor: Colors.orangeAccent.shade200, icon: Icons.search), + MenuTile( + title: 'Broadcast', + onTap: () { + // Navigate to the broadcast page + context.push('/broadcast'); + }, + icon: Icons.announcement, + primaryColor: Colors.greenAccent.shade100, + secondaryColor: Colors.greenAccent.shade200, + ), ], ), ), From 1f99fc044bcde892923722ca07bf4b59cc570b1b Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Sat, 10 Feb 2024 03:08:37 +0530 Subject: [PATCH 04/20] added dummy data and displayed in the broadcast screen --- frontend/lib/models/broadcast_schema.dart | 2 - frontend/lib/provider/broadcast_provider.dart | 19 +++- frontend/lib/screens/broadcast.dart | 90 +++++++++++++++---- 3 files changed, 91 insertions(+), 20 deletions(-) diff --git a/frontend/lib/models/broadcast_schema.dart b/frontend/lib/models/broadcast_schema.dart index 006683b..16e8aac 100644 --- a/frontend/lib/models/broadcast_schema.dart +++ b/frontend/lib/models/broadcast_schema.dart @@ -1,5 +1,3 @@ -import 'package:flutter/foundation.dart'; - class Broadcast { final String title; final String body; diff --git a/frontend/lib/provider/broadcast_provider.dart b/frontend/lib/provider/broadcast_provider.dart index 433ebbe..615e9eb 100644 --- a/frontend/lib/provider/broadcast_provider.dart +++ b/frontend/lib/provider/broadcast_provider.dart @@ -1,8 +1,21 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smart_insti_app/models/broadcast_schema.dart'; -import '../repositories/broadcast_repository.dart'; final broadcastProvider = FutureProvider>((ref) async { - final repository = ref.read(broadcastRepositoryProvider); - return repository.fetchBroadcasts(); + await Future.delayed(const Duration(seconds: 2)); // Simulating delay + return List.generate( + 10, + (index) => Broadcast( + title: 'Broadcast $index', + body: 'This is the body of broadcast $index.', + time: DateTime.now(), + )); }); +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import 'package:smart_insti_app/models/broadcast_schema.dart'; +// import '../repositories/broadcast_repository.dart'; + +// final broadcastProvider = FutureProvider>((ref) async { +// final repository = ref.read(broadcastRepositoryProvider); +// return repository.fetchBroadcasts(); +// }); diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/broadcast.dart index 85e9006..bf545df 100644 --- a/frontend/lib/screens/broadcast.dart +++ b/frontend/lib/screens/broadcast.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smart_insti_app/provider/broadcast_provider.dart'; -import 'package:smart_insti_app/models/broadcast_schema.dart'; +// import 'package:smart_insti_app/models/broadcast_schema.dart'; class BroadcastPage extends ConsumerWidget { @override @@ -10,27 +10,87 @@ class BroadcastPage extends ConsumerWidget { return Scaffold( appBar: AppBar( - title: Text('Broadcasts'), + title: const Text('Broadcasts'), ), body: broadcasts.when( data: (broadcasts) { - return ListView.builder( - itemCount: broadcasts.length, - itemBuilder: (context, index) { - final broadcast = broadcasts[index]; - return ListTile( - title: Text(broadcast.title), - subtitle: Text(broadcast.body), - trailing: Text( - '${broadcast.time.hour}:${broadcast.time.minute}', - ), - ); - }, + return SingleChildScrollView( + child: Column( + children: broadcasts.map((broadcast) { + return Card( + margin: const EdgeInsets.all(8.0), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + broadcast.title, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + ), + ), + Text( + '${broadcast.time.hour > 12 ? broadcast.time.hour - 12 : broadcast.time.hour}:${broadcast.time.minute} ${broadcast.time.hour >= 12 ? 'PM' : 'AM'}', + style: const TextStyle( + fontSize: 16.0, + ), + ), + ], + ), + const SizedBox(height: 8.0), + Text( + broadcast.body, + style: const TextStyle( + fontSize: 16.0, + ), + ), + ], + ), + ), + ); + }).toList(), + ), ); }, - loading: () => Center(child: CircularProgressIndicator()), + loading: () => const Center(child: CircularProgressIndicator()), error: (error, stackTrace) => Center(child: Text('Error: $error')), ), ); } } +// class BroadcastPage extends ConsumerWidget { +// @override +// Widget build(BuildContext context, WidgetRef ref) { +// final broadcasts = ref.watch(broadcastProvider); + +// return Scaffold( +// appBar: AppBar( +// title: Text('Broadcasts'), +// ), +// body: broadcasts.when( +// data: (broadcasts) { +// return ListView.builder( +// itemCount: broadcasts.length, +// itemBuilder: (context, index) { +// final broadcast = broadcasts[index]; +// return ListTile( +// title: Text(broadcast.title), +// subtitle: Text(broadcast.body), +// trailing: Text( +// '${broadcast.time.hour}:${broadcast.time.minute}', +// ), +// ); +// }, +// ); +// }, +// loading: () => Center(child: CircularProgressIndicator()), +// error: (error, stackTrace) => Center(child: Text('Error: $error')), +// ), +// ); +// } +// } From fea97f70cef0723ee214d7933948e879a6451c52 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Sun, 11 Feb 2024 16:10:56 +0530 Subject: [PATCH 05/20] ui updated --- frontend/lib/provider/broadcast_provider.dart | 8 - frontend/lib/screens/broadcast.dart | 151 +++++++++++++----- 2 files changed, 114 insertions(+), 45 deletions(-) diff --git a/frontend/lib/provider/broadcast_provider.dart b/frontend/lib/provider/broadcast_provider.dart index 615e9eb..56c0648 100644 --- a/frontend/lib/provider/broadcast_provider.dart +++ b/frontend/lib/provider/broadcast_provider.dart @@ -11,11 +11,3 @@ final broadcastProvider = FutureProvider>((ref) async { time: DateTime.now(), )); }); -// import 'package:flutter_riverpod/flutter_riverpod.dart'; -// import 'package:smart_insti_app/models/broadcast_schema.dart'; -// import '../repositories/broadcast_repository.dart'; - -// final broadcastProvider = FutureProvider>((ref) async { -// final repository = ref.read(broadcastRepositoryProvider); -// return repository.fetchBroadcasts(); -// }); diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/broadcast.dart index bf545df..f756cff 100644 --- a/frontend/lib/screens/broadcast.dart +++ b/frontend/lib/screens/broadcast.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smart_insti_app/provider/broadcast_provider.dart'; -// import 'package:smart_insti_app/models/broadcast_schema.dart'; +import 'package:smart_insti_app/models/broadcast_schema.dart'; class BroadcastPage extends ConsumerWidget { @override @@ -11,58 +11,135 @@ class BroadcastPage extends ConsumerWidget { return Scaffold( appBar: AppBar( title: const Text('Broadcasts'), + backgroundColor: Colors.blue, // Set app bar background color ), - body: broadcasts.when( - data: (broadcasts) { - return SingleChildScrollView( - child: Column( - children: broadcasts.map((broadcast) { - return Card( - margin: const EdgeInsets.all(8.0), - child: Padding( + body: Container( + color: Colors.blue[50], // Set body background color + child: broadcasts.when( + data: (broadcasts) { + return SingleChildScrollView( + child: Column( + children: broadcasts.map((broadcast) { + return Padding( padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + child: Card( + elevation: 4, // Add elevation to card + color: Colors.white, // Set card background color + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 10), // Add border radius to card + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - broadcast.title, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18.0, - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + broadcast.title, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + ), + ), + Text( + '${broadcast.time.hour > 12 ? broadcast.time.hour - 12 : broadcast.time.hour}:${broadcast.time.minute} ${broadcast.time.hour >= 12 ? 'PM' : 'AM'}', + style: const TextStyle( + fontSize: 16.0, + ), + ), + ], ), + const SizedBox(height: 8.0), Text( - '${broadcast.time.hour > 12 ? broadcast.time.hour - 12 : broadcast.time.hour}:${broadcast.time.minute} ${broadcast.time.hour >= 12 ? 'PM' : 'AM'}', + broadcast.body, style: const TextStyle( fontSize: 16.0, ), ), ], ), - const SizedBox(height: 8.0), - Text( - broadcast.body, - style: const TextStyle( - fontSize: 16.0, - ), - ), - ], + ), ), - ), - ); - }).toList(), - ), - ); - }, - loading: () => const Center(child: CircularProgressIndicator()), - error: (error, stackTrace) => Center(child: Text('Error: $error')), + ); + }).toList(), + ), + ); + }, + loading: () => const Center(child: CircularProgressIndicator()), + error: (error, stackTrace) => Center(child: Text('Error: $error')), + ), ), ); } } +// import 'package:flutter/material.dart'; +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import 'package:smart_insti_app/provider/broadcast_provider.dart'; +// // import 'package:smart_insti_app/models/broadcast_schema.dart'; + +// class BroadcastPage extends ConsumerWidget { +// @override +// Widget build(BuildContext context, WidgetRef ref) { +// final broadcasts = ref.watch(broadcastProvider); + +// return Scaffold( +// appBar: AppBar( +// title: const Text('Broadcasts'), +// ), +// body: broadcasts.when( +// data: (broadcasts) { +// return SingleChildScrollView( +// child: Column( +// children: broadcasts.map((broadcast) { +// return Card( +// margin: const EdgeInsets.all(8.0), +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Text( +// broadcast.title, +// style: const TextStyle( +// fontWeight: FontWeight.bold, +// fontSize: 18.0, +// ), +// ), +// Text( +// '${broadcast.time.hour > 12 ? broadcast.time.hour - 12 : broadcast.time.hour}:${broadcast.time.minute} ${broadcast.time.hour >= 12 ? 'PM' : 'AM'}', +// style: const TextStyle( +// fontSize: 16.0, +// ), +// ), +// ], +// ), +// const SizedBox(height: 8.0), +// Text( +// broadcast.body, +// style: const TextStyle( +// fontSize: 16.0, +// ), +// ), +// ], +// ), +// ), +// ); +// }).toList(), +// ), +// ); +// }, +// loading: () => const Center(child: CircularProgressIndicator()), +// error: (error, stackTrace) => Center(child: Text('Error: $error')), +// ), +// ); +// } +// } // class BroadcastPage extends ConsumerWidget { // @override // Widget build(BuildContext context, WidgetRef ref) { From e2f49f47552d7fce7249673cd8b09298dd01d790 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Sun, 11 Feb 2024 16:17:51 +0530 Subject: [PATCH 06/20] schema updated and displayed --- frontend/lib/models/broadcast_schema.dart | 6 +++--- frontend/lib/provider/broadcast_provider.dart | 13 +++++++------ frontend/lib/screens/broadcast.dart | 14 +++++++------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/frontend/lib/models/broadcast_schema.dart b/frontend/lib/models/broadcast_schema.dart index 16e8aac..d6ef863 100644 --- a/frontend/lib/models/broadcast_schema.dart +++ b/frontend/lib/models/broadcast_schema.dart @@ -1,19 +1,19 @@ class Broadcast { final String title; final String body; - final DateTime time; + final DateTime date; Broadcast({ required this.title, required this.body, - required this.time, + required this.date, }); factory Broadcast.fromJson(Map json) { return Broadcast( title: json['title'], body: json['body'], - time: DateTime.parse(json['time']), + date: DateTime.parse(json['date']), // Update parsing to 'date' ); } } diff --git a/frontend/lib/provider/broadcast_provider.dart b/frontend/lib/provider/broadcast_provider.dart index 56c0648..3dc114d 100644 --- a/frontend/lib/provider/broadcast_provider.dart +++ b/frontend/lib/provider/broadcast_provider.dart @@ -4,10 +4,11 @@ import 'package:smart_insti_app/models/broadcast_schema.dart'; final broadcastProvider = FutureProvider>((ref) async { await Future.delayed(const Duration(seconds: 2)); // Simulating delay return List.generate( - 10, - (index) => Broadcast( - title: 'Broadcast $index', - body: 'This is the body of broadcast $index.', - time: DateTime.now(), - )); + 10, + (index) => Broadcast( + title: 'Broadcast $index', + body: 'This is the body of broadcast $index.', + date: DateTime.now().subtract(Duration(days: index)), + ), + ); }); diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/broadcast.dart index f756cff..4955f34 100644 --- a/frontend/lib/screens/broadcast.dart +++ b/frontend/lib/screens/broadcast.dart @@ -11,10 +11,10 @@ class BroadcastPage extends ConsumerWidget { return Scaffold( appBar: AppBar( title: const Text('Broadcasts'), - backgroundColor: Colors.blue, // Set app bar background color + backgroundColor: Colors.blue, ), body: Container( - color: Colors.blue[50], // Set body background color + color: Colors.blue[50], child: broadcasts.when( data: (broadcasts) { return SingleChildScrollView( @@ -23,11 +23,10 @@ class BroadcastPage extends ConsumerWidget { return Padding( padding: const EdgeInsets.all(8.0), child: Card( - elevation: 4, // Add elevation to card - color: Colors.white, // Set card background color + elevation: 4, + color: Colors.white, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - 10), // Add border radius to card + borderRadius: BorderRadius.circular(10), ), child: Padding( padding: const EdgeInsets.all(12.0), @@ -45,7 +44,7 @@ class BroadcastPage extends ConsumerWidget { ), ), Text( - '${broadcast.time.hour > 12 ? broadcast.time.hour - 12 : broadcast.time.hour}:${broadcast.time.minute} ${broadcast.time.hour >= 12 ? 'PM' : 'AM'}', + '${broadcast.date.day}-${broadcast.date.month}-${broadcast.date.year}', style: const TextStyle( fontSize: 16.0, ), @@ -75,6 +74,7 @@ class BroadcastPage extends ConsumerWidget { ); } } + // import 'package:flutter/material.dart'; // import 'package:flutter_riverpod/flutter_riverpod.dart'; // import 'package:smart_insti_app/provider/broadcast_provider.dart'; From 01c707914a0fdb889f389737a86931e044eefca4 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Mon, 12 Feb 2024 01:50:21 +0530 Subject: [PATCH 07/20] notifications page added with dummy notiifcations --- frontend/lib/models/notifications_schema.dart | 5 + frontend/lib/models/student2.dart | 18 --- .../lib/provider/notifications_provider.dart | 22 +++ frontend/lib/routes/routes.dart | 111 +++++++++++++-- frontend/lib/screens/home.dart | 132 +++++++++++------- frontend/lib/screens/notifications.dart | 58 ++++++++ 6 files changed, 266 insertions(+), 80 deletions(-) create mode 100644 frontend/lib/models/notifications_schema.dart delete mode 100644 frontend/lib/models/student2.dart create mode 100644 frontend/lib/provider/notifications_provider.dart create mode 100644 frontend/lib/screens/notifications.dart diff --git a/frontend/lib/models/notifications_schema.dart b/frontend/lib/models/notifications_schema.dart new file mode 100644 index 0000000..452fa48 --- /dev/null +++ b/frontend/lib/models/notifications_schema.dart @@ -0,0 +1,5 @@ +class NotificationModel { + final String message; + + NotificationModel({required this.message}); +} diff --git a/frontend/lib/models/student2.dart b/frontend/lib/models/student2.dart deleted file mode 100644 index a388e30..0000000 --- a/frontend/lib/models/student2.dart +++ /dev/null @@ -1,18 +0,0 @@ -class Student { - Student( - {required this.name, - required this.studentMail, - required this.rollNumber, - required this.branch, - required this.role, - this.id, - this.collegeId}); - - final String? id; - final String? collegeId; - final String name; - final String studentMail; - final String rollNumber; - final String branch; - final String role; -} diff --git a/frontend/lib/provider/notifications_provider.dart b/frontend/lib/provider/notifications_provider.dart new file mode 100644 index 0000000..dadf208 --- /dev/null +++ b/frontend/lib/provider/notifications_provider.dart @@ -0,0 +1,22 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../models/notifications_schema.dart'; + +final notificationsProvider = + StateNotifierProvider>( + (ref) => NotificationsNotifier(), +); + +class NotificationsNotifier extends StateNotifier> { + NotificationsNotifier() : super([]); + + void addNotification(String message) { + state = [...state, NotificationModel(message: 'message1')]; + } + + // Method to generate dummy notifications + void generateDummyNotifications() { + addNotification('Notification 1'); + addNotification('Notification 2'); + addNotification('Notification 3'); + } +} diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 74e42b9..e6bed1c 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -5,25 +5,24 @@ import 'package:smart_insti_app/screens/admin/add_students.dart'; import 'package:smart_insti_app/screens/admin/admin_home.dart'; import 'package:smart_insti_app/screens/admin/manage_rooms.dart'; import 'package:smart_insti_app/screens/admin/view_students.dart'; +import 'package:smart_insti_app/screens/broadcast.dart'; import 'package:smart_insti_app/screens/home.dart'; import 'package:smart_insti_app/screens/lost_and_found.dart'; +import 'package:smart_insti_app/screens/notifications.dart'; import '../screens/admin/add_faculty.dart'; import '../screens/admin/add_menu.dart'; import '../screens/admin/view_courses.dart'; import '../screens/admin/view_faculty.dart'; import '../screens/admin/view_menu.dart'; +import '../screens/room_vacancy.dart'; import '../screens/user_profile.dart'; import '../screens/auth/signin_page.dart'; -import '../screens/room_vacancy.dart'; -import '../screens/broadcast.dart'; final GoRouter routes = GoRouter( - // initialLocation: '/home', routes: [ GoRoute( path: '/', pageBuilder: (context, state) => const MaterialPage(child: Home()), - // pageBuilder: (context, state) => MaterialPage(child: SignIn()), routes: [ GoRoute( path: 'broadcast', @@ -33,12 +32,6 @@ final GoRouter routes = GoRouter( path: 'user_profile', pageBuilder: (context, state) => const MaterialPage(child: UserProfile()), -// pageBuilder: (context, state) => MaterialPage(child: UserLogin()), -// routes: [ -// GoRoute( -// path: 'admin_login', -// pageBuilder: (context, state) => -// const MaterialPage(child: AdminLogin()), ), GoRoute( path: 'admin_home', @@ -92,10 +85,106 @@ final GoRouter routes = GoRouter( ) ], ), + GoRoute( + path: 'notifications', + pageBuilder: (context, state) => + MaterialPage(child: NotificationsPage()), + ), ], ), ], -); +);// import 'package:flutter/material.dart'; +// import 'package:go_router/go_router.dart'; +// import 'package:smart_insti_app/screens/admin/add_courses.dart'; +// import 'package:smart_insti_app/screens/admin/add_students.dart'; +// import 'package:smart_insti_app/screens/admin/admin_home.dart'; +// import 'package:smart_insti_app/screens/admin/manage_rooms.dart'; +// import 'package:smart_insti_app/screens/admin/view_students.dart'; +// import 'package:smart_insti_app/screens/home.dart'; +// import 'package:smart_insti_app/screens/lost_and_found.dart'; +// import '../screens/admin/add_faculty.dart'; +// import '../screens/admin/add_menu.dart'; +// import '../screens/admin/view_courses.dart'; +// import '../screens/admin/view_faculty.dart'; +// import '../screens/admin/view_menu.dart'; +// import '../screens/user_profile.dart'; +// import '../screens/auth/signin_page.dart'; +// import '../screens/room_vacancy.dart'; +// import '../screens/broadcast.dart'; + +// final GoRouter routes = GoRouter( +// // initialLocation: '/home', +// routes: [ +// GoRoute( +// path: '/', +// pageBuilder: (context, state) => const MaterialPage(child: Home()), +// // pageBuilder: (context, state) => MaterialPage(child: SignIn()), +// routes: [ +// GoRoute( +// path: 'broadcast', +// pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), +// ), +// GoRoute( +// path: 'user_profile', +// pageBuilder: (context, state) => +// const MaterialPage(child: UserProfile()), +// ), +// GoRoute( +// path: 'admin_home', +// pageBuilder: (context, state) => +// const MaterialPage(child: AdminHome()), +// routes: [ +// GoRoute( +// path: 'add_students', +// pageBuilder: (context, state) => +// MaterialPage(child: AddStudents()), +// ), +// GoRoute( +// path: 'add_faculty', +// pageBuilder: (context, state) => +// MaterialPage(child: AddFaculty()), +// ), +// GoRoute( +// path: 'add_courses', +// pageBuilder: (context, state) => +// MaterialPage(child: AddCourses()), +// ), +// GoRoute( +// path: 'view_students', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewStudents()), +// ), +// GoRoute( +// path: 'view_faculty', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewFaculty()), +// ), +// GoRoute( +// path: 'view_courses', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewCourses()), +// ), +// GoRoute( +// path: 'add_menu', +// pageBuilder: (context, state) => +// MaterialPage(child: AddMessMenu()), +// ), +// GoRoute( +// path: 'view_menu', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewMessMenu()), +// ), +// GoRoute( +// path: 'manage_rooms', +// pageBuilder: (context, state) => +// MaterialPage(child: ManageRooms()), +// ) +// ], +// ), +// ], +// ), +// ], +// ); // final GoRouter routes = GoRouter( // routes: [ diff --git a/frontend/lib/screens/home.dart b/frontend/lib/screens/home.dart index 2dd3067..af52731 100644 --- a/frontend/lib/screens/home.dart +++ b/frontend/lib/screens/home.dart @@ -4,31 +4,40 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smart_insti_app/components/menu_tile.dart'; import '../constants/constants.dart'; import '../provider/student_provider.dart'; - import '../provider/room_provider.dart'; +import '../screens/notifications.dart'; class Home extends ConsumerWidget { - const Home({super.key}); + const Home({Key? key}); @override Widget build(BuildContext context, WidgetRef ref) { final student = ref.read(studentProvider); + return SafeArea( child: Scaffold( appBar: AppBar( - title: const Text( + title: Text( AppConstants.appName, ), backgroundColor: Colors.lightBlueAccent, actions: [ + // Icon for Notifications Page + IconButton( + icon: Icon(Icons.notifications), + onPressed: () { + // Navigate to notifications page + context.push('/notifications'); + }, + ), IconButton( - icon: const Icon(Icons.person), + icon: Icon(Icons.person), onPressed: () { context.push('/user_profile'); }, ), IconButton( - icon: const Icon(Icons.admin_panel_settings), + icon: Icon(Icons.admin_panel_settings), onPressed: () { context.push('/admin_home'); }, @@ -43,12 +52,12 @@ class Home extends ConsumerWidget { title: 'Room\nVacancy', onTap: () => context.push('/home/classroom_vacancy'), body: [ - const SizedBox(height: 5), + SizedBox(height: 5), Consumer( builder: (_, ref, __) => Text( '${ref.read(roomProvider.notifier).getVacantCount()} Vacant', textAlign: TextAlign.center, - style: const TextStyle(fontSize: 14), + style: TextStyle(fontSize: 14), ), ), ], @@ -57,11 +66,12 @@ class Home extends ConsumerWidget { secondaryColor: Colors.lightBlueAccent.shade200, ), MenuTile( - title: "Lost\n&\nFound", - onTap: () => context.push('/home/lost_and_found'), - primaryColor: Colors.orangeAccent.shade100, - secondaryColor: Colors.orangeAccent.shade200, - icon: Icons.search), + title: "Lost\n&\nFound", + onTap: () => context.push('/home/lost_and_found'), + primaryColor: Colors.orangeAccent.shade100, + secondaryColor: Colors.orangeAccent.shade200, + icon: Icons.search, + ), MenuTile( title: 'Broadcast', onTap: () { @@ -78,64 +88,84 @@ class Home extends ConsumerWidget { ); } } +// import 'package:flutter/material.dart'; +// import 'package:go_router/go_router.dart'; +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import 'package:smart_insti_app/components/menu_tile.dart'; +// import '../constants/constants.dart'; +// import '../provider/student_provider.dart'; +// import '../provider/room_provider.dart'; // class Home extends ConsumerWidget { -// const Home({Key? key}); +// const Home({super.key}); // @override // Widget build(BuildContext context, WidgetRef ref) { // final student = ref.read(studentProvider); - // return SafeArea( // child: Scaffold( // appBar: AppBar( // title: const Text( // AppConstants.appName, -// // style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), // ), // backgroundColor: Colors.lightBlueAccent, +// actions: [ +// IconButton( +// icon: const Icon(Icons.person), +// onPressed: () { +// context.push('/user_profile'); +// }, +// ), +// IconButton( +// icon: const Icon(Icons.admin_panel_settings), +// onPressed: () { +// context.push('/admin_home'); +// }, +// ), +// ], // ), -// body: Padding( -// padding: const EdgeInsets.all(16.0), -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Align( -// alignment: Alignment.centerRight, -// child: Padding( -// padding: const EdgeInsets.only(right: 8.0), -// child: GestureDetector( -// onTap: () { -// context.push('/user_profile'); -// }, -// child: Container( -// width: 50, -// height: 50, -// decoration: const BoxDecoration( -// shape: BoxShape.circle, -// color: Colors.lightBlue, -// ), -// child: const Icon( -// Icons.person, -// color: Colors.white, -// ), -// ), +// body: GridView.count( +// padding: const EdgeInsets.all(10), +// crossAxisCount: 2, +// children: [ +// MenuTile( +// title: 'Room\nVacancy', +// onTap: () => context.push('/home/classroom_vacancy'), +// body: [ +// const SizedBox(height: 5), +// Consumer( +// builder: (_, ref, __) => Text( +// '${ref.read(roomProvider.notifier).getVacantCount()} Vacant', +// textAlign: TextAlign.center, +// style: const TextStyle(fontSize: 14), // ), // ), -// ), -// const SizedBox(height: 16), -// Text( -// 'Welcome, ${student.name}!', -// style: -// const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), -// ), -// const SizedBox(height: 16), -// const Text('Tap the icon to view your profile.'), -// ], -// ), +// ], +// icon: Icons.class_, +// primaryColor: Colors.lightBlueAccent.shade100, +// secondaryColor: Colors.lightBlueAccent.shade200, +// ), +// MenuTile( +// title: "Lost\n&\nFound", +// onTap: () => context.push('/home/lost_and_found'), +// primaryColor: Colors.orangeAccent.shade100, +// secondaryColor: Colors.orangeAccent.shade200, +// icon: Icons.search), +// MenuTile( +// title: 'Broadcast', +// onTap: () { +// // Navigate to the broadcast page +// context.push('/broadcast'); +// }, +// icon: Icons.announcement, +// primaryColor: Colors.greenAccent.shade100, +// secondaryColor: Colors.greenAccent.shade200, +// ), +// ], // ), // ), // ); // } // } + diff --git a/frontend/lib/screens/notifications.dart b/frontend/lib/screens/notifications.dart new file mode 100644 index 0000000..4f62e4a --- /dev/null +++ b/frontend/lib/screens/notifications.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../provider/notifications_provider.dart'; + +class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { + @override + Widget build(BuildContext context, WidgetRef ref) { + // Read notifications from the provider + final notifications = ref.watch(notificationsProvider); + + // Generate dummy notifications when the page is first built + WidgetsBinding.instance?.addPostFrameCallback((_) { + ref.read(notificationsProvider.notifier).generateDummyNotifications(); + }); + + return Scaffold( + appBar: AppBar( + title: Text('Notifications'), + ), + body: ListView.builder( + itemCount: notifications.length, + itemBuilder: (context, index) { + final notification = notifications[index]; + return ListTile( + title: Text(notification.message), + ); + }, + ), + ); + } +} + +// import 'package:flutter/material.dart'; +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import '../provider/notifications_provider.dart'; + +// class NotificationsPage extends ConsumerWidget { +// @override +// Widget build(BuildContext context, WidgetRef ref) { +// // Read notifications from the provider +// final notifications = ref.watch(notificationsProvider); + +// return Scaffold( +// appBar: AppBar( +// title: Text('Notifications'), +// ), +// body: ListView.builder( +// itemCount: notifications.length, +// itemBuilder: (context, index) { +// final notification = notifications[index]; +// return ListTile( +// title: Text(notification.message), +// ); +// }, +// ), +// ); +// } +// } From 69191d2ed593cdcb87639a6b002d43f6af4365a5 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Mon, 12 Feb 2024 01:55:11 +0530 Subject: [PATCH 08/20] ui change --- frontend/lib/screens/notifications.dart | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/lib/screens/notifications.dart b/frontend/lib/screens/notifications.dart index 4f62e4a..e0ba2a2 100644 --- a/frontend/lib/screens/notifications.dart +++ b/frontend/lib/screens/notifications.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../provider/notifications_provider.dart'; +import '../models/notifications_schema.dart'; class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { @override @@ -16,13 +17,21 @@ class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { return Scaffold( appBar: AppBar( title: Text('Notifications'), + backgroundColor: Colors.blue, // Change app bar color to blue ), body: ListView.builder( - itemCount: notifications.length, + itemCount: notifications.length > 5 ? 5 : notifications.length, itemBuilder: (context, index) { final notification = notifications[index]; - return ListTile( - title: Text(notification.message), + return Card( + elevation: 4, + margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: ListTile( + title: Text( + notification.message, + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), ); }, ), @@ -30,6 +39,8 @@ class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { } } + + // import 'package:flutter/material.dart'; // import 'package:flutter_riverpod/flutter_riverpod.dart'; // import '../provider/notifications_provider.dart'; From 7e7b889f7eaa5f3f28fdf8aec4eb393cc71c2ba4 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Mon, 12 Feb 2024 02:05:50 +0530 Subject: [PATCH 09/20] schema updated --- frontend/lib/models/notifications_schema.dart | 3 +- .../lib/provider/notifications_provider.dart | 19 +++++--- frontend/lib/screens/notifications.dart | 44 +++++-------------- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/frontend/lib/models/notifications_schema.dart b/frontend/lib/models/notifications_schema.dart index 452fa48..2aab73b 100644 --- a/frontend/lib/models/notifications_schema.dart +++ b/frontend/lib/models/notifications_schema.dart @@ -1,5 +1,6 @@ class NotificationModel { final String message; + final DateTime date; - NotificationModel({required this.message}); + NotificationModel({required this.message, required this.date}); } diff --git a/frontend/lib/provider/notifications_provider.dart b/frontend/lib/provider/notifications_provider.dart index dadf208..88d1c5e 100644 --- a/frontend/lib/provider/notifications_provider.dart +++ b/frontend/lib/provider/notifications_provider.dart @@ -9,14 +9,23 @@ final notificationsProvider = class NotificationsNotifier extends StateNotifier> { NotificationsNotifier() : super([]); - void addNotification(String message) { - state = [...state, NotificationModel(message: 'message1')]; + void addNotification(String message, DateTime date) { + state = [ + ...state, + NotificationModel(message: message, date: date ?? DateTime.now()) + ]; } // Method to generate dummy notifications void generateDummyNotifications() { - addNotification('Notification 1'); - addNotification('Notification 2'); - addNotification('Notification 3'); + addNotification('Notification 1', DateTime(2004, 9, 7, 17, 30)); + addNotification('Notification 2', DateTime(2004, 9, 8, 9, 45)); + addNotification('Notification 3', DateTime(2004, 9, 9, 12, 0)); + addNotification('Notification 4', DateTime(2004, 9, 7, 17, 30)); + addNotification('Notification 5', DateTime(2004, 9, 8, 9, 45)); + addNotification('Notification 6', DateTime(2004, 9, 9, 12, 0)); + addNotification('Notification 7', DateTime(2004, 9, 7, 17, 30)); + addNotification('Notification 8', DateTime(2004, 9, 8, 9, 45)); + addNotification('Notification 9', DateTime(2004, 9, 9, 12, 0)); } } diff --git a/frontend/lib/screens/notifications.dart b/frontend/lib/screens/notifications.dart index e0ba2a2..58f24eb 100644 --- a/frontend/lib/screens/notifications.dart +++ b/frontend/lib/screens/notifications.dart @@ -6,10 +6,8 @@ import '../models/notifications_schema.dart'; class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { @override Widget build(BuildContext context, WidgetRef ref) { - // Read notifications from the provider final notifications = ref.watch(notificationsProvider); - // Generate dummy notifications when the page is first built WidgetsBinding.instance?.addPostFrameCallback((_) { ref.read(notificationsProvider.notifier).generateDummyNotifications(); }); @@ -17,10 +15,10 @@ class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { return Scaffold( appBar: AppBar( title: Text('Notifications'), - backgroundColor: Colors.blue, // Change app bar color to blue + backgroundColor: Colors.blue, ), body: ListView.builder( - itemCount: notifications.length > 5 ? 5 : notifications.length, + itemCount: notifications.length > 9 ? 9 : notifications.length, itemBuilder: (context, index) { final notification = notifications[index]; return Card( @@ -31,39 +29,19 @@ class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { notification.message, style: TextStyle(fontWeight: FontWeight.bold), ), + subtitle: Text( + _formatDateTime(notification.date), + style: TextStyle(color: Colors.grey), + ), ), ); }, ), ); } -} - - -// import 'package:flutter/material.dart'; -// import 'package:flutter_riverpod/flutter_riverpod.dart'; -// import '../provider/notifications_provider.dart'; - -// class NotificationsPage extends ConsumerWidget { -// @override -// Widget build(BuildContext context, WidgetRef ref) { -// // Read notifications from the provider -// final notifications = ref.watch(notificationsProvider); - -// return Scaffold( -// appBar: AppBar( -// title: Text('Notifications'), -// ), -// body: ListView.builder( -// itemCount: notifications.length, -// itemBuilder: (context, index) { -// final notification = notifications[index]; -// return ListTile( -// title: Text(notification.message), -// ); -// }, -// ), -// ); -// } -// } + // Function to format DateTime object to display in ListTile + String _formatDateTime(DateTime dateTime) { + return '${dateTime.day}/${dateTime.month}/${dateTime.year} ${dateTime.hour}:${dateTime.minute}'; + } +} From 3267b227f3a5c8dbe55fea8217e12e42f5639247 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Mon, 12 Feb 2024 02:08:22 +0530 Subject: [PATCH 10/20] removed redundant code --- frontend/lib/routes/routes.dart | 140 +------------------------------- frontend/lib/screens/home.dart | 81 ------------------ 2 files changed, 1 insertion(+), 220 deletions(-) diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index e6bed1c..296836d 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -93,142 +93,4 @@ final GoRouter routes = GoRouter( ], ), ], -);// import 'package:flutter/material.dart'; -// import 'package:go_router/go_router.dart'; -// import 'package:smart_insti_app/screens/admin/add_courses.dart'; -// import 'package:smart_insti_app/screens/admin/add_students.dart'; -// import 'package:smart_insti_app/screens/admin/admin_home.dart'; -// import 'package:smart_insti_app/screens/admin/manage_rooms.dart'; -// import 'package:smart_insti_app/screens/admin/view_students.dart'; -// import 'package:smart_insti_app/screens/home.dart'; -// import 'package:smart_insti_app/screens/lost_and_found.dart'; -// import '../screens/admin/add_faculty.dart'; -// import '../screens/admin/add_menu.dart'; -// import '../screens/admin/view_courses.dart'; -// import '../screens/admin/view_faculty.dart'; -// import '../screens/admin/view_menu.dart'; -// import '../screens/user_profile.dart'; -// import '../screens/auth/signin_page.dart'; -// import '../screens/room_vacancy.dart'; -// import '../screens/broadcast.dart'; - -// final GoRouter routes = GoRouter( -// // initialLocation: '/home', -// routes: [ -// GoRoute( -// path: '/', -// pageBuilder: (context, state) => const MaterialPage(child: Home()), -// // pageBuilder: (context, state) => MaterialPage(child: SignIn()), -// routes: [ -// GoRoute( -// path: 'broadcast', -// pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), -// ), -// GoRoute( -// path: 'user_profile', -// pageBuilder: (context, state) => -// const MaterialPage(child: UserProfile()), -// ), -// GoRoute( -// path: 'admin_home', -// pageBuilder: (context, state) => -// const MaterialPage(child: AdminHome()), -// routes: [ -// GoRoute( -// path: 'add_students', -// pageBuilder: (context, state) => -// MaterialPage(child: AddStudents()), -// ), -// GoRoute( -// path: 'add_faculty', -// pageBuilder: (context, state) => -// MaterialPage(child: AddFaculty()), -// ), -// GoRoute( -// path: 'add_courses', -// pageBuilder: (context, state) => -// MaterialPage(child: AddCourses()), -// ), -// GoRoute( -// path: 'view_students', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewStudents()), -// ), -// GoRoute( -// path: 'view_faculty', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewFaculty()), -// ), -// GoRoute( -// path: 'view_courses', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewCourses()), -// ), -// GoRoute( -// path: 'add_menu', -// pageBuilder: (context, state) => -// MaterialPage(child: AddMessMenu()), -// ), -// GoRoute( -// path: 'view_menu', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewMessMenu()), -// ), -// GoRoute( -// path: 'manage_rooms', -// pageBuilder: (context, state) => -// MaterialPage(child: ManageRooms()), -// ) -// ], -// ), -// ], -// ), -// ], -// ); - -// final GoRouter routes = GoRouter( -// routes: [ -// GoRoute( -// path: '/', -// pageBuilder: (context, state) => const MaterialPage(child: AdminHome()), -// routes: [ -// GoRoute( -// path: 'add_students', -// pageBuilder: (context, state) => MaterialPage(child: AddStudents()), -// ), -// GoRoute( -// path: 'add_faculty', -// pageBuilder: (context, state) => MaterialPage(child: AddFaculty()), -// ), -// GoRoute( -// path: 'add_courses', -// pageBuilder: (context, state) => MaterialPage(child: AddCourses()), -// ), -// GoRoute( -// path: 'view_students', -// pageBuilder: (context, state) => MaterialPage(child: ViewStudents()), -// ), -// GoRoute( -// path: 'view_faculty', -// pageBuilder: (context, state) => MaterialPage(child: ViewFaculty()), -// ), -// GoRoute( -// path: 'view_courses', -// pageBuilder: (context, state) => MaterialPage(child: ViewCourses()), -// ), -// GoRoute( -// path: 'add_menu', -// pageBuilder: (context, state) => MaterialPage(child: AddMessMenu()), -// ), -// GoRoute( -// path: 'view_menu', -// pageBuilder: (context, state) => MaterialPage(child: ViewMessMenu()), -// ), -// GoRoute( -// path: 'manage_rooms', -// pageBuilder: (context, state) => MaterialPage(child: ManageRooms()), -// ) -// ], -// ) -// ], -// ); +); diff --git a/frontend/lib/screens/home.dart b/frontend/lib/screens/home.dart index af52731..52c2a9d 100644 --- a/frontend/lib/screens/home.dart +++ b/frontend/lib/screens/home.dart @@ -88,84 +88,3 @@ class Home extends ConsumerWidget { ); } } -// import 'package:flutter/material.dart'; -// import 'package:go_router/go_router.dart'; -// import 'package:flutter_riverpod/flutter_riverpod.dart'; -// import 'package:smart_insti_app/components/menu_tile.dart'; -// import '../constants/constants.dart'; -// import '../provider/student_provider.dart'; - -// import '../provider/room_provider.dart'; - -// class Home extends ConsumerWidget { -// const Home({super.key}); - -// @override -// Widget build(BuildContext context, WidgetRef ref) { -// final student = ref.read(studentProvider); -// return SafeArea( -// child: Scaffold( -// appBar: AppBar( -// title: const Text( -// AppConstants.appName, -// ), -// backgroundColor: Colors.lightBlueAccent, -// actions: [ -// IconButton( -// icon: const Icon(Icons.person), -// onPressed: () { -// context.push('/user_profile'); -// }, -// ), -// IconButton( -// icon: const Icon(Icons.admin_panel_settings), -// onPressed: () { -// context.push('/admin_home'); -// }, -// ), -// ], -// ), -// body: GridView.count( -// padding: const EdgeInsets.all(10), -// crossAxisCount: 2, -// children: [ -// MenuTile( -// title: 'Room\nVacancy', -// onTap: () => context.push('/home/classroom_vacancy'), -// body: [ -// const SizedBox(height: 5), -// Consumer( -// builder: (_, ref, __) => Text( -// '${ref.read(roomProvider.notifier).getVacantCount()} Vacant', -// textAlign: TextAlign.center, -// style: const TextStyle(fontSize: 14), -// ), -// ), -// ], -// icon: Icons.class_, -// primaryColor: Colors.lightBlueAccent.shade100, -// secondaryColor: Colors.lightBlueAccent.shade200, -// ), -// MenuTile( -// title: "Lost\n&\nFound", -// onTap: () => context.push('/home/lost_and_found'), -// primaryColor: Colors.orangeAccent.shade100, -// secondaryColor: Colors.orangeAccent.shade200, -// icon: Icons.search), -// MenuTile( -// title: 'Broadcast', -// onTap: () { -// // Navigate to the broadcast page -// context.push('/broadcast'); -// }, -// icon: Icons.announcement, -// primaryColor: Colors.greenAccent.shade100, -// secondaryColor: Colors.greenAccent.shade200, -// ), -// ], -// ), -// ), -// ); -// } -// } - From 8f55d65f6d511cefab2a2ed2d174285040fe0787 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Tue, 13 Feb 2024 02:45:08 +0530 Subject: [PATCH 11/20] removed notifications screen --- frontend/lib/models/notifications_schema.dart | 6 --- .../lib/provider/notifications_provider.dart | 31 ------------ frontend/lib/routes/routes.dart | 6 --- frontend/lib/screens/home.dart | 9 ---- frontend/lib/screens/notifications.dart | 47 ------------------- 5 files changed, 99 deletions(-) delete mode 100644 frontend/lib/models/notifications_schema.dart delete mode 100644 frontend/lib/provider/notifications_provider.dart delete mode 100644 frontend/lib/screens/notifications.dart diff --git a/frontend/lib/models/notifications_schema.dart b/frontend/lib/models/notifications_schema.dart deleted file mode 100644 index 2aab73b..0000000 --- a/frontend/lib/models/notifications_schema.dart +++ /dev/null @@ -1,6 +0,0 @@ -class NotificationModel { - final String message; - final DateTime date; - - NotificationModel({required this.message, required this.date}); -} diff --git a/frontend/lib/provider/notifications_provider.dart b/frontend/lib/provider/notifications_provider.dart deleted file mode 100644 index 88d1c5e..0000000 --- a/frontend/lib/provider/notifications_provider.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../models/notifications_schema.dart'; - -final notificationsProvider = - StateNotifierProvider>( - (ref) => NotificationsNotifier(), -); - -class NotificationsNotifier extends StateNotifier> { - NotificationsNotifier() : super([]); - - void addNotification(String message, DateTime date) { - state = [ - ...state, - NotificationModel(message: message, date: date ?? DateTime.now()) - ]; - } - - // Method to generate dummy notifications - void generateDummyNotifications() { - addNotification('Notification 1', DateTime(2004, 9, 7, 17, 30)); - addNotification('Notification 2', DateTime(2004, 9, 8, 9, 45)); - addNotification('Notification 3', DateTime(2004, 9, 9, 12, 0)); - addNotification('Notification 4', DateTime(2004, 9, 7, 17, 30)); - addNotification('Notification 5', DateTime(2004, 9, 8, 9, 45)); - addNotification('Notification 6', DateTime(2004, 9, 9, 12, 0)); - addNotification('Notification 7', DateTime(2004, 9, 7, 17, 30)); - addNotification('Notification 8', DateTime(2004, 9, 8, 9, 45)); - addNotification('Notification 9', DateTime(2004, 9, 9, 12, 0)); - } -} diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 296836d..f80d295 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -8,7 +8,6 @@ import 'package:smart_insti_app/screens/admin/view_students.dart'; import 'package:smart_insti_app/screens/broadcast.dart'; import 'package:smart_insti_app/screens/home.dart'; import 'package:smart_insti_app/screens/lost_and_found.dart'; -import 'package:smart_insti_app/screens/notifications.dart'; import '../screens/admin/add_faculty.dart'; import '../screens/admin/add_menu.dart'; import '../screens/admin/view_courses.dart'; @@ -85,11 +84,6 @@ final GoRouter routes = GoRouter( ) ], ), - GoRoute( - path: 'notifications', - pageBuilder: (context, state) => - MaterialPage(child: NotificationsPage()), - ), ], ), ], diff --git a/frontend/lib/screens/home.dart b/frontend/lib/screens/home.dart index 52c2a9d..76c75bb 100644 --- a/frontend/lib/screens/home.dart +++ b/frontend/lib/screens/home.dart @@ -5,7 +5,6 @@ import 'package:smart_insti_app/components/menu_tile.dart'; import '../constants/constants.dart'; import '../provider/student_provider.dart'; import '../provider/room_provider.dart'; -import '../screens/notifications.dart'; class Home extends ConsumerWidget { const Home({Key? key}); @@ -22,14 +21,6 @@ class Home extends ConsumerWidget { ), backgroundColor: Colors.lightBlueAccent, actions: [ - // Icon for Notifications Page - IconButton( - icon: Icon(Icons.notifications), - onPressed: () { - // Navigate to notifications page - context.push('/notifications'); - }, - ), IconButton( icon: Icon(Icons.person), onPressed: () { diff --git a/frontend/lib/screens/notifications.dart b/frontend/lib/screens/notifications.dart deleted file mode 100644 index 58f24eb..0000000 --- a/frontend/lib/screens/notifications.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../provider/notifications_provider.dart'; -import '../models/notifications_schema.dart'; - -class NotificationsPage extends ConsumerWidget with WidgetsBindingObserver { - @override - Widget build(BuildContext context, WidgetRef ref) { - final notifications = ref.watch(notificationsProvider); - - WidgetsBinding.instance?.addPostFrameCallback((_) { - ref.read(notificationsProvider.notifier).generateDummyNotifications(); - }); - - return Scaffold( - appBar: AppBar( - title: Text('Notifications'), - backgroundColor: Colors.blue, - ), - body: ListView.builder( - itemCount: notifications.length > 9 ? 9 : notifications.length, - itemBuilder: (context, index) { - final notification = notifications[index]; - return Card( - elevation: 4, - margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - child: ListTile( - title: Text( - notification.message, - style: TextStyle(fontWeight: FontWeight.bold), - ), - subtitle: Text( - _formatDateTime(notification.date), - style: TextStyle(color: Colors.grey), - ), - ), - ); - }, - ), - ); - } - - // Function to format DateTime object to display in ListTile - String _formatDateTime(DateTime dateTime) { - return '${dateTime.day}/${dateTime.month}/${dateTime.year} ${dateTime.hour}:${dateTime.minute}'; - } -} From 611040c307d53fa841055d22b3ac249373cb524f Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Tue, 13 Feb 2024 12:40:41 +0530 Subject: [PATCH 12/20] env configured --- frontend/.env | 1 + 1 file changed, 1 insertion(+) create mode 100644 frontend/.env diff --git a/frontend/.env b/frontend/.env new file mode 100644 index 0000000..d20fa3e --- /dev/null +++ b/frontend/.env @@ -0,0 +1 @@ +BACKEND_DOMAIN='http://10.0.2.2:3000' \ No newline at end of file From 22190e021f1282672f82fb90d75df508375e1b76 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Tue, 13 Feb 2024 18:07:57 +0530 Subject: [PATCH 13/20] pubspec.lock updated --- frontend/pubspec.lock | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index 2d997b4..643a17e 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -266,7 +266,7 @@ packages: dependency: transitive description: name: flutter_animate - sha256: "7c8a6594a9252dad30cc2ef16e33270b6248c4dedc3b3d06c86c4f3f4dc05ae5" + sha256: "2f3535790fff1ad21bca4f16b7435fa4af6a3c4b43e88e273a8683ed4ec26b26" url: "https://pub.dev" source: hosted version: "4.4.0" @@ -398,14 +398,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" - flutter_shaders: - dependency: transitive - description: - name: flutter_shaders - sha256: "02750b545c01ff4d8e9bbe8f27a7731aa3778402506c67daa1de7f5fc3f4befe" - url: "https://pub.dev" - source: hosted - version: "0.1.2" flutter_svg: dependency: transitive description: From a0c1d695dea46c7a9f8b4dab8151d59e5bccc105 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Tue, 13 Feb 2024 19:44:30 +0530 Subject: [PATCH 14/20] routes changed --- frontend/lib/routes/routes.dart | 287 ++++++++++++++++++++++---------- 1 file changed, 202 insertions(+), 85 deletions(-) diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 7af92c4..80e0651 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -6,137 +6,254 @@ import 'package:smart_insti_app/screens/admin/admin_home.dart'; import 'package:smart_insti_app/screens/admin/manage_rooms.dart'; import 'package:smart_insti_app/screens/admin/view_students.dart'; import 'package:smart_insti_app/screens/broadcast.dart'; -import 'package:smart_insti_app/screens/auth/user_login.dart'; +import 'package:smart_insti_app/screens/home.dart'; import 'package:smart_insti_app/screens/lost_and_found.dart'; import '../screens/admin/add_faculty.dart'; import '../screens/admin/add_menu.dart'; import '../screens/admin/view_courses.dart'; import '../screens/admin/view_faculty.dart'; import '../screens/admin/view_menu.dart'; +import '../screens/auth/signin_page.dart'; import '../screens/room_vacancy.dart'; import '../screens/user_profile.dart'; -import '../screens/auth/admin_login.dart'; -import '../screens/user/user_home.dart'; -import '../screens/user/faculty_profile.dart'; -import '../screens/user/student_profile.dart'; +import '../screens/auth/signin_page.dart'; final GoRouter routes = GoRouter( - initialLocation: '/', + initialLocation: '/home', routes: [ GoRoute( path: '/', - pageBuilder: (context, state) => MaterialPage(child: UserLogin()), + // pageBuilder: (context, state) => MaterialPage(child: SignIn()), + pageBuilder: (context, state) => const MaterialPage(child: Home()), routes: [ GoRoute( - path: 'user_home', - pageBuilder: (context, state) => MaterialPage(child: UserHome()), + path: 'broadcast', + pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), + ), + GoRoute( + path: 'user_profile', + pageBuilder: (context, state) => + const MaterialPage(child: UserProfile()), + ), + GoRoute( + path: 'admin_home', + pageBuilder: (context, state) => + const MaterialPage(child: AdminHome()), routes: [ GoRoute( - path: 'view_students', + path: 'add_students', pageBuilder: (context, state) => - MaterialPage(child: ViewStudents()), + MaterialPage(child: AddStudents()), ), GoRoute( - path: 'view_faculty', + path: 'add_faculty', pageBuilder: (context, state) => - MaterialPage(child: ViewFaculty()), + MaterialPage(child: AddFaculty()), ), GoRoute( - path: 'view_courses', + path: 'add_courses', pageBuilder: (context, state) => - MaterialPage(child: ViewCourses()), + MaterialPage(child: AddCourses()), ), GoRoute( - path: 'view_menu', + path: 'view_students', pageBuilder: (context, state) => - MaterialPage(child: ViewMessMenu()), + MaterialPage(child: ViewStudents()), ), GoRoute( - path: 'classroom_vacancy', + path: 'view_faculty', pageBuilder: (context, state) => - const MaterialPage(child: RoomVacancy()), + MaterialPage(child: ViewFaculty()), ), GoRoute( - path: 'lost_and_found', + path: 'view_courses', pageBuilder: (context, state) => - MaterialPage(child: LostAndFound()), + MaterialPage(child: ViewCourses()), ), GoRoute( - path: 'manage_rooms', + path: 'add_menu', pageBuilder: (context, state) => - MaterialPage(child: ManageRooms()), + MaterialPage(child: AddMessMenu()), ), GoRoute( - path: 'student_profile', + path: 'view_menu', pageBuilder: (context, state) => - MaterialPage(child: StudentProfile()), + MaterialPage(child: ViewMessMenu()), ), GoRoute( - path: 'faculty_profile', + path: 'manage_rooms', pageBuilder: (context, state) => - MaterialPage(child: FacultyProfile()), - ), + MaterialPage(child: ManageRooms()), + ) ], ), + ], + ), + GoRoute( + path: '/home', + pageBuilder: (context, state) => const MaterialPage(child: Home()), + routes: [ + GoRoute( + path: 'classroom_vacancy', + pageBuilder: (context, state) => + const MaterialPage(child: RoomVacancy()), + ), GoRoute( - path: 'admin_login', - pageBuilder: (context, state) => MaterialPage(child: AdminLogin()), - routes: [ - GoRoute( - path: 'admin_home', - pageBuilder: (context, state) => - const MaterialPage(child: AdminHome()), - routes: [ - GoRoute( - path: 'add_students', - pageBuilder: (context, state) => - MaterialPage(child: AddStudents()), - ), - GoRoute( - path: 'add_faculty', - pageBuilder: (context, state) => - MaterialPage(child: AddFaculty()), - ), - GoRoute( - path: 'add_courses', - pageBuilder: (context, state) => - MaterialPage(child: AddCourses()), - ), - GoRoute( - path: 'view_students', - pageBuilder: (context, state) => - MaterialPage(child: ViewStudents()), - ), - GoRoute( - path: 'view_faculty', - pageBuilder: (context, state) => - MaterialPage(child: ViewFaculty()), - ), - GoRoute( - path: 'view_courses', - pageBuilder: (context, state) => - MaterialPage(child: ViewCourses()), - ), - GoRoute( - path: 'add_menu', - pageBuilder: (context, state) => - MaterialPage(child: AddMessMenu()), - ), - GoRoute( - path: 'view_menu', - pageBuilder: (context, state) => - MaterialPage(child: ViewMessMenu()), - ), - GoRoute( - path: 'manage_rooms', - pageBuilder: (context, state) => - MaterialPage(child: ManageRooms()), - ), - ], - ), - ], + path: 'lost_and_found', + pageBuilder: (context, state) => MaterialPage(child: LostAndFound()), ), ], ), ], -); +);// import 'package:flutter/material.dart'; +// import 'package:go_router/go_router.dart'; +// import 'package:smart_insti_app/screens/admin/add_courses.dart'; +// import 'package:smart_insti_app/screens/admin/add_students.dart'; +// import 'package:smart_insti_app/screens/admin/admin_home.dart'; +// import 'package:smart_insti_app/screens/admin/manage_rooms.dart'; +// import 'package:smart_insti_app/screens/admin/view_students.dart'; +// import 'package:smart_insti_app/screens/broadcast.dart'; +// import 'package:smart_insti_app/screens/auth/user_login.dart'; +// import 'package:smart_insti_app/screens/lost_and_found.dart'; +// import '../screens/admin/add_faculty.dart'; +// import '../screens/admin/add_menu.dart'; +// import '../screens/admin/view_courses.dart'; +// import '../screens/admin/view_faculty.dart'; +// import '../screens/admin/view_menu.dart'; +// import '../screens/room_vacancy.dart'; +// import '../screens/user_profile.dart'; +// import '../screens/auth/admin_login.dart'; +// import '../screens/user/user_home.dart'; +// import '../screens/user/faculty_profile.dart'; +// import '../screens/user/student_profile.dart'; + +// final GoRouter routes = GoRouter( +// initialLocation: '/', +// routes: [ +// GoRoute( +// path: '/', +// pageBuilder: (context, state) => MaterialPage(child: UserLogin()), +// routes: [ +// GoRoute( +// path: 'user_home', +// pageBuilder: (context, state) => MaterialPage(child: UserHome()), +// routes: [ +// GoRoute( +// path: 'view_students', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewStudents()), +// ), +// GoRoute( +// path: 'view_faculty', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewFaculty()), +// ), +// GoRoute( +// path: 'view_courses', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewCourses()), +// ), +// GoRoute( +// path: 'view_menu', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewMessMenu()), +// ), +// GoRoute( +// path: 'classroom_vacancy', +// pageBuilder: (context, state) => +// const MaterialPage(child: RoomVacancy()), +// ), +// GoRoute( +// path: 'lost_and_found', +// pageBuilder: (context, state) => +// MaterialPage(child: LostAndFound()), +// ), +// GoRoute( +// path: 'manage_rooms', +// pageBuilder: (context, state) => +// MaterialPage(child: ManageRooms()), +// ), +// GoRoute( +// path: 'student_profile', +// pageBuilder: (context, state) => +// MaterialPage(child: StudentProfile()), +// ), +// GoRoute( +// path: 'faculty_profile', +// pageBuilder: (context, state) => +// MaterialPage(child: FacultyProfile()), +// ), +// GoRoute( +// path: 'broadcast', +// pageBuilder: (context, state) => +// MaterialPage(child: BroadcastPage()), +// ), +// GoRoute( +// path: 'user_profile', +// pageBuilder: (context, state) => +// const MaterialPage(child: UserProfile()), +// ), +// ], +// ), +// GoRoute( +// path: 'admin_login', +// pageBuilder: (context, state) => MaterialPage(child: AdminLogin()), +// routes: [ +// GoRoute( +// path: 'admin_home', +// pageBuilder: (context, state) => +// const MaterialPage(child: AdminHome()), +// routes: [ +// GoRoute( +// path: 'add_students', +// pageBuilder: (context, state) => +// MaterialPage(child: AddStudents()), +// ), +// GoRoute( +// path: 'add_faculty', +// pageBuilder: (context, state) => +// MaterialPage(child: AddFaculty()), +// ), +// GoRoute( +// path: 'add_courses', +// pageBuilder: (context, state) => +// MaterialPage(child: AddCourses()), +// ), +// GoRoute( +// path: 'view_students', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewStudents()), +// ), +// GoRoute( +// path: 'view_faculty', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewFaculty()), +// ), +// GoRoute( +// path: 'view_courses', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewCourses()), +// ), +// GoRoute( +// path: 'add_menu', +// pageBuilder: (context, state) => +// MaterialPage(child: AddMessMenu()), +// ), +// GoRoute( +// path: 'view_menu', +// pageBuilder: (context, state) => +// MaterialPage(child: ViewMessMenu()), +// ), +// GoRoute( +// path: 'manage_rooms', +// pageBuilder: (context, state) => +// MaterialPage(child: ManageRooms()), +// ), +// ], +// ), +// ], +// ), +// ], +// ), +// ], +// ); From 984c31effefeaf64328e8731437b7ec3f2a44d77 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Wed, 14 Feb 2024 12:36:33 +0530 Subject: [PATCH 15/20] home to user_home , routes changes , broadcast feature added --- frontend/lib/provider/home_provider.dart | 10 ++ frontend/lib/routes/routes.dart | 48 ++++++---- frontend/lib/screens/broadcast.dart | 115 ++++++++++++----------- frontend/lib/screens/home.dart | 81 ---------------- 4 files changed, 102 insertions(+), 152 deletions(-) delete mode 100644 frontend/lib/screens/home.dart diff --git a/frontend/lib/provider/home_provider.dart b/frontend/lib/provider/home_provider.dart index 39b57b1..d1d7540 100644 --- a/frontend/lib/provider/home_provider.dart +++ b/frontend/lib/provider/home_provider.dart @@ -78,6 +78,16 @@ class UserProvider extends StateNotifier { secondaryColor: Colors.orangeAccent.shade200, icon: Icons.search, ), + MenuTile( + title: 'Broadcast', + onTap: () { + // Navigate to the broadcast page + context.push('/user_home/broadcast'); + }, + icon: Icons.announcement, + primaryColor: Colors.greenAccent.shade100, + secondaryColor: Colors.greenAccent.shade200, + ), ]; String query = state.searchController.text; state = state.copyWith( diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 236a013..5476bf9 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -14,13 +14,16 @@ import '../screens/admin/admin_profile.dart'; import '../screens/admin/view_courses.dart'; import '../screens/admin/view_faculty.dart'; import '../screens/admin/view_menu.dart'; -import '../screens/auth/signin_page.dart'; +import '../screens/auth/admin_login.dart'; import '../screens/user/room_vacancy.dart'; import '../screens/user_profile.dart'; -import '../screens/auth/signin_page.dart'; +import '../screens/user/student_profile.dart'; +import '../screens/user/user_home.dart'; +import '../screens/user/faculty_profile.dart'; +import '../screens/broadcast.dart'; final GoRouter routes = GoRouter( - initialLocation: '/home', + initialLocation: '/user_home/broadcast', routes: [ GoRoute( path: '/', @@ -106,23 +109,36 @@ final GoRouter routes = GoRouter( path: 'lost_and_found', pageBuilder: (context, state) => MaterialPage(child: LostAndFound()), ), - ], - ), - GoRoute( - path: '/home', - pageBuilder: (context, state) => const MaterialPage(child: Home()), - routes: [ - GoRoute( - path: 'classroom_vacancy', - pageBuilder: (context, state) => - const MaterialPage(child: RoomVacancy()), - ), GoRoute( - path: 'lost_and_found', - pageBuilder: (context, state) => MaterialPage(child: LostAndFound()), + path: 'broadcast', + pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), ), ], ), + // GoRoute( + // path: '/home', + // pageBuilder: (context, state) => const MaterialPage(child: Home()), + // routes: [ + // GoRoute( + // path: 'classroom_vacancy', + // pageBuilder: (context, state) => + // const MaterialPage(child: RoomVacancy()), + // ), + // GoRoute( + // path: 'lost_and_found', + // pageBuilder: (context, state) => MaterialPage(child: LostAndFound()), + // ), + // GoRoute( + // path: 'broadcast', + // pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), + // ), + // GoRoute( + // path: 'user_profile', + // pageBuilder: (context, state) => + // const MaterialPage(child: UserProfile()), + // ), + // ], + // ), ], );// import 'package:flutter/material.dart'; // import 'package:go_router/go_router.dart'; diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/broadcast.dart index 4955f34..804bbc2 100644 --- a/frontend/lib/screens/broadcast.dart +++ b/frontend/lib/screens/broadcast.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:responsive_framework/responsive_framework.dart'; import 'package:smart_insti_app/provider/broadcast_provider.dart'; import 'package:smart_insti_app/models/broadcast_schema.dart'; @@ -8,67 +9,71 @@ class BroadcastPage extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final broadcasts = ref.watch(broadcastProvider); - return Scaffold( - appBar: AppBar( - title: const Text('Broadcasts'), - backgroundColor: Colors.blue, - ), - body: Container( - color: Colors.blue[50], - child: broadcasts.when( - data: (broadcasts) { - return SingleChildScrollView( - child: Column( - children: broadcasts.map((broadcast) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Card( - elevation: 4, - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - broadcast.title, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18.0, + return ResponsiveScaledBox( + width: 411, + child: Scaffold( + appBar: AppBar( + title: const Text('Broadcasts'), + backgroundColor: Colors.blue, + ), + body: Container( + color: Colors.blue[50], + child: broadcasts.when( + data: (broadcasts) { + return SingleChildScrollView( + child: Column( + children: broadcasts.map((broadcast) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + elevation: 4, + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + broadcast.title, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + ), ), - ), - Text( - '${broadcast.date.day}-${broadcast.date.month}-${broadcast.date.year}', - style: const TextStyle( - fontSize: 16.0, + Text( + '${broadcast.date.day}-${broadcast.date.month}-${broadcast.date.year}', + style: const TextStyle( + fontSize: 16.0, + ), ), + ], + ), + const SizedBox(height: 8.0), + Text( + broadcast.body, + style: const TextStyle( + fontSize: 16.0, ), - ], - ), - const SizedBox(height: 8.0), - Text( - broadcast.body, - style: const TextStyle( - fontSize: 16.0, ), - ), - ], + ], + ), ), ), - ), - ); - }).toList(), - ), - ); - }, - loading: () => const Center(child: CircularProgressIndicator()), - error: (error, stackTrace) => Center(child: Text('Error: $error')), + ); + }).toList(), + ), + ); + }, + loading: () => const Center(child: CircularProgressIndicator()), + error: (error, stackTrace) => Center(child: Text('Error: $error')), + ), ), ), ); diff --git a/frontend/lib/screens/home.dart b/frontend/lib/screens/home.dart deleted file mode 100644 index 76c75bb..0000000 --- a/frontend/lib/screens/home.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:smart_insti_app/components/menu_tile.dart'; -import '../constants/constants.dart'; -import '../provider/student_provider.dart'; -import '../provider/room_provider.dart'; - -class Home extends ConsumerWidget { - const Home({Key? key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final student = ref.read(studentProvider); - - return SafeArea( - child: Scaffold( - appBar: AppBar( - title: Text( - AppConstants.appName, - ), - backgroundColor: Colors.lightBlueAccent, - actions: [ - IconButton( - icon: Icon(Icons.person), - onPressed: () { - context.push('/user_profile'); - }, - ), - IconButton( - icon: Icon(Icons.admin_panel_settings), - onPressed: () { - context.push('/admin_home'); - }, - ), - ], - ), - body: GridView.count( - padding: const EdgeInsets.all(10), - crossAxisCount: 2, - children: [ - MenuTile( - title: 'Room\nVacancy', - onTap: () => context.push('/home/classroom_vacancy'), - body: [ - SizedBox(height: 5), - Consumer( - builder: (_, ref, __) => Text( - '${ref.read(roomProvider.notifier).getVacantCount()} Vacant', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 14), - ), - ), - ], - icon: Icons.class_, - primaryColor: Colors.lightBlueAccent.shade100, - secondaryColor: Colors.lightBlueAccent.shade200, - ), - MenuTile( - title: "Lost\n&\nFound", - onTap: () => context.push('/home/lost_and_found'), - primaryColor: Colors.orangeAccent.shade100, - secondaryColor: Colors.orangeAccent.shade200, - icon: Icons.search, - ), - MenuTile( - title: 'Broadcast', - onTap: () { - // Navigate to the broadcast page - context.push('/broadcast'); - }, - icon: Icons.announcement, - primaryColor: Colors.greenAccent.shade100, - secondaryColor: Colors.greenAccent.shade200, - ), - ], - ), - ), - ); - } -} From 2d93a8a68f7217ff34170c2a1856216d7f4eac20 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Wed, 14 Feb 2024 12:37:36 +0530 Subject: [PATCH 16/20] removed redundant code --- frontend/lib/routes/routes.dart | 177 +--------------------------- frontend/lib/screens/broadcast.dart | 97 --------------- 2 files changed, 1 insertion(+), 273 deletions(-) diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 5476bf9..df4a61e 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -115,180 +115,5 @@ final GoRouter routes = GoRouter( ), ], ), - // GoRoute( - // path: '/home', - // pageBuilder: (context, state) => const MaterialPage(child: Home()), - // routes: [ - // GoRoute( - // path: 'classroom_vacancy', - // pageBuilder: (context, state) => - // const MaterialPage(child: RoomVacancy()), - // ), - // GoRoute( - // path: 'lost_and_found', - // pageBuilder: (context, state) => MaterialPage(child: LostAndFound()), - // ), - // GoRoute( - // path: 'broadcast', - // pageBuilder: (context, state) => MaterialPage(child: BroadcastPage()), - // ), - // GoRoute( - // path: 'user_profile', - // pageBuilder: (context, state) => - // const MaterialPage(child: UserProfile()), - // ), - // ], - // ), ], -);// import 'package:flutter/material.dart'; -// import 'package:go_router/go_router.dart'; -// import 'package:smart_insti_app/screens/admin/add_courses.dart'; -// import 'package:smart_insti_app/screens/admin/add_students.dart'; -// import 'package:smart_insti_app/screens/admin/admin_home.dart'; -// import 'package:smart_insti_app/screens/admin/manage_rooms.dart'; -// import 'package:smart_insti_app/screens/admin/view_students.dart'; -// import 'package:smart_insti_app/screens/broadcast.dart'; -// import 'package:smart_insti_app/screens/auth/user_login.dart'; -// import 'package:smart_insti_app/screens/lost_and_found.dart'; -// import '../screens/admin/add_faculty.dart'; -// import '../screens/admin/add_menu.dart'; -// import '../screens/admin/view_courses.dart'; -// import '../screens/admin/view_faculty.dart'; -// import '../screens/admin/view_menu.dart'; -// import '../screens/room_vacancy.dart'; -// import '../screens/user_profile.dart'; -// import '../screens/auth/admin_login.dart'; -// import '../screens/user/user_home.dart'; -// import '../screens/user/faculty_profile.dart'; -// import '../screens/user/student_profile.dart'; - -// final GoRouter routes = GoRouter( -// initialLocation: '/', -// routes: [ -// GoRoute( -// path: '/', -// pageBuilder: (context, state) => MaterialPage(child: UserLogin()), -// routes: [ -// GoRoute( -// path: 'user_home', -// pageBuilder: (context, state) => MaterialPage(child: UserHome()), -// routes: [ -// GoRoute( -// path: 'view_students', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewStudents()), -// ), -// GoRoute( -// path: 'view_faculty', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewFaculty()), -// ), -// GoRoute( -// path: 'view_courses', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewCourses()), -// ), -// GoRoute( -// path: 'view_menu', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewMessMenu()), -// ), -// GoRoute( -// path: 'classroom_vacancy', -// pageBuilder: (context, state) => -// const MaterialPage(child: RoomVacancy()), -// ), -// GoRoute( -// path: 'lost_and_found', -// pageBuilder: (context, state) => -// MaterialPage(child: LostAndFound()), -// ), -// GoRoute( -// path: 'manage_rooms', -// pageBuilder: (context, state) => -// MaterialPage(child: ManageRooms()), -// ), -// GoRoute( -// path: 'student_profile', -// pageBuilder: (context, state) => -// MaterialPage(child: StudentProfile()), -// ), -// GoRoute( -// path: 'faculty_profile', -// pageBuilder: (context, state) => -// MaterialPage(child: FacultyProfile()), -// ), -// GoRoute( -// path: 'broadcast', -// pageBuilder: (context, state) => -// MaterialPage(child: BroadcastPage()), -// ), -// GoRoute( -// path: 'user_profile', -// pageBuilder: (context, state) => -// const MaterialPage(child: UserProfile()), -// ), -// ], -// ), -// GoRoute( -// path: 'admin_login', -// pageBuilder: (context, state) => MaterialPage(child: AdminLogin()), -// routes: [ -// GoRoute( -// path: 'admin_home', -// pageBuilder: (context, state) => -// const MaterialPage(child: AdminHome()), -// routes: [ -// GoRoute( -// path: 'add_students', -// pageBuilder: (context, state) => -// MaterialPage(child: AddStudents()), -// ), -// GoRoute( -// path: 'add_faculty', -// pageBuilder: (context, state) => -// MaterialPage(child: AddFaculty()), -// ), -// GoRoute( -// path: 'add_courses', -// pageBuilder: (context, state) => -// MaterialPage(child: AddCourses()), -// ), -// GoRoute( -// path: 'view_students', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewStudents()), -// ), -// GoRoute( -// path: 'view_faculty', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewFaculty()), -// ), -// GoRoute( -// path: 'view_courses', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewCourses()), -// ), -// GoRoute( -// path: 'add_menu', -// pageBuilder: (context, state) => -// MaterialPage(child: AddMessMenu()), -// ), -// GoRoute( -// path: 'view_menu', -// pageBuilder: (context, state) => -// MaterialPage(child: ViewMessMenu()), -// ), -// GoRoute( -// path: 'manage_rooms', -// pageBuilder: (context, state) => -// MaterialPage(child: ManageRooms()), -// ), -// ], -// ), -// ], -// ), -// ], -// ), -// ], -// ); +); diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/broadcast.dart index 804bbc2..b688798 100644 --- a/frontend/lib/screens/broadcast.dart +++ b/frontend/lib/screens/broadcast.dart @@ -79,100 +79,3 @@ class BroadcastPage extends ConsumerWidget { ); } } - -// import 'package:flutter/material.dart'; -// import 'package:flutter_riverpod/flutter_riverpod.dart'; -// import 'package:smart_insti_app/provider/broadcast_provider.dart'; -// // import 'package:smart_insti_app/models/broadcast_schema.dart'; - -// class BroadcastPage extends ConsumerWidget { -// @override -// Widget build(BuildContext context, WidgetRef ref) { -// final broadcasts = ref.watch(broadcastProvider); - -// return Scaffold( -// appBar: AppBar( -// title: const Text('Broadcasts'), -// ), -// body: broadcasts.when( -// data: (broadcasts) { -// return SingleChildScrollView( -// child: Column( -// children: broadcasts.map((broadcast) { -// return Card( -// margin: const EdgeInsets.all(8.0), -// child: Padding( -// padding: const EdgeInsets.all(8.0), -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Row( -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Text( -// broadcast.title, -// style: const TextStyle( -// fontWeight: FontWeight.bold, -// fontSize: 18.0, -// ), -// ), -// Text( -// '${broadcast.time.hour > 12 ? broadcast.time.hour - 12 : broadcast.time.hour}:${broadcast.time.minute} ${broadcast.time.hour >= 12 ? 'PM' : 'AM'}', -// style: const TextStyle( -// fontSize: 16.0, -// ), -// ), -// ], -// ), -// const SizedBox(height: 8.0), -// Text( -// broadcast.body, -// style: const TextStyle( -// fontSize: 16.0, -// ), -// ), -// ], -// ), -// ), -// ); -// }).toList(), -// ), -// ); -// }, -// loading: () => const Center(child: CircularProgressIndicator()), -// error: (error, stackTrace) => Center(child: Text('Error: $error')), -// ), -// ); -// } -// } -// class BroadcastPage extends ConsumerWidget { -// @override -// Widget build(BuildContext context, WidgetRef ref) { -// final broadcasts = ref.watch(broadcastProvider); - -// return Scaffold( -// appBar: AppBar( -// title: Text('Broadcasts'), -// ), -// body: broadcasts.when( -// data: (broadcasts) { -// return ListView.builder( -// itemCount: broadcasts.length, -// itemBuilder: (context, index) { -// final broadcast = broadcasts[index]; -// return ListTile( -// title: Text(broadcast.title), -// subtitle: Text(broadcast.body), -// trailing: Text( -// '${broadcast.time.hour}:${broadcast.time.minute}', -// ), -// ); -// }, -// ); -// }, -// loading: () => Center(child: CircularProgressIndicator()), -// error: (error, stackTrace) => Center(child: Text('Error: $error')), -// ), -// ); -// } -// } From e2eebc477818fe58b2cc9ed46f8306988a18d961 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Wed, 14 Feb 2024 20:55:06 +0530 Subject: [PATCH 17/20] removed env file frontend --- frontend/.env | 1 - 1 file changed, 1 deletion(-) delete mode 100644 frontend/.env diff --git a/frontend/.env b/frontend/.env deleted file mode 100644 index d20fa3e..0000000 --- a/frontend/.env +++ /dev/null @@ -1 +0,0 @@ -BACKEND_DOMAIN='http://10.0.2.2:3000' \ No newline at end of file From 775619e81581c6bd748bd2a3a873966ec8c4e350 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Wed, 14 Feb 2024 22:42:14 +0530 Subject: [PATCH 18/20] modified routes --- frontend/lib/routes/routes.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index df4a61e..1348d84 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -16,14 +16,13 @@ import '../screens/admin/view_faculty.dart'; import '../screens/admin/view_menu.dart'; import '../screens/auth/admin_login.dart'; import '../screens/user/room_vacancy.dart'; -import '../screens/user_profile.dart'; import '../screens/user/student_profile.dart'; import '../screens/user/user_home.dart'; import '../screens/user/faculty_profile.dart'; import '../screens/broadcast.dart'; final GoRouter routes = GoRouter( - initialLocation: '/user_home/broadcast', + initialLocation: '/', routes: [ GoRoute( path: '/', From a0d9068ddbb79a523a537fbdd67222c2369da5f3 Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Wed, 14 Feb 2024 22:43:56 +0530 Subject: [PATCH 19/20] files moved to user screen --- frontend/lib/routes/routes.dart | 2 +- frontend/lib/screens/{ => user}/broadcast.dart | 0 frontend/lib/screens/{ => user}/edit_profile.dart | 6 +++--- frontend/lib/screens/user/student_profile.dart | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename frontend/lib/screens/{ => user}/broadcast.dart (100%) rename frontend/lib/screens/{ => user}/edit_profile.dart (89%) diff --git a/frontend/lib/routes/routes.dart b/frontend/lib/routes/routes.dart index 1348d84..772dc29 100644 --- a/frontend/lib/routes/routes.dart +++ b/frontend/lib/routes/routes.dart @@ -19,7 +19,7 @@ import '../screens/user/room_vacancy.dart'; import '../screens/user/student_profile.dart'; import '../screens/user/user_home.dart'; import '../screens/user/faculty_profile.dart'; -import '../screens/broadcast.dart'; +import '../screens/user/broadcast.dart'; final GoRouter routes = GoRouter( initialLocation: '/', diff --git a/frontend/lib/screens/broadcast.dart b/frontend/lib/screens/user/broadcast.dart similarity index 100% rename from frontend/lib/screens/broadcast.dart rename to frontend/lib/screens/user/broadcast.dart diff --git a/frontend/lib/screens/edit_profile.dart b/frontend/lib/screens/user/edit_profile.dart similarity index 89% rename from frontend/lib/screens/edit_profile.dart rename to frontend/lib/screens/user/edit_profile.dart index 3a78ce0..30216df 100644 --- a/frontend/lib/screens/edit_profile.dart +++ b/frontend/lib/screens/user/edit_profile.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../provider/skills_edit_widget.dart'; -import '../provider/achievements_edit_widget.dart'; -import '../provider/about_Edit_widget.dart'; +import '../../provider/skills_edit_widget.dart'; +import '../../provider/achievements_edit_widget.dart'; +import '../../provider/about_Edit_widget.dart'; import 'dart:convert'; class EditProfileScreen extends ConsumerWidget { diff --git a/frontend/lib/screens/user/student_profile.dart b/frontend/lib/screens/user/student_profile.dart index ecc6397..d6df194 100644 --- a/frontend/lib/screens/user/student_profile.dart +++ b/frontend/lib/screens/user/student_profile.dart @@ -5,7 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smart_insti_app/models/achievement.dart'; import 'package:smart_insti_app/models/student.dart'; import 'package:smart_insti_app/provider/auth_provider.dart'; -import '../edit_profile.dart'; +import 'edit_profile.dart'; import 'package:smart_insti_app/constants/dummy_entries.dart'; class StudentProfile extends ConsumerWidget { From 84d983a1f162d30ca4c633c7eedd8e1265cd96cd Mon Sep 17 00:00:00 2001 From: SAISURYAtalla Date: Wed, 14 Feb 2024 22:47:50 +0530 Subject: [PATCH 20/20] removed reduntant code --- frontend/lib/constants/dummy_entries.dart | 157 ++++++++++++------ .../provider/achievements_edit_widget.dart | 1 - frontend/lib/provider/student_provider.dart | 1 - 3 files changed, 108 insertions(+), 51 deletions(-) diff --git a/frontend/lib/constants/dummy_entries.dart b/frontend/lib/constants/dummy_entries.dart index 9a883ce..7b7c47c 100644 --- a/frontend/lib/constants/dummy_entries.dart +++ b/frontend/lib/constants/dummy_entries.dart @@ -285,31 +285,6 @@ class DummyStudents { ]; } -// class DummySkills { -// static List skills = [ -// Skill(id: '1', name: 'Flutter', level: 80), -// Skill(id: '2', name: 'C++', level: 100), -// Skill(id: '3', name: 'javascript', level: 20), -// Skill(id: '4', name: 'Nodejs', level: 30), -// Skill(id: '5', name: 'Reactjs', level: 40), -// Skill(id: '6', name: 'MongoDB', level: 50), -// Skill(id: '7', name: 'Graphic Designing', level: 60), -// Skill(id: '8', name: 'chess', level: 70), -// Skill(id: '9', name: 'cricket', level: 80), -// Skill(id: '10', name: 'VScode', level: 100), -// Skill(id: '11', name: 'Dart', level: 100), -// Skill(id: '12', name: 'Typing', level: 90), -// Skill(id: '13', name: 'Drawing', level: 80), -// Skill(id: '14', name: 'Painting', level: 70), -// Skill(id: '15', name: 'Sketching', level: 60), -// Skill(id: '16', name: 'Programming', level: 50), -// Skill(id: '17', name: 'Python', level: 40), -// Skill(id: '18', name: 'C', level: 30), -// Skill(id: '19', name: 'Speaking', level: 20), -// Skill(id: '20', name: 'Sleeping', level: 10) -// ]; -// } - class Dummyachievements { static List achievements = [ Achievement( @@ -547,7 +522,11 @@ class DummyFaculties { id: '2', name: 'Prof. Johnson', email: 'johnson@example.com', - courses: [DummyCourses.courses[1], DummyCourses.courses[6], DummyCourses.courses[11]], + courses: [ + DummyCourses.courses[1], + DummyCourses.courses[6], + DummyCourses.courses[11] + ], cabinNumber: 'C-102', department: 'Mechanical Engineering', ), @@ -555,7 +534,11 @@ class DummyFaculties { id: '3', name: 'Dr. Brown', email: 'brown@example.com', - courses: [DummyCourses.courses[2], DummyCourses.courses[7], DummyCourses.courses[12]], + courses: [ + DummyCourses.courses[2], + DummyCourses.courses[7], + DummyCourses.courses[12] + ], cabinNumber: 'C-103', department: 'Electrical Engineering', ), @@ -563,119 +546,187 @@ class DummyFaculties { id: '4', name: 'Prof. Davis', email: 'davis@example.com', - courses: [DummyCourses.courses[3], DummyCourses.courses[8], DummyCourses.courses[13]], + courses: [ + DummyCourses.courses[3], + DummyCourses.courses[8], + DummyCourses.courses[13] + ], cabinNumber: 'C-104', department: 'Civil Engineering'), Faculty( id: '5', name: 'Dr. Wilson', email: 'wilson@example.com', - courses: [DummyCourses.courses[4], DummyCourses.courses[9], DummyCourses.courses[14]], + courses: [ + DummyCourses.courses[4], + DummyCourses.courses[9], + DummyCourses.courses[14] + ], cabinNumber: 'C-105', department: 'Chemical Engineering'), Faculty( id: '6', name: 'Prof. Miller', email: 'miller@example.com', - courses: [DummyCourses.courses[0], DummyCourses.courses[5], DummyCourses.courses[10]], + courses: [ + DummyCourses.courses[0], + DummyCourses.courses[5], + DummyCourses.courses[10] + ], cabinNumber: 'C-106', department: 'Biotechnology'), Faculty( id: '7', name: 'Dr. Turner', email: 'turner@example.com', - courses: [DummyCourses.courses[1], DummyCourses.courses[6], DummyCourses.courses[11]], + courses: [ + DummyCourses.courses[1], + DummyCourses.courses[6], + DummyCourses.courses[11] + ], cabinNumber: 'C-107', department: 'Aerospace Engineering'), Faculty( id: '8', name: 'Prof. Clark', email: 'clark@example.com', - courses: [DummyCourses.courses[2], DummyCourses.courses[7], DummyCourses.courses[12]], + courses: [ + DummyCourses.courses[2], + DummyCourses.courses[7], + DummyCourses.courses[12] + ], cabinNumber: 'C-108', department: 'Information Technology'), Faculty( id: '9', name: 'Dr. Harris', email: 'harris@example.com', - courses: [DummyCourses.courses[3], DummyCourses.courses[8], DummyCourses.courses[13]], + courses: [ + DummyCourses.courses[3], + DummyCourses.courses[8], + DummyCourses.courses[13] + ], cabinNumber: 'C-109', department: 'Mechatronics'), Faculty( id: '10', name: 'Prof. Turner', email: 'turner@example.com', - courses: [DummyCourses.courses[4], DummyCourses.courses[9], DummyCourses.courses[14]], + courses: [ + DummyCourses.courses[4], + DummyCourses.courses[9], + DummyCourses.courses[14] + ], cabinNumber: 'C-110', department: 'Robotics Engineering'), Faculty( id: '11', name: 'Dr. White', email: 'white@example.com', - courses: [DummyCourses.courses[0], DummyCourses.courses[5], DummyCourses.courses[10]], + courses: [ + DummyCourses.courses[0], + DummyCourses.courses[5], + DummyCourses.courses[10] + ], cabinNumber: 'D-101', department: 'Industrial Engineering'), Faculty( id: '12', name: 'Prof. Allen', email: 'allen@example.com', - courses: [DummyCourses.courses[1], DummyCourses.courses[6], DummyCourses.courses[11]], + courses: [ + DummyCourses.courses[1], + DummyCourses.courses[6], + DummyCourses.courses[11] + ], cabinNumber: 'D-102', department: 'Computer Engineering'), Faculty( id: '13', name: 'Dr. Young', email: 'young@example.com', - courses: [DummyCourses.courses[2], DummyCourses.courses[7], DummyCourses.courses[12]], + courses: [ + DummyCourses.courses[2], + DummyCourses.courses[7], + DummyCourses.courses[12] + ], cabinNumber: 'D-103', department: 'Software Engineering'), Faculty( id: '14', name: 'Prof. Walker', email: 'walker@example.com', - courses: [DummyCourses.courses[3], DummyCourses.courses[8], DummyCourses.courses[13]], + courses: [ + DummyCourses.courses[3], + DummyCourses.courses[8], + DummyCourses.courses[13] + ], cabinNumber: 'D-104', department: 'Environmental Engineering'), Faculty( id: '15', name: 'Dr. Lee', email: 'lee@example.com', - courses: [DummyCourses.courses[4], DummyCourses.courses[9], DummyCourses.courses[14]], + courses: [ + DummyCourses.courses[4], + DummyCourses.courses[9], + DummyCourses.courses[14] + ], cabinNumber: 'D-105', department: 'Petrolesum[ Engineer]ing'), Faculty( id: '16', name: 'Prof. Hall', email: 'hall@example.com', - courses: [DummyCourses.courses[0], DummyCourses.courses[5], DummyCourses.courses[10]], + courses: [ + DummyCourses.courses[0], + DummyCourses.courses[5], + DummyCourses.courses[10] + ], cabinNumber: 'D-106', department: 'Nuclear Engineering'), Faculty( id: '17', name: 'Dr. Miller', email: 'miller@example.com', - courses: [DummyCourses.courses[1], DummyCourses.courses[6], DummyCourses.courses[11]], + courses: [ + DummyCourses.courses[1], + DummyCourses.courses[6], + DummyCourses.courses[11] + ], cabinNumber: 'D-107', department: 'Biomedical Engineering'), Faculty( id: '18', name: 'Prof. Baker', email: 'baker@example.com', - courses: [DummyCourses.courses[2], DummyCourses.courses[7], DummyCourses.courses[12]], + courses: [ + DummyCourses.courses[2], + DummyCourses.courses[7], + DummyCourses.courses[12] + ], cabinNumber: 'D-108', department: 'Chemical Engineering'), Faculty( id: '19', name: 'Dr. Turner', email: 'turner@example.com', - courses: [DummyCourses.courses[3], DummyCourses.courses[8], DummyCourses.courses[13]], + courses: [ + DummyCourses.courses[3], + DummyCourses.courses[8], + DummyCourses.courses[13] + ], cabinNumber: 'D-109', department: 'Electronics Engineering'), Faculty( id: '20', name: 'Prof. Smith', email: 'smith@example.com', - courses: [DummyCourses.courses[4], DummyCourses.courses[9], DummyCourses.courses[14]], + courses: [ + DummyCourses.courses[4], + DummyCourses.courses[9], + DummyCourses.courses[14] + ], cabinNumber: 'D-110', department: 'Computer Science'), ]; @@ -947,7 +998,11 @@ class DummyRooms { Room(id: '16', name: 'Outdoor Sports Arena', vacant: true), Room(id: '17', name: 'Medical Clinic', vacant: false, occupantId: 'S004'), Room(id: '18', name: 'Music Room', vacant: true), - Room(id: '19', name: 'Student Council Office', vacant: false, occupantId: 'T005'), + Room( + id: '19', + name: 'Student Council Office', + vacant: false, + occupantId: 'T005'), Room(id: '20', name: 'Virtual Reality Lab', vacant: true), ]; } @@ -1124,13 +1179,15 @@ class DummyAchievements { id: '12', name: 'Training and Development', date: DateTime(2022, 4, 22), - description: 'Contributed significantly to employee training and development.', + description: + 'Contributed significantly to employee training and development.', ), Achievement( id: '13', name: 'Quality Assurance Recognition', date: DateTime(2023, 2, 14), - description: 'Acknowledged for ensuring high-quality standards in projects.', + description: + 'Acknowledged for ensuring high-quality standards in projects.', ), Achievement( id: '14', @@ -1166,13 +1223,15 @@ class DummyAchievements { id: '19', name: 'Health and Wellness Initiative', date: DateTime(2023, 9, 10), - description: 'Led initiatives to promote health and wellness in the workplace.', + description: + 'Led initiatives to promote health and wellness in the workplace.', ), Achievement( id: '20', name: 'Public Speaking Achievement', date: DateTime(2022, 1, 30), - description: 'Received acclaim for public speaking skills at a conference.', + description: + 'Received acclaim for public speaking skills at a conference.', ), ]; // You can use the dummyEntries list as needed in your application diff --git a/frontend/lib/provider/achievements_edit_widget.dart b/frontend/lib/provider/achievements_edit_widget.dart index 82d6129..6c34cc4 100644 --- a/frontend/lib/provider/achievements_edit_widget.dart +++ b/frontend/lib/provider/achievements_edit_widget.dart @@ -91,7 +91,6 @@ class AchievementsEditWidget extends ConsumerWidget { }, ), TextFormField( - // Add another text field for description initialValue: achievements[index].description, onChanged: (value) { ref diff --git a/frontend/lib/provider/student_provider.dart b/frontend/lib/provider/student_provider.dart index 583a15a..41994b7 100644 --- a/frontend/lib/provider/student_provider.dart +++ b/frontend/lib/provider/student_provider.dart @@ -83,7 +83,6 @@ class StudentState { return students.firstWhere((student) => student.id == studentId); } catch (e) { return Student( - // Default values or a placeholder student object id: '1', name: 'John Doe', email: 'john.doe@example.com',