notification overhaul

This commit is contained in:
2025-08-30 00:12:29 +02:00
parent 9ae2bb5654
commit 6dccac6124
25 changed files with 1313 additions and 3947 deletions

View File

@@ -1,12 +1,17 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:supplements/logging.dart';
import 'providers/settings_provider.dart';
import 'providers/simple_sync_provider.dart';
import 'providers/supplement_provider.dart';
import 'screens/home_screen.dart';
import 'screens/profile_setup_screen.dart';
import 'services/notification_router.dart';
import 'services/simple_notification_service.dart';
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
void main() async {
WidgetsFlutterBinding.ensureInitialized();
@@ -42,15 +47,23 @@ class MyApp extends StatelessWidget {
WidgetsBinding.instance.addPostFrameCallback((_) {
final supplementProvider = context.read<SupplementProvider>();
// Initialize notification router with the app's navigator
NotificationRouter.instance.initialize(navigatorKey);
// If the app was launched via a notification, route to the proper dialog
SimpleNotificationService.instance.getLaunchDetails().then((details) {
NotificationRouter.instance.handleAppLaunchDetails(details);
});
// Set up sync completion callback
syncProvider.setOnSyncCompleteCallback(() async {
if (kDebugMode) {
print('SupplementsLog: Sync completed, refreshing UI data...');
printLog('Sync completed, refreshing UI data...');
}
await supplementProvider.loadSupplements();
await supplementProvider.loadTodayIntakes();
if (kDebugMode) {
print('SupplementsLog: UI data refreshed after sync');
printLog('UI data refreshed after sync');
}
});
@@ -64,6 +77,7 @@ class MyApp extends StatelessWidget {
});
return MaterialApp(
navigatorKey: navigatorKey,
title: 'Supplements Tracker',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(