mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
notification overhaul
This commit is contained in:
@@ -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(
|
||||
|
Reference in New Issue
Block a user