Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Notification Dot #195

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: CircleAvatar(radius: 10,backgroundColor: Colors.red,child: Text("${SharedPreferencesForDot.getNoOfNewNotification() - SharedPreferencesForDot.getNoOfNotification()}"),),) : SizedBox(),
],
),
),
),
Expand Down
7 changes: 7 additions & 0 deletions 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 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
Loading