Skip to content

Commit

Permalink
Merge branch 'TSEC-MAD-Club:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-khewle authored Jul 13, 2024
2 parents e879ff5 + aabde0c commit 2fe089c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Future<void> main() async {
await Firebase.initializeApp();

await SharedPreferencesForDot.initializeSharedPreferences();
await SharedPreferencesForDot.setNewNotificationDot();

await LocalNotificationService.localNotificationInit();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
Expand Down
8 changes: 0 additions & 8 deletions lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,6 @@ class _GuideLinesScreenState extends State<GuideLinesScreen> {
SizedBox(
height: size.height * 0.03,
),
InkWell(
onTap: LocalNotificationService.showNotification,
child: Container(
height: 100,
width: 100,
color: Colors.white,
),
),
],
),
)
Expand Down
21 changes: 14 additions & 7 deletions lib/new_ui/screens/main_screen/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import 'package:tsec_app/new_ui/screens/committees_screen/old_committees_screen.
import 'package:tsec_app/screens/tpc_screen.dart';
import 'package:url_launcher/link.dart';

import '../../../services/sharedprefsfordot.dart';

class MainScreen extends ConsumerStatefulWidget {
const MainScreen({
Key? key,
Expand Down Expand Up @@ -368,13 +370,18 @@ class _MainScreenState extends ConsumerState<MainScreen> {
Navigator.push(context, MaterialPageRoute(builder: (
context) => NotificationScreen(),),);
},
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 6, 0, 0),
child: Image.asset(
'assets/images/new_app_bar/icon_bell.png',
width: 45,
height: 45,
),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 6, 0, 0),
child: Image.asset(
'assets/images/new_app_bar/icon_bell.png',
width: 45,
height: 45,
),
),
(SharedPreferencesForDot.getNoOfNewNotification() - SharedPreferencesForDot.getNoOfNotification() != 0) ? Positioned(right: 0,top: 0,child: Container(alignment: Alignment.center,padding: EdgeInsets.all(6),decoration: BoxDecoration(color: Colors.red,shape: BoxShape.circle),child: Text("${SharedPreferencesForDot.getNoOfNewNotification() - SharedPreferencesForDot.getNoOfNotification()}",style: TextStyle(color: Colors.white,fontSize: 12),),),) : SizedBox(),
],
),
),
),
Expand Down
9 changes: 8 additions & 1 deletion lib/screens/notification_screen/notification_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:intl/intl.dart';
import 'package:tsec_app/provider/notification_provider.dart';
import 'package:tsec_app/screens/notification_screen/widgets/notification_list_item.dart';
import 'package:tsec_app/services/notification_service.dart';
import 'package:tsec_app/services/sharedprefsfordot.dart';
import 'package:tsec_app/utils/custom_snackbar.dart';
import 'package:tsec_app/utils/init_get_it.dart';
import '../../models/notification_model/notification_model.dart';
Expand All @@ -29,6 +30,12 @@ class NotificationScreen extends ConsumerStatefulWidget {
class _NotificationScreenState extends ConsumerState<NotificationScreen> {
DateTime _lastDate = DateTime(2000);

@override
void initState() {
super.initState();
SharedPreferencesForDot.storeNoOfNotification(SharedPreferencesForDot.getNoOfNewNotification());
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -47,7 +54,7 @@ class _NotificationScreenState extends ConsumerState<NotificationScreen> {
final notifications = data.docs;
return ListView.builder(itemCount: notifications.length, itemBuilder: (context, index){
final notif = NotificationModel.fromJson(notifications[index].data() as Map<String, dynamic>);
print(notif.attachments.toString());
//print(notif.attachments.toString());
final listTile = NotificationListItem(
notificationModel: notif,
);
Expand Down
26 changes: 22 additions & 4 deletions lib/services/sharedprefsfordot.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class SharedPreferencesForDot{

Expand All @@ -8,12 +9,29 @@ class SharedPreferencesForDot{
prefs = await SharedPreferences.getInstance();
}

static int getNotificationNumber(){
return prefs.getInt("notificationNumber") ?? 0;
static setNewNotificationDot()async{
final getDocs = await FirebaseFirestore.instance.collection("notifications").get();
storeNoOfNewNotification(getDocs.docs.length);
}

static storeNotificationNumber(int value){
prefs.setInt("notificationNumber", value);
static int getNoOfNotification(){
return prefs.getInt("noOfNotification") ?? 0;
}

static storeNoOfNotification(int value){
prefs.setInt("noOfNotification", value);
}

static int getNoOfNewNotification(){
return prefs.getInt("noOfNewNotification") ?? 0;
}

static storeNoOfNewNotification(int value){
prefs.setInt("noOfNewNotification", value);
}

static makeNotificationEqual(){

}

static String getRailwayKeyStatus(){
Expand Down

0 comments on commit 2fe089c

Please sign in to comment.