temporary removed notifications

This commit is contained in:
Marton Kiss 2025-01-03 16:03:42 +01:00
parent ac3429f30f
commit 0a02d4e831
5 changed files with 979 additions and 979 deletions

File diff suppressed because it is too large Load Diff

View File

@ -104,7 +104,7 @@ class Startup {
user = await database.query.getUsers(settings);
// Set all notification categories to seen to avoid having notifications that the user has already seen in the app
NotificationsHelper().setAllCategoriesSeen(user);
// NotificationsHelper().setAllCategoriesSeen(user);
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
// Notifications setup
@ -165,11 +165,11 @@ class Startup {
);
// Initialize notifications
await flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveNotificationResponse:
NotificationsHelper().onDidReceiveNotificationResponse,
);
// await flutterLocalNotificationsPlugin.initialize(
// initializationSettings,
// onDidReceiveNotificationResponse:
// NotificationsHelper().onDidReceiveNotificationResponse,
// );
}
// if (Platform.isAndroid || Platform.isIOS) {
@ -239,7 +239,7 @@ Future<void> initPlatformState() async {
if (!Platform.isIOS) return;
LiveActivityHelper().backgroundJob();
} else {
NotificationsHelper().backgroundJob();
// NotificationsHelper().backgroundJob();
}
BackgroundFetch.finish(taskId);
}, (String taskId) async {
@ -279,7 +279,7 @@ void backgroundHeadlessTask(HeadlessTask task) {
if (!Platform.isIOS) return;
LiveActivityHelper().backgroundJob();
} else {
NotificationsHelper().backgroundJob();
// NotificationsHelper().backgroundJob();
}
BackgroundFetch.finish(task.taskId);
}

View File

