Fix review findings in channel notification modes
- Detect mentions on the original text, as @[name] or a whole-word @name - Save and restore the full mode map in review mode - Open the mode picker from the chat bell and show the mode in its tooltip - Share one mode picker sheet; fix the stale sheet context - Persist modes by name and skip unknown entries - Keep writing muted_channels so older builds keep the user's mutes - Remove the muteChannel/unmuteChannel/isChannelMuted shims - Update notifications docs to match the behaviour
This commit is contained in:
1 parent
705bff2f15
commit
f667320608
32 files changed
+502
-196
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/app_settings_service.dart'
|
||||
show AppSettingsService, ChannelNotificationMode;
|
||||
import 'mesh_ui.dart';
|
||||
|
||||
/// Localized label for a channel notification [mode].
|
||||
String channelNotificationModeLabel(
|
||||
BuildContext context,
|
||||
ChannelNotificationMode mode,
|
||||
) => switch (mode) {
|
||||
ChannelNotificationMode.all => context.l10n.channels_notifyAll,
|
||||
ChannelNotificationMode.mentionsOnly =>
|
||||
context.l10n.channels_notifyMentionsOnly,
|
||||
ChannelNotificationMode.muted => context.l10n.channels_notifyNone,
|
||||
};
|
||||
|
||||
/// Icon for a channel notification [mode].
|
||||
IconData channelNotificationModeIcon(ChannelNotificationMode mode) =>
|
||||
switch (mode) {
|
||||
ChannelNotificationMode.all => Icons.notifications,
|
||||
ChannelNotificationMode.mentionsOnly => Icons.notification_important,
|
||||
ChannelNotificationMode.muted => Icons.notifications_off,
|
||||
};
|
||||
|
||||
/// Shows the per-channel notification mode picker (all / mentions only /
|
||||
/// muted) for the channel identified by [muteKey].
|
||||
void showChannelNotificationModeSheet(BuildContext context, String muteKey) {
|
||||
final settingsService = context.read<AppSettingsService>();
|
||||
final currentMode = settingsService.getChannelNotificationMode(muteKey);
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (sheetContext) {
|
||||
final scheme = Theme.of(sheetContext).colorScheme;
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final mode in ChannelNotificationMode.values)
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
channelNotificationModeIcon(mode),
|
||||
color: mode == currentMode
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
title: Text(channelNotificationModeLabel(sheetContext, mode)),
|
||||
trailing: mode == currentMode ? const Icon(Icons.check) : null,
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
await settingsService.setChannelNotificationMode(
|
||||
muteKey,
|
||||
mode,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user