forked from firka/student-legacy
commit
a88ccfa3fc
60
.idea/naplo.iml
generated
60
.idea/naplo.iml
generated
@ -2,7 +2,65 @@
|
|||||||
<module type="JAVA_MODULE" version="4">
|
<module type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/flutter_acrylic/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/flutter_acrylic/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/flutter_acrylic/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_desktop_ui/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_desktop_ui/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_desktop_ui/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/share_plus/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/share_plus/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/share_plus/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_premium/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_premium/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_premium/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/share_plus/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/share_plus/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/share_plus/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_kreta_api/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_kreta_api/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_kreta_api/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_mobile_ui/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_mobile_ui/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo_mobile_ui/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus/example/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus/example/.dart_tool" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus/example/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/flutter_acrylic/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/flutter_acrylic/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/filcnaplo/linux/flutter/ephemeral/.plugin_symlinks/flutter_acrylic/.dart_tool" />
|
||||||
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
|
BIN
filcnaplo/android/app/src/main/res/drawable/ic_notification.png
Normal file
BIN
filcnaplo/android/app/src/main/res/drawable/ic_notification.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
77
filcnaplo/lib/helpers/notification_helper.dart
Normal file
77
filcnaplo/lib/helpers/notification_helper.dart
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
|
import 'package:filcnaplo/api/providers/status_provider.dart';
|
||||||
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
|
import 'package:filcnaplo/database/init.dart';
|
||||||
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
|
import 'package:filcnaplo/helpers/notification_helper.i18n.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/client/client.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||||
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
|
||||||
|
class NotificationsHelper {
|
||||||
|
@pragma('vm:entry-point')
|
||||||
|
void backgroundJob() async {
|
||||||
|
// initialize providers
|
||||||
|
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||||
|
FlutterLocalNotificationsPlugin();
|
||||||
|
DatabaseProvider database = DatabaseProvider();
|
||||||
|
var db = await initDB(database);
|
||||||
|
await database.init();
|
||||||
|
SettingsProvider settingsProvider =
|
||||||
|
await database.query.getSettings(database);
|
||||||
|
UserProvider userProvider = await database.query.getUsers(settingsProvider);
|
||||||
|
|
||||||
|
if (userProvider.id != null && settingsProvider.notificationsEnabled) {
|
||||||
|
// refresh grades
|
||||||
|
final status = StatusProvider();
|
||||||
|
final kretaClient = KretaClient(
|
||||||
|
user: userProvider, settings: settingsProvider, status: status);
|
||||||
|
kretaClient.refreshLogin();
|
||||||
|
GradeProvider gradeProvider = GradeProvider(
|
||||||
|
settings: settingsProvider,
|
||||||
|
user: userProvider,
|
||||||
|
database: database,
|
||||||
|
kreta: kretaClient);
|
||||||
|
gradeProvider.fetch();
|
||||||
|
List<Grade> grades =
|
||||||
|
await database.userQuery.getGrades(userId: userProvider.id ?? "");
|
||||||
|
DateTime lastSeenGrade =
|
||||||
|
await database.userQuery.lastSeenGrade(userId: userProvider.id ?? "");
|
||||||
|
|
||||||
|
// loop through grades and see which hasn't been seen yet
|
||||||
|
for (Grade grade in grades) {
|
||||||
|
// if the grade was added over a week ago, don't show it to avoid notification spam
|
||||||
|
if (grade.seenDate.isAfter(lastSeenGrade) && grade.date.difference(DateTime.now()).inDays * -1 < 7) {
|
||||||
|
// send notificiation about new grade
|
||||||
|
const AndroidNotificationDetails androidNotificationDetails =
|
||||||
|
AndroidNotificationDetails('GRADES', 'Jegyek',
|
||||||
|
channelDescription: 'Értesítés jegyek beírásakor',
|
||||||
|
importance: Importance.max,
|
||||||
|
priority: Priority.max,
|
||||||
|
color: const Color(0xFF3D7BF4),
|
||||||
|
ticker: 'Jegyek');
|
||||||
|
const NotificationDetails notificationDetails =
|
||||||
|
NotificationDetails(android: androidNotificationDetails);
|
||||||
|
await flutterLocalNotificationsPlugin.show(
|
||||||
|
// probably shouldn't use a random int
|
||||||
|
Random().nextInt(432234 * 2),
|
||||||
|
"title".i18n,
|
||||||
|
"body".i18n.fill([
|
||||||
|
grade.value.value.toString(),
|
||||||
|
grade.subject.isRenamed &&
|
||||||
|
settingsProvider.renamedSubjectsEnabled
|
||||||
|
? grade.subject.renamedTo!
|
||||||
|
: grade.subject.name
|
||||||
|
]),
|
||||||
|
notificationDetails);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set grade seen status
|
||||||
|
gradeProvider.seenAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
filcnaplo/lib/helpers/notification_helper.i18n.dart
Normal file
24
filcnaplo/lib/helpers/notification_helper.i18n.dart
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import 'package:i18n_extension/i18n_extension.dart';
|
||||||
|
|
||||||
|
extension Localization on String {
|
||||||
|
static final _t = Translations.byLocale("hu_hu") +
|
||||||
|
{
|
||||||
|
"en_en": {
|
||||||
|
"title": "New grade",
|
||||||
|
"body": "You got a %s in %s"
|
||||||
|
},
|
||||||
|
"hu_hu": {
|
||||||
|
"title": "Új jegy",
|
||||||
|
"body": "%s-st kaptál %s tantárgyból"
|
||||||
|
},
|
||||||
|
"de_de": {
|
||||||
|
"title": "Neue Note",
|
||||||
|
"body": "Du hast eine %s in %s"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
String get i18n => localize(this, _t);
|
||||||
|
String fill(List<Object> params) => localizeFill(this, params);
|
||||||
|
String plural(int value) => localizePlural(value, this, _t);
|
||||||
|
String version(Object modifier) => localizeVersion(modifier, this, _t);
|
||||||
|
}
|
@ -2,13 +2,16 @@ import 'package:background_fetch/background_fetch.dart';
|
|||||||
import 'package:filcnaplo/api/providers/user_provider.dart';
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
import 'package:filcnaplo/api/providers/database_provider.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
import 'package:filcnaplo/database/init.dart';
|
import 'package:filcnaplo/database/init.dart';
|
||||||
|
import 'package:filcnaplo/helpers/notification_helper.dart';
|
||||||
import 'package:filcnaplo/models/settings.dart';
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/client/client.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:filcnaplo/app.dart';
|
import 'package:filcnaplo/app.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/error_screen.dart';
|
import 'package:filcnaplo_mobile_ui/screens/error_screen.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/error_report_screen.dart';
|
import 'package:filcnaplo_mobile_ui/screens/error_report_screen.dart';
|
||||||
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
// Initalize
|
// Initalize
|
||||||
@ -43,6 +46,53 @@ class Startup {
|
|||||||
await database.init();
|
await database.init();
|
||||||
settings = await database.query.getSettings(database);
|
settings = await database.query.getSettings(database);
|
||||||
user = await database.query.getUsers(settings);
|
user = await database.query.getUsers(settings);
|
||||||
|
|
||||||
|
// Notifications setup
|
||||||
|
initPlatformState();
|
||||||
|
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||||
|
FlutterLocalNotificationsPlugin();
|
||||||
|
|
||||||
|
// Get permission to show notifications
|
||||||
|
flutterLocalNotificationsPlugin
|
||||||
|
.resolvePlatformSpecificImplementation<
|
||||||
|
AndroidFlutterLocalNotificationsPlugin>()!
|
||||||
|
.requestPermission();
|
||||||
|
await flutterLocalNotificationsPlugin
|
||||||
|
.resolvePlatformSpecificImplementation<
|
||||||
|
IOSFlutterLocalNotificationsPlugin>()
|
||||||
|
?.requestPermissions(
|
||||||
|
alert: false,
|
||||||
|
badge: true,
|
||||||
|
sound: true,
|
||||||
|
);
|
||||||
|
await flutterLocalNotificationsPlugin
|
||||||
|
.resolvePlatformSpecificImplementation<
|
||||||
|
MacOSFlutterLocalNotificationsPlugin>()
|
||||||
|
?.requestPermissions(
|
||||||
|
alert: false,
|
||||||
|
badge: true,
|
||||||
|
sound: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Platform specific settings
|
||||||
|
final DarwinInitializationSettings initializationSettingsDarwin =
|
||||||
|
DarwinInitializationSettings(
|
||||||
|
requestSoundPermission: true,
|
||||||
|
requestBadgePermission: true,
|
||||||
|
requestAlertPermission: false,
|
||||||
|
);
|
||||||
|
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||||
|
AndroidInitializationSettings('ic_notification');
|
||||||
|
final InitializationSettings initializationSettings = InitializationSettings(
|
||||||
|
android: initializationSettingsAndroid,
|
||||||
|
iOS: initializationSettingsDarwin,
|
||||||
|
macOS: initializationSettingsDarwin
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initialize notifications
|
||||||
|
await flutterLocalNotificationsPlugin.initialize(
|
||||||
|
initializationSettings,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +121,51 @@ Widget errorBuilder(FlutterErrorDetails details) {
|
|||||||
return Container();
|
return Container();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Future<void> initPlatformState() async {
|
||||||
|
// Configure BackgroundFetch.
|
||||||
|
int status = await BackgroundFetch.configure(BackgroundFetchConfig(
|
||||||
|
minimumFetchInterval: 15,
|
||||||
|
stopOnTerminate: false,
|
||||||
|
enableHeadless: true,
|
||||||
|
requiresBatteryNotLow: false,
|
||||||
|
requiresCharging: false,
|
||||||
|
requiresStorageNotLow: false,
|
||||||
|
requiresDeviceIdle: false,
|
||||||
|
requiredNetworkType: NetworkType.ANY,
|
||||||
|
startOnBoot: true
|
||||||
|
), (String taskId) async { // <-- Event handler
|
||||||
|
print("[BackgroundFetch] Event received $taskId");
|
||||||
|
NotificationsHelper().backgroundJob();
|
||||||
|
BackgroundFetch.finish(taskId);
|
||||||
|
}, (String taskId) async { // <-- Task timeout handler.
|
||||||
|
print("[BackgroundFetch] TASK TIMEOUT taskId: $taskId");
|
||||||
|
BackgroundFetch.finish(taskId);
|
||||||
|
});
|
||||||
|
print('[BackgroundFetch] configure success: $status');
|
||||||
|
BackgroundFetch.scheduleTask(TaskConfig(
|
||||||
|
taskId: "com.transistorsoft.refilcnotification",
|
||||||
|
delay: 900000, // 15 minutes
|
||||||
|
periodic: true,
|
||||||
|
forceAlarmManager: true,
|
||||||
|
stopOnTerminate: false,
|
||||||
|
enableHeadless: true
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void backgroundHeadlessTask(HeadlessTask task) {
|
void backgroundHeadlessTask(HeadlessTask task) {
|
||||||
|
String taskId = task.taskId;
|
||||||
|
bool isTimeout = task.timeout;
|
||||||
|
if (isTimeout) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print("[BackgroundFetch] Headless task timed-out: $taskId");
|
||||||
|
}
|
||||||
|
BackgroundFetch.finish(taskId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print('[BackgroundFetch] Headless event received.');
|
print('[BackgroundFetch] Headless event received.');
|
||||||
}
|
}
|
||||||
|
NotificationsHelper().backgroundJob();
|
||||||
BackgroundFetch.finish(task.taskId);
|
BackgroundFetch.finish(task.taskId);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
|
|||||||
|
|
||||||
// Grades
|
// Grades
|
||||||
case FilterType.grades:
|
case FilterType.grades:
|
||||||
|
gradeProvider.seenAll();
|
||||||
items = grade_filter.getWidgets(
|
items = grade_filter.getWidgets(
|
||||||
gradeProvider.grades, gradeProvider.lastSeenDate);
|
gradeProvider.grades, gradeProvider.lastSeenDate);
|
||||||
if (settingsProvider.gradeOpeningFun) {
|
if (settingsProvider.gradeOpeningFun) {
|
||||||
|
@ -51,7 +51,6 @@ class GradeProvider with ChangeNotifier {
|
|||||||
final userStore = _database.userStore;
|
final userStore = _database.userStore;
|
||||||
userStore.storeLastSeenGrade(DateTime.now(), userId: userId);
|
userStore.storeLastSeenGrade(DateTime.now(), userId: userId);
|
||||||
_lastSeen = DateTime.now();
|
_lastSeen = DateTime.now();
|
||||||
notifyListeners();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,6 @@ class NavigationScreenState extends State<NavigationScreen>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
initPlatformState();
|
|
||||||
|
|
||||||
HomeWidget.setAppGroupId('hu.refilc.naplo.group');
|
HomeWidget.setAppGroupId('hu.refilc.naplo.group');
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class _SettingsScreenState extends State<SettingsScreen>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
Future.delayed(Duration.zero, () {
|
Future.delayed(Duration.zero, () {
|
||||||
futureRelease = Provider.of<UpdateProvider>(context).installedVersion();
|
futureRelease = Provider.of<UpdateProvider>(context, listen: false).installedVersion();
|
||||||
});
|
});
|
||||||
_hideContainersController = AnimationController(
|
_hideContainersController = AnimationController(
|
||||||
vsync: this, duration: const Duration(milliseconds: 200));
|
vsync: this, duration: const Duration(milliseconds: 200));
|
||||||
@ -437,6 +437,61 @@ class _SettingsScreenState extends State<SettingsScreen>
|
|||||||
activeColor: Theme.of(context).colorScheme.secondary,
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Material(
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: SwitchListTile(
|
||||||
|
value: settings.notificationsEnabled,
|
||||||
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
|
contentPadding: const EdgeInsets.only(left: 12.0),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12.0)),
|
||||||
|
title: Row(children: [
|
||||||
|
Icon(FeatherIcons.messageSquare,
|
||||||
|
color: settings.notificationsEnabled ? Theme.of(context).colorScheme.secondary : AppColors.of(context).text.withOpacity(.25)),
|
||||||
|
const SizedBox(width: 14.0),
|
||||||
|
Text(
|
||||||
|
"notifications".i18n,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.of(context).text.withOpacity(
|
||||||
|
settings.notificationsEnabled ? 1.0 : .5),
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 16.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: Duration(milliseconds: 200),
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(left: 10, right: 10),
|
||||||
|
child: Center(
|
||||||
|
child: Text("BETA",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 9.1,
|
||||||
|
color: AppColors.of(context)
|
||||||
|
.text
|
||||||
|
.withOpacity(
|
||||||
|
settings.notificationsEnabled
|
||||||
|
? 1.0
|
||||||
|
: .5),
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
overflow: TextOverflow.ellipsis))),
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.of(context).filc.withOpacity(
|
||||||
|
settings.notificationsEnabled ? 1.0 : .5),
|
||||||
|
borderRadius: BorderRadius.circular(40)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
onChanged: (value) =>
|
||||||
|
settings.update(notificationsEnabled: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user