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.
39 lines
1.4 KiB
Dart
39 lines
1.4 KiB
Dart
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 '../widgets/connect_sheet.dart';
|
|
|
|
/// The single rule for offline (read-only) mode: anything that talks to the
|
|
/// radio or changes stored history is unavailable unless a radio is
|
|
/// connected. Connecting and a pending auto-reconnect count as offline.
|
|
bool isRadioReadOnly(MeshCoreConnector connector) => !connector.isConnected;
|
|
|
|
extension RadioReadOnlyContext on BuildContext {
|
|
/// [isRadioReadOnly] for the connector in scope; rebuilds the caller when it
|
|
/// changes. Use in `build`; in callbacks use [ensureRadioConnected].
|
|
bool get radioReadOnly =>
|
|
select<MeshCoreConnector, bool>((c) => isRadioReadOnly(c));
|
|
}
|
|
|
|
/// Safety net for radio actions that could not be disabled in the UI (for
|
|
/// example a dialog that was already open when the link dropped). Returns
|
|
/// true when connected; otherwise explains why and offers to connect.
|
|
bool ensureRadioConnected(BuildContext context) {
|
|
if (!isRadioReadOnly(context.read<MeshCoreConnector>())) return true;
|
|
final l10n = context.l10n;
|
|
showDismissibleSnackBar(
|
|
context,
|
|
content: Text(l10n.settings_notConnectedError),
|
|
action: SnackBarAction(
|
|
label: l10n.common_connect,
|
|
onPressed: () {
|
|
if (context.mounted) showConnectSheet(context);
|
|
},
|
|
),
|
|
);
|
|
return false;
|
|
}
|