Files
meshcore-open/lib/widgets/channel_notification_mode_sheet.dart
T
zjs81 979e1a7d2a Fix layouts on small screens and large text, and test every screen
Contact rows give the name its own line (wrapping to two) with route and
last seen below, right-aligned on wide windows. Fixes overflows found by a
new widget test that renders every screen at 320x568 with text scales up to
2.0 and on a desktop window: region dropdown, contacts list, repeater CLI,
status grid and settings card, map cache buttons, and empty states.
Dropdowns truncate long labels, and option sheets and dialogs scroll.
2026-10-25 11:10:27 -07:00

70 lines
2.4 KiB
Dart

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: SingleChildScrollView(
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,
);
},
),
],
),
),
);
},
);
}