✨ Notify with haptic feedback
This commit is contained in:
@@ -4,10 +4,12 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:island/main.dart';
|
import 'package:island/main.dart';
|
||||||
|
import 'package:island/pods/config.dart';
|
||||||
import 'package:island/route.dart';
|
import 'package:island/route.dart';
|
||||||
import 'package:island/models/account.dart';
|
import 'package:island/models/account.dart';
|
||||||
import 'package:island/pods/websocket.dart';
|
import 'package:island/pods/websocket.dart';
|
||||||
@@ -89,6 +91,7 @@ StreamSubscription<WebSocketPacket> setupNotificationListener(
|
|||||||
BuildContext context,
|
BuildContext context,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
) {
|
) {
|
||||||
|
final settings = ref.watch(appSettingsProvider);
|
||||||
final ws = ref.watch(websocketProvider);
|
final ws = ref.watch(websocketProvider);
|
||||||
return ws.dataStream.listen((pkt) async {
|
return ws.dataStream.listen((pkt) async {
|
||||||
if (pkt.type == "notifications.new") {
|
if (pkt.type == "notifications.new") {
|
||||||
@@ -98,6 +101,9 @@ StreamSubscription<WebSocketPacket> setupNotificationListener(
|
|||||||
talker.info(
|
talker.info(
|
||||||
'[Notification] Showing in-app notification: ${notification.title}',
|
'[Notification] Showing in-app notification: ${notification.title}',
|
||||||
);
|
);
|
||||||
|
if (settings.notifyWithHaptic) {
|
||||||
|
HapticFeedback.heavyImpact();
|
||||||
|
}
|
||||||
showTopSnackBar(
|
showTopSnackBar(
|
||||||
globalOverlay.currentState!,
|
globalOverlay.currentState!,
|
||||||
Center(
|
Center(
|
||||||
@@ -115,12 +121,12 @@ StreamSubscription<WebSocketPacket> setupNotificationListener(
|
|||||||
right: 16,
|
right: 16,
|
||||||
top:
|
top:
|
||||||
(!kIsWeb &&
|
(!kIsWeb &&
|
||||||
(Platform.isMacOS ||
|
(Platform.isMacOS ||
|
||||||
Platform.isWindows ||
|
Platform.isWindows ||
|
||||||
Platform.isLinux))
|
Platform.isLinux))
|
||||||
? 28
|
? 28
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
: MediaQuery.of(context).padding.top + 16,
|
: MediaQuery.of(context).padding.top + 16,
|
||||||
bottom: 16,
|
bottom: 16,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user