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); 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 // 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; late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
// Notifications setup // Notifications setup
@ -165,11 +165,11 @@ class Startup {
); );
// Initialize notifications // Initialize notifications
await flutterLocalNotificationsPlugin.initialize( // await flutterLocalNotificationsPlugin.initialize(
initializationSettings, // initializationSettings,
onDidReceiveNotificationResponse: // onDidReceiveNotificationResponse:
NotificationsHelper().onDidReceiveNotificationResponse, // NotificationsHelper().onDidReceiveNotificationResponse,
); // );
} }
// if (Platform.isAndroid || Platform.isIOS) { // if (Platform.isAndroid || Platform.isIOS) {
@ -239,7 +239,7 @@ Future<void> initPlatformState() async {
if (!Platform.isIOS) return; if (!Platform.isIOS) return;
LiveActivityHelper().backgroundJob(); LiveActivityHelper().backgroundJob();
} else { } else {
NotificationsHelper().backgroundJob(); // NotificationsHelper().backgroundJob();
} }
BackgroundFetch.finish(taskId); BackgroundFetch.finish(taskId);
}, (String taskId) async { }, (String taskId) async {
@ -279,7 +279,7 @@ void backgroundHeadlessTask(HeadlessTask task) {
if (!Platform.isIOS) return; if (!Platform.isIOS) return;
LiveActivityHelper().backgroundJob(); LiveActivityHelper().backgroundJob();
} else { } else {
NotificationsHelper().backgroundJob(); // NotificationsHelper().backgroundJob();
} }
BackgroundFetch.finish(task.taskId); BackgroundFetch.finish(task.taskId);
} }

View File

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

View File

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