@ -153,7 +153,7 @@ class GradeProvider with ChangeNotifier {
for (Grade grade in grs) {
if (grade.value.value == 5) {
gradeStreak++;
} else if (grade.value.value !=0) {
} else if (grade.value.value != 0) {
break;
}
}

View File

@ -1,277 +1,277 @@
import 'package:flutter/foundation.dart';
import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/helpers/notification_helper.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/models/user.dart';
import 'package:refilc/theme/colors/colors.dart';
// import 'package:refilc_mobile_ui/common/beta_chip.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'notifications_screen.i18n.dart';
// import 'package:flutter/foundation.dart';
// import 'package:refilc/api/providers/database_provider.dart';
// import 'package:refilc/api/providers/user_provider.dart';
// import 'package:refilc/helpers/notification_helper.dart';
// import 'package:refilc/models/settings.dart';
// import 'package:refilc/models/user.dart';
// import 'package:refilc/theme/colors/colors.dart';
// // import 'package:refilc_mobile_ui/common/beta_chip.dart';
// import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_feather_icons/flutter_feather_icons.dart';
// import 'package:provider/provider.dart';
// import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
// import 'notifications_screen.i18n.dart';
class MenuNotifications extends StatelessWidget {
const MenuNotifications({
super.key,
this.borderRadius = const BorderRadius.vertical(
top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
});
// class MenuNotifications extends StatelessWidget {
// const MenuNotifications({
// super.key,
// this.borderRadius = const BorderRadius.vertical(
// top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
// });
final BorderRadius borderRadius;
// final BorderRadius borderRadius;
@override
Widget build(BuildContext context) {
return PanelButton(
onPressed: () => Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(builder: (context) => const NotificationsScreen()),
),
title: Row(
children: [
Text(
"notifications_screen".i18n,
),
// const SizedBox(width: 5.0),
// const BetaChip(
// disabled: false,
// ),
],
),
leading: Icon(
FeatherIcons.messageCircle,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: borderRadius,
);
}
}
// @override
// Widget build(BuildContext context) {
// return PanelButton(
// onPressed: () => Navigator.of(context, rootNavigator: true).push(
// CupertinoPageRoute(builder: (context) => const NotificationsScreen()),
// ),
// title: Row(
// children: [
// Text(
// "notifications_screen".i18n,
// ),
// // const SizedBox(width: 5.0),
// // const BetaChip(
// // disabled: false,
// // ),
// ],
// ),
// leading: Icon(
// FeatherIcons.messageCircle,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(0.95),
// ),
// trailing: Icon(
// FeatherIcons.chevronRight,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(0.95),
// ),
// borderRadius: borderRadius,
// );
// }
// }
class NotificationsScreen extends StatelessWidget {
const NotificationsScreen({super.key});
// class NotificationsScreen extends StatelessWidget {
// const NotificationsScreen({super.key});
// Set all notification categories as seen to avoid spamming the user with notifications when they turn on notifications
void setAll(BuildContext context, DateTime date) {
DatabaseProvider database =
Provider.of<DatabaseProvider>(context, listen: false);
User? user = Provider.of<UserProvider>(context, listen: false).user;
if (user != null) {
for (LastSeenCategory category in LastSeenCategory.values) {
database.userStore
.storeLastSeen(date, userId: user.id, category: category);
}
}
}
// Set all notification categories as seen to avoid spamming the user with notifications when they turn on notifications
// void setAll(BuildContext context, DateTime date) {
// DatabaseProvider database =
// Provider.of<DatabaseProvider>(context, listen: false);
// User? user = Provider.of<UserProvider>(context, listen: false).user;
// if (user != null) {
// for (LastSeenCategory category in LastSeenCategory.values) {
// database.userStore
// .storeLastSeen(date, userId: user.id, category: category);
// }
// }
// }
@override
Widget build(BuildContext context) {
SettingsProvider settings = Provider.of<SettingsProvider>(context);
// @override
// Widget build(BuildContext context) {
// SettingsProvider settings = Provider.of<SettingsProvider>(context);
return Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
title: Text(
"notifications_screen".i18n,
style: TextStyle(color: AppColors.of(context).text),
),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
child: Column(
children: [
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settings.update(
notificationsGradesEnabled:
!settings.notificationsGradesEnabled);
setAll(context, DateTime.now());
},
title: Text(
"grades".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settings.notificationsGradesEnabled ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.bookmark,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settings.notificationsGradesEnabled ? .95 : .25),
),
trailing: Switch(
onChanged: (v) =>
settings.update(notificationsGradesEnabled: v),
value: settings.notificationsGradesEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settings.update(
notificationsAbsencesEnabled:
!settings.notificationsAbsencesEnabled);
setAll(context, DateTime.now());
},
title: Text(
"absences".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settings.notificationsAbsencesEnabled ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.clock,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settings.notificationsAbsencesEnabled ? .95 : .25),
),
trailing: Switch(
onChanged: (v) =>
settings.update(notificationsAbsencesEnabled: v),
value: settings.notificationsAbsencesEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settings.update(
notificationsMessagesEnabled:
!settings.notificationsMessagesEnabled);
setAll(context, DateTime.now());
},
title: Text(
"messages".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settings.notificationsMessagesEnabled ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.messageSquare,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settings.notificationsMessagesEnabled ? .95 : .25),
),
trailing: Switch(
onChanged: (v) =>
settings.update(notificationsMessagesEnabled: v),
value: settings.notificationsMessagesEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settings.update(
notificationsLessonsEnabled:
!settings.notificationsLessonsEnabled);
setAll(context, DateTime.now());
},
title: Text(
"lessons".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settings.notificationsLessonsEnabled ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.bookmark,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settings.notificationsLessonsEnabled ? .95 : .25),
),
trailing: Switch(
onChanged: (v) =>
settings.update(notificationsLessonsEnabled: v),
value: settings.notificationsLessonsEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// only used for debugging, pressing **will** cause notification spam
kDebugMode
? SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () => setAll(
context, DateTime(1970, 1, 1, 0, 0, 0, 0, 0)),
title: Text("set_all_as_unseen".i18n),
leading: Icon(
FeatherIcons.mail,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0)),
)
],
)
: const SizedBox.shrink(),
],
),
),
),
);
}
}
// return Scaffold(
// appBar: AppBar(
// surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
// leading: BackButton(color: AppColors.of(context).text),
// title: Text(
// "notifications_screen".i18n,
// style: TextStyle(color: AppColors.of(context).text),
// ),
// ),
// body: SingleChildScrollView(
// child: Padding(
// padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
// child: Column(
// children: [
// SplittedPanel(
// padding: const EdgeInsets.only(top: 8.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [
// PanelButton(
// padding: const EdgeInsets.only(left: 14.0, right: 6.0),
// onPressed: () {
// settings.update(
// notificationsGradesEnabled:
// !settings.notificationsGradesEnabled);
// setAll(context, DateTime.now());
// },
// title: Text(
// "grades".i18n,
// style: TextStyle(
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsGradesEnabled ? .95 : .25),
// ),
// ),
// leading: Icon(
// FeatherIcons.bookmark,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsGradesEnabled ? .95 : .25),
// ),
// trailing: Switch(
// onChanged: (v) =>
// settings.update(notificationsGradesEnabled: v),
// value: settings.notificationsGradesEnabled,
// activeColor: Theme.of(context).colorScheme.secondary,
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0),
// ),
// ),
// ],
// ),
// SplittedPanel(
// padding: const EdgeInsets.only(top: 8.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [
// PanelButton(
// padding: const EdgeInsets.only(left: 14.0, right: 6.0),
// onPressed: () {
// settings.update(
// notificationsAbsencesEnabled:
// !settings.notificationsAbsencesEnabled);
// setAll(context, DateTime.now());
// },
// title: Text(
// "absences".i18n,
// style: TextStyle(
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsAbsencesEnabled ? .95 : .25),
// ),
// ),
// leading: Icon(
// FeatherIcons.clock,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsAbsencesEnabled ? .95 : .25),
// ),
// trailing: Switch(
// onChanged: (v) =>
// settings.update(notificationsAbsencesEnabled: v),
// value: settings.notificationsAbsencesEnabled,
// activeColor: Theme.of(context).colorScheme.secondary,
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0),
// ),
// ),
// ],
// ),
// SplittedPanel(
// padding: const EdgeInsets.only(top: 8.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [
// PanelButton(
// padding: const EdgeInsets.only(left: 14.0, right: 6.0),
// onPressed: () {
// settings.update(
// notificationsMessagesEnabled:
// !settings.notificationsMessagesEnabled);
// setAll(context, DateTime.now());
// },
// title: Text(
// "messages".i18n,
// style: TextStyle(
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsMessagesEnabled ? .95 : .25),
// ),
// ),
// leading: Icon(
// FeatherIcons.messageSquare,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsMessagesEnabled ? .95 : .25),
// ),
// trailing: Switch(
// onChanged: (v) =>
// settings.update(notificationsMessagesEnabled: v),
// value: settings.notificationsMessagesEnabled,
// activeColor: Theme.of(context).colorScheme.secondary,
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0),
// ),
// ),
// ],
// ),
// SplittedPanel(
// padding: const EdgeInsets.only(top: 8.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [
// PanelButton(
// padding: const EdgeInsets.only(left: 14.0, right: 6.0),
// onPressed: () {
// settings.update(
// notificationsLessonsEnabled:
// !settings.notificationsLessonsEnabled);
// setAll(context, DateTime.now());
// },
// title: Text(
// "lessons".i18n,
// style: TextStyle(
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsLessonsEnabled ? .95 : .25),
// ),
// ),
// leading: Icon(
// FeatherIcons.bookmark,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(
// settings.notificationsLessonsEnabled ? .95 : .25),
// ),
// trailing: Switch(
// onChanged: (v) =>
// settings.update(notificationsLessonsEnabled: v),
// value: settings.notificationsLessonsEnabled,
// activeColor: Theme.of(context).colorScheme.secondary,
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0),
// ),
// ),
// ],
// ),
// // only used for debugging, pressing **will** cause notification spam
// kDebugMode
// ? SplittedPanel(
// padding: const EdgeInsets.only(top: 9.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [
// PanelButton(
// onPressed: () => setAll(
// context, DateTime(1970, 1, 1, 0, 0, 0, 0, 0)),
// title: Text("set_all_as_unseen".i18n),
// leading: Icon(
// FeatherIcons.mail,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(0.95),
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0)),
// )
// ],
// )
// : const SizedBox.shrink(),
// ],
// ),
// ),
// ),
// );
// }
// }

View File

@ -945,18 +945,18 @@ class SettingsScreenState extends State<SettingsScreen>
),
// notifications
const SplittedPanel(
padding: EdgeInsets.only(top: 8.0),
cardPadding: EdgeInsets.all(4.0),
children: [
MenuNotifications(
borderRadius: BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// const SplittedPanel(
// padding: EdgeInsets.only(top: 8.0),
// cardPadding: EdgeInsets.all(4.0),
// children: [
// MenuNotifications(
// borderRadius: BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0),
// ),
// ),
// ],
// ),
// extras
const SplittedPanel(