mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
feat: Integrate ShadSonner for improved toast notifications across multiple screens
This commit is contained in:
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:supplements/logging.dart';
|
||||
import 'package:supplements/services/simple_notification_service.dart';
|
||||
@@ -32,9 +33,6 @@ class NotificationRouter {
|
||||
printLog('🔔 handleNotificationResponse: Received actionId: $actionId');
|
||||
printLog('🔔 handleNotificationResponse: Decoded payloadMap: $payloadMap');
|
||||
|
||||
// Cancel retry notifications for any interaction (take, snooze, or tap)
|
||||
await _cancelRetryNotificationsForResponse(payloadMap);
|
||||
|
||||
// Handle Snooze actions without surfacing UI
|
||||
if (actionId == 'snooze_single' || actionId == 'snooze_group') {
|
||||
try {
|
||||
@@ -49,6 +47,11 @@ class NotificationRouter {
|
||||
|
||||
// Default: route to in-app UI for Take actions and normal taps
|
||||
await _routeFromPayload(payloadMap);
|
||||
|
||||
// Cancel retry notifications only for Take actions (not for taps or snoozes)
|
||||
if (actionId == 'take_single' || actionId == 'take_group') {
|
||||
await _cancelRetryNotificationsForResponse(payloadMap);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleAppLaunchDetails(NotificationAppLaunchDetails? details) async {
|
||||
@@ -294,8 +297,10 @@ class NotificationRouter {
|
||||
|
||||
void _showSnack(BuildContext context, String message) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message)),
|
||||
ShadSonner.of(context).show(
|
||||
ShadToast(
|
||||
title: Text(message),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user