Tester feedback: offline mode, pt-PT, menus, layout and translations
Offline (read-only) mode - The last connected radio is remembered; with no radio the app opens on its saved contacts, channels, messages and unread counts. - Main screens stay open on disconnect. A Connect button replaces the battery and signal indicators, with a sheet to reconnect, choose a radio or stop a pending reconnect. - While disconnected everything is read-only: the composer becomes a "connect to send" bar (drafts kept) and controls that change the radio or stored history are disabled or hidden. - Resending while disconnected no longer deletes the message; a different radio no longer shows the previous radio's channels. - Notification taps open the saved chat while offline. Chats and menus - Channel chat menu: notifications, edit channel, delete channel; the filter row lines up with the others; bell moved out of the app bar. - DM and room menus: remove from contacts; rooms get room management. - Search field uses the full app bar; long-press a result to copy. - Hashtag channel titles no longer read "# #name"; more room around the radio activity dot. - Repeat filter: short messages from one sender are caught at the same count as long ones. Layout - Shared menu row (wraps to two lines) and segment label (never splits a word) used across the app. - One Scan button on the scanner; consistent settings tile titles; contact "last seen" wraps instead of truncating; unfetched repeater settings are dimmed. Localization - New European Portuguese locale (pt_PT); regional locales are handled by the language picker, notifications and the background service. - Fill 67 missing strings per locale, including backup and restore. - Keep "Flood" and "Zero Hop" untranslated, shorten "last seen" and routing labels, and fix mistranslated scan, theme and hop strings. - Received-image strings, badge and caption come from translations. - Regenerate the Czech localizations, which were missing strings. Docs - Add documentation/design.md (UI reference) and offline-mode.md; update channel, chat, navigation and scanner docs.
This commit is contained in:
1 parent
47f2293a5c
commit
462159e803
108 files changed
+17435
-4536
No files matched your search
@@ -3,6 +3,8 @@ import 'package:meshcore_open/connector/meshcore_connector.dart';
|
||||
import 'package:meshcore_open/widgets/battery_indicator.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
import 'connect_sheet.dart';
|
||||
import 'radio_stats_entry.dart';
|
||||
import 'snr_indicator.dart';
|
||||
|
||||
@@ -34,11 +36,24 @@ class AppBarTitle extends StatelessWidget {
|
||||
? constraints.maxWidth
|
||||
: MediaQuery.sizeOf(context).width;
|
||||
final compact = availableWidth < 170;
|
||||
final showSubtitle =
|
||||
!compact && connector.isConnected && selfName != null && subtitle;
|
||||
final connected = connector.isConnected;
|
||||
final reconnecting =
|
||||
!connected &&
|
||||
(connector.state == MeshCoreConnectionState.connecting ||
|
||||
connector.isAutoReconnectScheduled);
|
||||
final offlineName = connector.lastRadioName;
|
||||
final subtitleText = !subtitle || compact
|
||||
? null
|
||||
: connected
|
||||
? selfName
|
||||
: offlineName != null && offlineName.isNotEmpty
|
||||
? context.l10n.appBar_offlineSubtitle(offlineName)
|
||||
: context.l10n.appBar_offline;
|
||||
final showBattery = showBatteryIndicator && availableWidth >= 60;
|
||||
final showSnr = availableWidth >= 110;
|
||||
final showIndicators = (showBattery || showSnr) && indicators;
|
||||
final showIndicators =
|
||||
connected && (showBattery || showSnr) && indicators;
|
||||
final showConnect = !connected && indicators;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@@ -50,9 +65,9 @@ class AppBarTitle extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
if (showSubtitle)
|
||||
if (subtitleText != null)
|
||||
Text(
|
||||
selfName,
|
||||
subtitleText,
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -72,6 +87,11 @@ class AppBarTitle extends StatelessWidget {
|
||||
const RadioStatsIconButton(compact: true),
|
||||
],
|
||||
),
|
||||
if (showConnect) const SizedBox(width: 6),
|
||||
if (showConnect)
|
||||
reconnecting
|
||||
? _ReconnectingChip(compact: availableWidth < 220)
|
||||
: ConnectButton(iconOnly: availableWidth < 220),
|
||||
trailing ?? const SizedBox.shrink(),
|
||||
],
|
||||
);
|
||||
@@ -79,3 +99,49 @@ class AppBarTitle extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ReconnectingChip extends StatelessWidget {
|
||||
final bool compact;
|
||||
|
||||
const _ReconnectingChip({required this.compact});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final label = context.l10n.appBar_reconnecting;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
const spinner = SizedBox.square(
|
||||
dimension: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2.5),
|
||||
);
|
||||
// Tapping still opens the sheet, which offers "Stop reconnecting".
|
||||
return Tooltip(
|
||||
message: label,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
onTap: () => showConnectSheet(context),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
spinner,
|
||||
if (!compact) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.labelLarge?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import '../helpers/gif_helper.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import 'byte_count_input.dart';
|
||||
import 'connect_sheet.dart';
|
||||
import 'gif_message.dart';
|
||||
import 'gif_picker.dart';
|
||||
import 'mesh_ui.dart';
|
||||
@@ -116,13 +118,7 @@ class ChatComposer extends StatelessWidget {
|
||||
for (final action in actions)
|
||||
PopupMenuItem(
|
||||
value: action.id,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(action.icon),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(child: Text(action.label)),
|
||||
],
|
||||
),
|
||||
child: MeshMenuItemRow(icon: action.icon, label: action.label),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -133,6 +129,9 @@ class ChatComposer extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
// Offline the chat is read-only. The draft stays in [controller] (owned
|
||||
// by the screen) and is back when the radio reconnects.
|
||||
if (context.radioReadOnly) return const OfflineComposerBar();
|
||||
final translation = context
|
||||
.select<AppSettingsService, (bool, bool, String?)>(
|
||||
(s) => (
|
||||
@@ -290,3 +289,70 @@ class ChatComposer extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Stands in for the composer while no radio is connected.
|
||||
class OfflineComposerBar extends StatelessWidget {
|
||||
const OfflineComposerBar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerLow,
|
||||
border: Border(top: BorderSide(color: scheme.outlineVariant, width: 1)),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 10, 12, 10),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final message = Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.cloud_off,
|
||||
color: scheme.onSurfaceVariant,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.l10n.chat_composerOffline,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyLarge?.copyWith(color: scheme.onSurface),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
// Side by side when there is room; otherwise the button goes
|
||||
// under the message so large text never squeezes it.
|
||||
final roomy =
|
||||
constraints.maxWidth /
|
||||
MediaQuery.textScalerOf(context).scale(1) >=
|
||||
420;
|
||||
if (roomy) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: message),
|
||||
const SizedBox(width: 8),
|
||||
const ConnectButton(),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
message,
|
||||
const SizedBox(height: 8),
|
||||
const ConnectButton(),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../helpers/message_search.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import 'chat_day_separator.dart';
|
||||
import 'empty_state.dart';
|
||||
@@ -15,6 +17,7 @@ class ChatSearchResults extends StatefulWidget {
|
||||
final double textScale;
|
||||
|
||||
/// Tapping a result: the chat closes search and jumps to the message.
|
||||
/// Long-pressing one copies its text.
|
||||
final ValueChanged<ChatSearchEntry>? onSelect;
|
||||
|
||||
const ChatSearchResults({
|
||||
@@ -156,6 +159,14 @@ class _ResultRow extends StatelessWidget {
|
||||
final shown = body.toLowerCase().contains(needle) ? body : entry.text;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
onLongPress: () async {
|
||||
await Clipboard.setData(ClipboardData(text: shown));
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.chat_messageCopied),
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Column(
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../screens/scanner_screen.dart';
|
||||
import '../screens/usb_screen.dart';
|
||||
import '../storage/last_radio_store.dart';
|
||||
import '../utils/dialog_utils.dart';
|
||||
import '../utils/platform_info.dart';
|
||||
import 'mesh_ui.dart';
|
||||
|
||||
/// Ways to get a radio connected: reconnect to the last one, pick another,
|
||||
/// or stop a pending automatic reconnect.
|
||||
Future<void> showConnectSheet(BuildContext context) {
|
||||
return showMeshSheet<void>(
|
||||
context,
|
||||
builder: (sheetContext) => _ConnectSheet(hostContext: context),
|
||||
);
|
||||
}
|
||||
|
||||
class _ConnectSheet extends StatelessWidget {
|
||||
/// Context of the screen that opened the sheet; it outlives the sheet.
|
||||
final BuildContext hostContext;
|
||||
|
||||
const _ConnectSheet({required this.hostContext});
|
||||
|
||||
Future<void> _reconnect(BuildContext context, String name) async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
Navigator.of(context).pop();
|
||||
final connected = await connector.reconnectToLastRadio();
|
||||
if (connected || !hostContext.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
hostContext,
|
||||
content: Text(hostContext.l10n.connectSheet_reconnectFailed(name)),
|
||||
);
|
||||
}
|
||||
|
||||
void _chooseRadio(BuildContext context, LastRadio? lastRadio) {
|
||||
Navigator.of(context).pop();
|
||||
if (!hostContext.mounted) return;
|
||||
final usb =
|
||||
PlatformInfo.isWeb ||
|
||||
(lastRadio?.transport == LastRadio.transportUsb &&
|
||||
PlatformInfo.supportsUsbSerial);
|
||||
Navigator.of(hostContext).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => usb ? const UsbScreen() : const ScannerScreen(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
final lastRadio = connector.lastRadio;
|
||||
final name = connector.lastRadioName ?? '';
|
||||
final connecting = connector.state == MeshCoreConnectionState.connecting;
|
||||
final canReconnect =
|
||||
!PlatformInfo.isWeb &&
|
||||
lastRadio != null &&
|
||||
name.isNotEmpty &&
|
||||
(lastRadio.canReconnectBle || lastRadio.canReconnectTcp);
|
||||
final titleStyle = textTheme.titleMedium;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
BottomSheetHeader(title: l10n.connectSheet_title),
|
||||
if (canReconnect)
|
||||
ListTile(
|
||||
minTileHeight: 64,
|
||||
leading: connecting
|
||||
? const SizedBox.square(
|
||||
dimension: 28,
|
||||
child: CircularProgressIndicator(strokeWidth: 3),
|
||||
)
|
||||
: Icon(
|
||||
lastRadio.canReconnectTcp ? Icons.lan : Icons.bluetooth,
|
||||
size: 28,
|
||||
),
|
||||
title: Text(l10n.connectSheet_reconnect(name), style: titleStyle),
|
||||
enabled: !connecting,
|
||||
onTap: () => _reconnect(context, name),
|
||||
),
|
||||
ListTile(
|
||||
minTileHeight: 64,
|
||||
leading: const Icon(Icons.radio, size: 28),
|
||||
title: Text(l10n.connectSheet_chooseRadio, style: titleStyle),
|
||||
subtitle: Text(l10n.connectSheet_chooseRadioSubtitle),
|
||||
onTap: () => _chooseRadio(context, lastRadio),
|
||||
),
|
||||
if (connector.isAutoReconnectScheduled)
|
||||
ListTile(
|
||||
minTileHeight: 64,
|
||||
leading: const Icon(Icons.sync_disabled, size: 28),
|
||||
title: Text(l10n.connectSheet_stopReconnecting, style: titleStyle),
|
||||
onTap: () {
|
||||
connector.cancelAutoReconnect();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Compact Connect button for app bars and read-only bars.
|
||||
class ConnectButton extends StatelessWidget {
|
||||
/// Icon only, for narrow app bars.
|
||||
final bool iconOnly;
|
||||
|
||||
const ConnectButton({super.key, this.iconOnly = false});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final label = context.l10n.common_connect;
|
||||
if (iconOnly) {
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.link),
|
||||
tooltip: label,
|
||||
onPressed: () => showConnectSheet(context),
|
||||
);
|
||||
}
|
||||
return FilledButton.tonalIcon(
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size(48, 48),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
visualDensity: VisualDensity.standard,
|
||||
),
|
||||
icon: const Icon(Icons.link, size: 20),
|
||||
label: Text(label),
|
||||
onPressed: () => showConnectSheet(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Overflow-menu entry of the main screens: Disconnect (after confirming,
|
||||
/// staying on the screen offline) while connected, Connect otherwise.
|
||||
/// [screenContext] must outlive the menu, as onTap runs after it closes.
|
||||
PopupMenuItem<T> connectionMenuItem<T>(
|
||||
BuildContext screenContext,
|
||||
BuildContext menuContext,
|
||||
) {
|
||||
final connector = screenContext.read<MeshCoreConnector>();
|
||||
final l10n = menuContext.l10n;
|
||||
if (connector.isConnected) {
|
||||
return PopupMenuItem<T>(
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.logout,
|
||||
iconColor: Theme.of(menuContext).colorScheme.error,
|
||||
label: l10n.common_disconnect,
|
||||
),
|
||||
onTap: () => showDisconnectDialog(screenContext, connector),
|
||||
);
|
||||
}
|
||||
return PopupMenuItem<T>(
|
||||
child: MeshMenuItemRow(icon: Icons.link, label: l10n.common_connect),
|
||||
onTap: () => showConnectSheet(screenContext),
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import '../l10n/l10n.dart';
|
||||
import '../services/image_chunk_transport.dart';
|
||||
import '../utils/lora_airtime.dart';
|
||||
import 'image_send_codec_binding.dart';
|
||||
import 'mesh_ui.dart';
|
||||
|
||||
/// Estimated wall clock above which the sheet warns the user explicitly.
|
||||
const Duration kImageSendLongAirtime = Duration(seconds: 5);
|
||||
@@ -426,11 +427,11 @@ class _ImageSendPreviewSheetState extends State<ImageSendPreviewSheet> {
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
label: Text(l10n.imageSend_viewOriginal),
|
||||
label: MeshSegmentLabel(l10n.imageSend_viewOriginal),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
label: Text(l10n.imageSend_viewReconstruction),
|
||||
label: MeshSegmentLabel(l10n.imageSend_viewReconstruction),
|
||||
enabled: _encoded != null && !_reconstructionUnavailable,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -20,6 +20,7 @@ final List<(String?, String Function(AppLocalizations))> appLanguageOptions = [
|
||||
('pl', (l) => l.appSettings_languagePl),
|
||||
('sl', (l) => l.appSettings_languageSl),
|
||||
('pt', (l) => l.appSettings_languagePt),
|
||||
('pt_PT', (l) => l.appSettings_languagePtPt),
|
||||
('it', (l) => l.appSettings_languageIt),
|
||||
('zh', (l) => l.appSettings_languageZh),
|
||||
('sv', (l) => l.appSettings_languageSv),
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Title style of settings rows: [MeshNavTile] and, through
|
||||
/// [MeshSettingsTileTheme], stock [ListTile]s and [SwitchListTile]s.
|
||||
TextStyle? meshTileTitleStyle(ThemeData theme) =>
|
||||
theme.textTheme.bodyLarge?.copyWith(fontWeight: FontWeight.w600);
|
||||
|
||||
/// Gives the [ListTile]s, [SwitchListTile]s and [CheckboxListTile]s below it
|
||||
/// the same semibold title as [MeshNavTile], so settings rows built from
|
||||
/// either read alike. Subtitles already match (`bodyMedium`,
|
||||
/// `onSurfaceVariant`). Wrap a settings screen's body in it.
|
||||
class MeshSettingsTileTheme extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const MeshSettingsTileTheme({super.key, required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTileTheme.merge(
|
||||
titleTextStyle: meshTileTitleStyle(Theme.of(context)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Settings-style navigation row: leading icon, bold title, secondary
|
||||
/// subtitle and an optional trailing chevron.
|
||||
///
|
||||
@@ -51,10 +74,7 @@ class MeshNavTile extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: textTheme.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: titleColor,
|
||||
),
|
||||
style: meshTileTitleStyle(theme)?.copyWith(color: titleColor),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
|
||||
+307
-1
@@ -1,6 +1,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
@@ -12,7 +13,8 @@ import '../theme/theme_icons.dart';
|
||||
/// Building blocks used across all screens so the app reads as one product:
|
||||
/// [SectionHeader], [MeshCard], [StatusChip], [StatTile], [AvatarCircle],
|
||||
/// [SignalBars], [RouteChip], [PulseDot], [BottomSheetHeader] +
|
||||
/// [showMeshSheet], [ErrorRetryCard], and [ListEntrance].
|
||||
/// [showMeshSheet], [ErrorRetryCard], [ListEntrance], [MeshSegmentLabel]
|
||||
/// and [MeshMenuItemRow].
|
||||
|
||||
/// Small-caps mono section label, optionally with a trailing widget.
|
||||
class SectionHeader extends StatelessWidget {
|
||||
@@ -749,3 +751,307 @@ class _ListEntranceState extends State<ListEntrance>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Contents of a [PopupMenuItem]: a 20px icon, a 12px gap and a label that
|
||||
/// wraps to at most [maxLines] lines and then ends in an ellipsis, so long
|
||||
/// translations are never clipped at the menu edge.
|
||||
///
|
||||
/// Pass an [icon], or a [leading] widget for custom icons (sized 20). With
|
||||
/// neither, a 20px gap keeps the label aligned with rows that have one.
|
||||
/// [color] tints icon and label (e.g. red for a destructive action);
|
||||
/// [iconColor] tints only the icon. [selected] bolds the label, for menus
|
||||
/// that mark the current choice.
|
||||
class MeshMenuItemRow extends StatelessWidget {
|
||||
final IconData? icon;
|
||||
final Widget? leading;
|
||||
final String label;
|
||||
final Color? color;
|
||||
final Color? iconColor;
|
||||
final bool selected;
|
||||
final int maxLines;
|
||||
|
||||
const MeshMenuItemRow({
|
||||
super.key,
|
||||
this.icon,
|
||||
this.leading,
|
||||
required this.label,
|
||||
this.color,
|
||||
this.iconColor,
|
||||
this.selected = false,
|
||||
this.maxLines = 2,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final effectiveIconColor = iconColor ?? color;
|
||||
return Row(
|
||||
children: [
|
||||
IconTheme.merge(
|
||||
data: IconThemeData(size: 20, color: effectiveIconColor),
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
child:
|
||||
leading ??
|
||||
(icon == null
|
||||
? null
|
||||
: Icon(icon, size: 20, color: effectiveIconColor)),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontWeight: selected ? FontWeight.bold : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Label for a [ButtonSegment] that never breaks a word in the middle.
|
||||
///
|
||||
/// Uses the button's text style. If the label does not fit on one line it is
|
||||
/// scaled down, but not below [minFontSize] (before the user's text scale).
|
||||
/// Below that, a multi-word label wraps at word boundaries onto up to
|
||||
/// [maxLines] centred lines, shrunk just enough for its longest word to fit.
|
||||
/// A single word that still does not fit keeps shrinking on one line, as
|
||||
/// splitting or clipping it would be harder to read than smaller text.
|
||||
class MeshSegmentLabel extends LeafRenderObjectWidget {
|
||||
final String text;
|
||||
final double minFontSize;
|
||||
final int maxLines;
|
||||
|
||||
const MeshSegmentLabel(
|
||||
this.text, {
|
||||
super.key,
|
||||
this.minFontSize = 12,
|
||||
this.maxLines = 2,
|
||||
});
|
||||
|
||||
TextStyle _style(BuildContext context) {
|
||||
final style = DefaultTextStyle.of(context).style;
|
||||
return MediaQuery.boldTextOf(context)
|
||||
? style.merge(const TextStyle(fontWeight: FontWeight.bold))
|
||||
: style;
|
||||
}
|
||||
|
||||
@override
|
||||
RenderObject createRenderObject(BuildContext context) {
|
||||
return _RenderSegmentLabel(
|
||||
text: text,
|
||||
style: _style(context),
|
||||
textScaler: MediaQuery.textScalerOf(context),
|
||||
textDirection: Directionality.of(context),
|
||||
minFontSize: minFontSize,
|
||||
maxLines: maxLines,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void updateRenderObject(BuildContext context, RenderObject renderObject) {
|
||||
(renderObject as _RenderSegmentLabel)
|
||||
..text = text
|
||||
..style = _style(context)
|
||||
..textScaler = MediaQuery.textScalerOf(context)
|
||||
..textDirection = Directionality.of(context)
|
||||
..minFontSize = minFontSize
|
||||
..maxLines = maxLines;
|
||||
}
|
||||
}
|
||||
|
||||
class _RenderSegmentLabel extends RenderBox {
|
||||
_RenderSegmentLabel({
|
||||
required String text,
|
||||
required TextStyle style,
|
||||
required TextScaler textScaler,
|
||||
required TextDirection textDirection,
|
||||
required double minFontSize,
|
||||
required int maxLines,
|
||||
}) : _text = text,
|
||||
_style = style,
|
||||
_textScaler = textScaler,
|
||||
_textDirection = textDirection,
|
||||
_minFontSize = minFontSize,
|
||||
_maxLines = maxLines;
|
||||
|
||||
final TextPainter _painter = TextPainter(textAlign: TextAlign.center);
|
||||
|
||||
String _text;
|
||||
set text(String value) {
|
||||
if (value == _text) return;
|
||||
_text = value;
|
||||
markNeedsLayout();
|
||||
markNeedsSemanticsUpdate();
|
||||
}
|
||||
|
||||
TextStyle _style;
|
||||
set style(TextStyle value) {
|
||||
if (value == _style) return;
|
||||
final relayout =
|
||||
value.compareTo(_style).index > RenderComparison.paint.index;
|
||||
_style = value;
|
||||
relayout ? markNeedsLayout() : markNeedsPaint();
|
||||
}
|
||||
|
||||
TextScaler _textScaler;
|
||||
set textScaler(TextScaler value) {
|
||||
if (value == _textScaler) return;
|
||||
_textScaler = value;
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
TextDirection _textDirection;
|
||||
set textDirection(TextDirection value) {
|
||||
if (value == _textDirection) return;
|
||||
_textDirection = value;
|
||||
markNeedsLayout();
|
||||
markNeedsSemanticsUpdate();
|
||||
}
|
||||
|
||||
double _minFontSize;
|
||||
set minFontSize(double value) {
|
||||
if (value == _minFontSize) return;
|
||||
_minFontSize = value;
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
int _maxLines;
|
||||
set maxLines(int value) {
|
||||
if (value == _maxLines) return;
|
||||
_maxLines = value;
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
double get _fontSize => _style.fontSize ?? 14;
|
||||
|
||||
/// [_textScaler] further multiplied by [factor].
|
||||
TextScaler _scaled(double factor) {
|
||||
if (factor >= 1) return _textScaler;
|
||||
return TextScaler.linear(_textScaler.scale(_fontSize) * factor / _fontSize);
|
||||
}
|
||||
|
||||
double _lineWidth(TextPainter painter, String text, TextScaler scaler) {
|
||||
painter
|
||||
..text = TextSpan(text: text, style: _style)
|
||||
..textDirection = _textDirection
|
||||
..textScaler = scaler
|
||||
..maxLines = 1
|
||||
..ellipsis = null
|
||||
..layout();
|
||||
return painter.width;
|
||||
}
|
||||
|
||||
/// Configures [painter] for [maxWidth] and lays it out.
|
||||
void _fit(TextPainter painter, double maxWidth) {
|
||||
final full = _lineWidth(painter, _text, _textScaler);
|
||||
var factor = 1.0;
|
||||
var lines = 1;
|
||||
if (full > maxWidth) {
|
||||
// A little slack: glyph metrics do not scale exactly linearly.
|
||||
final fitFactor = maxWidth / full * 0.98;
|
||||
final floor = math.min(1.0, _minFontSize / _fontSize);
|
||||
final words = _text.trim().split(RegExp(r'\s+'));
|
||||
if (fitFactor >= floor || words.length < 2) {
|
||||
factor = fitFactor;
|
||||
} else {
|
||||
final longest = words
|
||||
.map((w) => _lineWidth(painter, w, _textScaler))
|
||||
.reduce(math.max);
|
||||
factor = math.min(1.0, maxWidth / longest * 0.98);
|
||||
lines = _maxLines;
|
||||
}
|
||||
}
|
||||
painter
|
||||
..text = TextSpan(text: _text, style: _style)
|
||||
..textDirection = _textDirection
|
||||
..textScaler = _scaled(factor)
|
||||
..maxLines = lines
|
||||
..ellipsis = '\u2026'
|
||||
..layout(maxWidth: maxWidth);
|
||||
}
|
||||
|
||||
double _intrinsicHeight(double width) {
|
||||
final painter = TextPainter(textAlign: TextAlign.center);
|
||||
_fit(painter, width);
|
||||
final height = painter.height;
|
||||
painter.dispose();
|
||||
return height;
|
||||
}
|
||||
|
||||
@override
|
||||
double computeMinIntrinsicWidth(double height) {
|
||||
final painter = TextPainter();
|
||||
final floor = math.min(1.0, _minFontSize / _fontSize);
|
||||
final longest = _text
|
||||
.trim()
|
||||
.split(RegExp(r'\s+'))
|
||||
.map((w) => _lineWidth(painter, w, _scaled(floor)))
|
||||
.reduce(math.max);
|
||||
painter.dispose();
|
||||
return longest.ceilToDouble();
|
||||
}
|
||||
|
||||
@override
|
||||
double computeMaxIntrinsicWidth(double height) {
|
||||
final painter = TextPainter();
|
||||
final width = _lineWidth(painter, _text, _textScaler);
|
||||
painter.dispose();
|
||||
return width.ceilToDouble();
|
||||
}
|
||||
|
||||
@override
|
||||
double computeMinIntrinsicHeight(double width) => _intrinsicHeight(width);
|
||||
|
||||
@override
|
||||
double computeMaxIntrinsicHeight(double width) => _intrinsicHeight(width);
|
||||
|
||||
@override
|
||||
Size computeDryLayout(covariant BoxConstraints constraints) {
|
||||
final painter = TextPainter(textAlign: TextAlign.center);
|
||||
_fit(painter, constraints.maxWidth);
|
||||
final size = constraints.constrain(painter.size);
|
||||
painter.dispose();
|
||||
return size;
|
||||
}
|
||||
|
||||
Offset get _paintOffset => Offset(
|
||||
(size.width - _painter.width) / 2,
|
||||
(size.height - _painter.height) / 2,
|
||||
);
|
||||
|
||||
@override
|
||||
void performLayout() {
|
||||
_fit(_painter, constraints.maxWidth);
|
||||
size = constraints.constrain(_painter.size);
|
||||
}
|
||||
|
||||
@override
|
||||
double? computeDistanceToActualBaseline(TextBaseline baseline) {
|
||||
return _paintOffset.dy + _painter.computeDistanceToActualBaseline(baseline);
|
||||
}
|
||||
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
_painter.paint(context.canvas, offset + _paintOffset);
|
||||
}
|
||||
|
||||
@override
|
||||
void describeSemanticsConfiguration(SemanticsConfiguration config) {
|
||||
super.describeSemanticsConfiguration(config);
|
||||
config
|
||||
..label = _text
|
||||
..textDirection = _textDirection;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_painter.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import '../l10n/l10n.dart';
|
||||
import '../models/display_path.dart';
|
||||
import '../models/path_playback.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import 'mesh_ui.dart';
|
||||
|
||||
/// Shared UI for the path map screens (live path trace and received-message
|
||||
/// path map): packet-flow animation overlays, single/combined view toggle,
|
||||
@@ -319,11 +320,11 @@ class PathViewModeToggle extends StatelessWidget {
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: PathViewMode.single,
|
||||
label: Text(l10n.pathMap_viewSingle),
|
||||
label: MeshSegmentLabel(l10n.pathMap_viewSingle),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: PathViewMode.combined,
|
||||
label: Text(l10n.pathMap_viewCombined),
|
||||
label: MeshSegmentLabel(l10n.pathMap_viewCombined),
|
||||
),
|
||||
],
|
||||
selected: {mode},
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../helpers/snack_bar_builder.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../models/radio_settings.dart';
|
||||
import '../services/app_debug_log_service.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
|
||||
/// Convert device coding-rate value (1-4 on some firmware, 5-8 on others)
|
||||
/// to the UI enum range (always 5-8).
|
||||
@@ -382,6 +383,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
}
|
||||
|
||||
Future<void> _saveSettings() async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final l10n = context.l10n;
|
||||
final freqMHz = double.tryParse(_frequencyController.text);
|
||||
final txPower = int.tryParse(_txPowerController.text);
|
||||
|
||||
@@ -73,15 +73,20 @@ class _RadioStatsIconButtonState extends State<RadioStatsIconButton> {
|
||||
),
|
||||
);
|
||||
}
|
||||
return Tooltip(
|
||||
message: context.l10n.radioStats_tooltip,
|
||||
child: InkWell(
|
||||
customBorder: const CircleBorder(),
|
||||
onTap: () => pushCompanionRadioStatsScreen(context),
|
||||
child: SizedBox(
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: Center(child: dot),
|
||||
// The gap after the dot keeps it from crowding the next app bar
|
||||
// action; it is outside the tap target, which stays 48px.
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 8),
|
||||
child: Tooltip(
|
||||
message: context.l10n.radioStats_tooltip,
|
||||
child: InkWell(
|
||||
customBorder: const CircleBorder(),
|
||||
onTap: () => pushCompanionRadioStatsScreen(context),
|
||||
child: SizedBox(
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: Center(child: dot),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -33,15 +33,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/received_image_store.dart';
|
||||
import 'image_send_codec_binding.dart' show ImageCodecAvailability;
|
||||
|
||||
/// User-visible strings for the NON-decoded states.
|
||||
///
|
||||
/// Exists so the wiring agent can hand in `AppLocalizations` values once the
|
||||
/// `receivedImage_*` ARB keys land (they do not exist yet, so English defaults
|
||||
/// ship inline). Deliberately contains no field for the R6 badge or caption:
|
||||
/// those must not be overridable, shortenable or blankable.
|
||||
/// Built from `AppLocalizations` by [ReceivedImageStrings.of]; the widget does
|
||||
/// that itself when no [ReceivedImageMessage.strings] override is passed.
|
||||
/// Deliberately contains no field for the R6 badge or caption: those must not
|
||||
/// be overridable, shortenable or blankable.
|
||||
@immutable
|
||||
class ReceivedImageStrings {
|
||||
final String Function(int received, int total) incoming;
|
||||
@@ -67,11 +69,8 @@ class ReceivedImageStrings {
|
||||
required this.incoming,
|
||||
required this.queued,
|
||||
required this.tapToDecode,
|
||||
// Optional on purpose: `channel_chat_screen.dart` builds this object and is
|
||||
// owned by another workstream, so the two tap-to-process strings must not
|
||||
// break that call site before the `receivedImage_*` ARB keys land.
|
||||
this.awaiting = _defaultAwaiting,
|
||||
this.tapToProcess = 'Tap to process',
|
||||
required this.awaiting,
|
||||
required this.tapToProcess,
|
||||
required this.decoding,
|
||||
required this.incomplete,
|
||||
required this.corrupt,
|
||||
@@ -82,41 +81,52 @@ class ReceivedImageStrings {
|
||||
required this.openSettings,
|
||||
});
|
||||
|
||||
// TODO(l10n): replace with context.l10n.receivedImage_* once app_en.arb has
|
||||
// the keys listed in section 5(k) of the receive spec.
|
||||
static ReceivedImageStrings english = ReceivedImageStrings(
|
||||
incoming: (received, total) => '$received of $total packets',
|
||||
queued: 'Waiting to decode',
|
||||
tapToDecode: 'Tap to decode',
|
||||
awaiting: _defaultAwaiting,
|
||||
tapToProcess: 'Tap to process',
|
||||
decoding: 'Reconstructing… about 1 s',
|
||||
incomplete: (received, total) =>
|
||||
'Image incomplete — $received of $total packets arrived',
|
||||
corrupt: 'Image could not be reconstructed',
|
||||
decoderMissing: 'Image received — image decoding is off',
|
||||
evicted: 'Image no longer stored',
|
||||
retry: 'Try again',
|
||||
decodeAgain: 'Decode again',
|
||||
openSettings: 'Set up',
|
||||
);
|
||||
/// The app's `receivedImage_*` strings for [l10n]'s locale.
|
||||
factory ReceivedImageStrings.of(AppLocalizations l10n) =>
|
||||
ReceivedImageStrings(
|
||||
incoming: l10n.receivedImage_incoming,
|
||||
queued: l10n.receivedImage_queued,
|
||||
tapToDecode: l10n.receivedImage_tapToDecode,
|
||||
awaiting: l10n.receivedImage_awaiting,
|
||||
tapToProcess: l10n.receivedImage_tapToProcess,
|
||||
decoding: l10n.receivedImage_decoding,
|
||||
incomplete: l10n.receivedImage_incomplete,
|
||||
corrupt: l10n.receivedImage_corrupt,
|
||||
decoderMissing: l10n.receivedImage_decoderMissing,
|
||||
evicted: l10n.receivedImage_evicted,
|
||||
retry: l10n.receivedImage_retry,
|
||||
decodeAgain: l10n.receivedImage_decodeAgain,
|
||||
openSettings: l10n.receivedImage_openSettings,
|
||||
);
|
||||
}
|
||||
|
||||
/// English default for [ReceivedImageStrings.awaiting]. A top-level function so
|
||||
/// it can be a `const` default value on the constructor.
|
||||
String _defaultAwaiting(int bytes, int packets) =>
|
||||
'$bytes bytes · $packets packets';
|
||||
/// The R6 label texts, localised but never injectable and never empty.
|
||||
///
|
||||
/// Resolved inside the private R6 widgets from the widget tree, so no caller
|
||||
/// can pass a replacement. If the tree has no `AppLocalizations`, or a
|
||||
/// translation is blank, the English text is used instead: a missing
|
||||
/// translation must never be able to remove the label.
|
||||
AppLocalizations _r6Strings(BuildContext context) {
|
||||
final l10n = Localizations.of<AppLocalizations>(context, AppLocalizations);
|
||||
if (l10n != null &&
|
||||
l10n.receivedImage_syntheticBadge.trim().isNotEmpty &&
|
||||
l10n.receivedImage_shareCaption(0).trim().isNotEmpty) {
|
||||
return l10n;
|
||||
}
|
||||
return lookupAppLocalizations(const Locale('en'));
|
||||
}
|
||||
|
||||
/// Text of the R6 label. Private and const: not injectable, not localisable
|
||||
/// yet, and never empty.
|
||||
const String _kSyntheticBadge = 'AI-reconstructed';
|
||||
/// Text of the R6 badge burnt into the image.
|
||||
String _syntheticBadge(BuildContext context) =>
|
||||
_r6Strings(context).receivedImage_syntheticBadge;
|
||||
|
||||
/// The caption is built from the ACTUAL bitstream size, never a nominal one:
|
||||
/// quoting a fixed "~156 bytes" under an image that took 209 is its own small
|
||||
/// dishonesty, in a label whose whole job is honesty.
|
||||
String _syntheticCaptionFor(int bytes) =>
|
||||
'Reconstructed by an AI model from $bytes bytes. '
|
||||
'Fine detail is generated, not transmitted.';
|
||||
/// dishonesty, in a label whose whole job is honesty. Same sentence as the
|
||||
/// share text in the channel screen, so the label reads identically wherever
|
||||
/// the image goes.
|
||||
String _syntheticCaptionFor(BuildContext context, int bytes) =>
|
||||
_r6Strings(context).receivedImage_shareCaption(bytes);
|
||||
|
||||
class ReceivedImageMessage extends StatefulWidget {
|
||||
/// 14 hex chars, as parsed out of the message text by
|
||||
@@ -225,7 +235,8 @@ class _ReceivedImageMessageState extends State<ReceivedImageMessage> {
|
||||
);
|
||||
}
|
||||
|
||||
ReceivedImageStrings get _s => widget.strings ?? ReceivedImageStrings.english;
|
||||
ReceivedImageStrings get _s =>
|
||||
widget.strings ?? ReceivedImageStrings.of(context.l10n);
|
||||
|
||||
Widget _buildForEntry(
|
||||
BuildContext context,
|
||||
@@ -558,7 +569,7 @@ class _SyntheticBanner extends StatelessWidget {
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
_kSyntheticBadge,
|
||||
_syntheticBadge(context),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.white),
|
||||
@@ -572,8 +583,8 @@ class _SyntheticBanner extends StatelessWidget {
|
||||
|
||||
/// R6, part 2: the full sentence, immediately under the image.
|
||||
class _SyntheticCaption extends StatelessWidget {
|
||||
/// Contrast variant only. The TEXT is the same const in both cases; there is
|
||||
/// no parameter that can shorten, blank or restyle it away.
|
||||
/// Contrast variant only. The TEXT is the same in both cases; there is no
|
||||
/// parameter that can shorten, blank or restyle it away.
|
||||
final bool onDark;
|
||||
|
||||
/// Size of the bitstream this image was reconstructed from.
|
||||
@@ -586,7 +597,7 @@ class _SyntheticCaption extends StatelessWidget {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
_syntheticCaptionFor(bytes),
|
||||
_syntheticCaptionFor(context, bytes),
|
||||
// No maxLines: the bubble is narrow and the sentence must never be
|
||||
// truncated. A label that reads "Details are invented. Not a" is worse
|
||||
// than none — it clips exactly where the warning was going.
|
||||
|
||||
@@ -15,6 +15,7 @@ import '../widgets/mesh_ui.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../helpers/utf8_length_limiter.dart';
|
||||
import 'routing_sheet.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
|
||||
class RepeaterLoginDialog extends StatefulWidget {
|
||||
final Contact repeater;
|
||||
@@ -93,6 +94,7 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
|
||||
Future<void> _handleLogin() async {
|
||||
if (_isLoggingIn) return;
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
|
||||
setState(() {
|
||||
_isLoggingIn = true;
|
||||
@@ -446,48 +448,24 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'auto',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_mode,
|
||||
size: 20,
|
||||
color: !isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_autoUseSavedPath,
|
||||
style: TextStyle(
|
||||
fontWeight: !isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.auto_mode,
|
||||
label: l10n.login_autoUseSavedPath,
|
||||
iconColor: !isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
selected: !isFloodMode,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'flood',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.waves,
|
||||
size: 20,
|
||||
color: isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_forceFloodMode,
|
||||
style: TextStyle(
|
||||
fontWeight: isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.waves,
|
||||
label: l10n.login_forceFloodMode,
|
||||
iconColor: isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
selected: isFloodMode,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../utils/app_logger.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../helpers/utf8_length_limiter.dart';
|
||||
import 'routing_sheet.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
|
||||
class RoomLoginDialog extends StatefulWidget {
|
||||
final Contact room;
|
||||
@@ -90,6 +91,7 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
|
||||
Future<void> _handleLogin() async {
|
||||
if (_isLoggingIn) return;
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
|
||||
setState(() {
|
||||
_isLoggingIn = true;
|
||||
@@ -378,48 +380,24 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'auto',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_mode,
|
||||
size: 20,
|
||||
color: !isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_autoUseSavedPath,
|
||||
style: TextStyle(
|
||||
fontWeight: !isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.auto_mode,
|
||||
label: l10n.login_autoUseSavedPath,
|
||||
iconColor: !isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
selected: !isFloodMode,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'flood',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.waves,
|
||||
size: 20,
|
||||
color: isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_forceFloodMode,
|
||||
style: TextStyle(
|
||||
fontWeight: isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.waves,
|
||||
label: l10n.login_forceFloodMode,
|
||||
iconColor: isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
selected: isFloodMode,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -10,6 +10,8 @@ import '../models/contact.dart';
|
||||
import '../models/path_history.dart';
|
||||
import '../screens/path_trace_map.dart';
|
||||
import '../services/path_history_service.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import 'mesh_ui.dart';
|
||||
import 'path_editor_sheet.dart';
|
||||
|
||||
enum _RoutingMode { auto, flood, direct, manual }
|
||||
@@ -448,7 +450,11 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.restart_alt, size: 18),
|
||||
label: Text(l10n.routing_forgetPath),
|
||||
onPressed: () => _forgetPath(connector, contact),
|
||||
// Resets the path on the radio; offline it would do
|
||||
// nothing yet report success.
|
||||
onPressed: isRadioReadOnly(connector)
|
||||
? null
|
||||
: () => _forgetPath(connector, contact),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -733,10 +739,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
) => ButtonSegment(
|
||||
value: value,
|
||||
icon: showIcons ? Icon(icon) : null,
|
||||
label: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(label, maxLines: 1, softWrap: false),
|
||||
),
|
||||
label: MeshSegmentLabel(label),
|
||||
);
|
||||
return SegmentedButton<_RoutingMode>(
|
||||
showSelectedIcon: false,
|
||||
|
||||
Reference in new issue
Block a user