simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
+26 -23
View File
@@ -203,16 +203,10 @@ class PushRenderer {
messages: styleMessages,
);
final androidDetails = AndroidNotificationDetails(
talkChannelId,
talkChannelName,
importance: Importance.high,
priority: Priority.high,
category: AndroidNotificationCategory.message,
color: _accentColor,
final androidDetails = _talkAndroidDetails(
tag: tag,
style: messagingStyle,
silent: !alert,
styleInformation: messagingStyle,
actions: _talkActions,
);
@@ -247,17 +241,11 @@ class PushRenderer {
title: senderName,
body: messageText,
notificationDetails: NotificationDetails(
android: AndroidNotificationDetails(
talkChannelId,
talkChannelName,
importance: Importance.high,
priority: Priority.high,
category: AndroidNotificationCategory.message,
color: _accentColor,
android: _talkAndroidDetails(
tag: tag,
// Single sender ⇒ no conversationTitle (1:1 convention): the sender
// Person is the header, a title would repeat the name per line.
styleInformation: MessagingStyleInformation(
style: MessagingStyleInformation(
const Person(key: 'self', name: 'Ich'),
groupConversation: false,
messages: [
@@ -271,6 +259,25 @@ class PushRenderer {
);
}
static AndroidNotificationDetails _talkAndroidDetails({
required String tag,
required StyleInformation style,
AndroidNotificationCategory? category = AndroidNotificationCategory.message,
bool silent = false,
List<AndroidNotificationAction>? actions,
}) => AndroidNotificationDetails(
talkChannelId,
talkChannelName,
importance: Importance.high,
priority: Priority.high,
category: category,
color: _accentColor,
tag: tag,
silent: silent,
styleInformation: style,
actions: actions,
);
// Both actions keep cancelNotification: true (the default): the plugin's
// Java receiver then removes the card NATIVELY the moment the action fires.
// The reply action must not rely on our Dart-side cancel instead — MIUI/
@@ -306,14 +313,10 @@ class PushRenderer {
title: title,
body: body,
notificationDetails: NotificationDetails(
android: AndroidNotificationDetails(
talkChannelId,
talkChannelName,
importance: Importance.high,
priority: Priority.high,
color: _accentColor,
android: _talkAndroidDetails(
tag: 'talk_error_$chatToken',
styleInformation: BigTextStyleInformation(body),
style: BigTextStyleInformation(body),
category: null,
),
iOS: const DarwinNotificationDetails(),
),