Files
meshcore-open/lib/widgets/radio_stats_entry.dart
T
zjs81 462159e803 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.
2026-11-09 21:18:29 -07:00

159 lines
4.3 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:meshcore_open/connector/meshcore_connector.dart';
import 'package:meshcore_open/models/companion_radio_stats.dart';
import 'package:meshcore_open/l10n/l10n.dart';
import 'package:meshcore_open/screens/companion_radio_stats_screen.dart';
import 'package:provider/provider.dart';
import 'mesh_ui.dart';
void pushCompanionRadioStatsScreen(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (context) => const CompanionRadioStatsScreen(),
),
);
}
class RadioStatsIconButton extends StatefulWidget {
final bool compact;
const RadioStatsIconButton({super.key, this.compact = false});
@override
State<RadioStatsIconButton> createState() => _RadioStatsIconButtonState();
}
class _RadioStatsIconButtonState extends State<RadioStatsIconButton> {
MeshCoreConnector? _connector;
@override
void initState() {
super.initState();
final c = context.read<MeshCoreConnector>();
_connector = c;
c.acquireRadioStatsPolling();
}
@override
void dispose() {
_connector?.releaseRadioStatsPolling();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Selector<MeshCoreConnector, ({bool connected, bool supported})>(
selector: (_, c) =>
(connected: c.isConnected, supported: c.supportsCompanionRadioStats),
builder: (context, state, _) {
if (!state.connected || !state.supported) {
return const SizedBox.shrink();
}
final connector = context.read<MeshCoreConnector>();
return ValueListenableBuilder<CompanionRadioStats?>(
valueListenable: connector.radioStatsNotifier,
builder: (context, _, child) {
final dot = AirActivityDot(
active: connector.radioStatsAirActivityPulse,
);
if (widget.compact) {
return Semantics(
label: context.l10n.radioStats_tooltip,
button: true,
child: GestureDetector(
onTap: () => pushCompanionRadioStatsScreen(context),
child: Padding(
padding: const EdgeInsets.only(left: 4),
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),
),
),
),
);
},
);
},
);
}
}
class AirActivityDot extends StatefulWidget {
final bool active;
const AirActivityDot({super.key, required this.active});
@override
State<AirActivityDot> createState() => AirActivityDotState();
}
class AirActivityDotState extends State<AirActivityDot> {
Timer? _timer;
bool _blink = true;
@override
void initState() {
super.initState();
if (widget.active) _startTimer();
}
@override
void didUpdateWidget(covariant AirActivityDot oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.active && !oldWidget.active) {
_startTimer();
} else if (!widget.active && oldWidget.active) {
_stopTimer();
_blink = true;
}
}
void _startTimer() {
_timer ??= Timer.periodic(const Duration(milliseconds: 400), (_) {
if (!mounted) return;
setState(() => _blink = !_blink);
});
}
void _stopTimer() {
_timer?.cancel();
_timer = null;
}
@override
void dispose() {
_stopTimer();
super.dispose();
}
@override
Widget build(BuildContext context) {
final on = widget.active && _blink;
final scheme = Theme.of(context).colorScheme;
return PulseDot(
color: on ? scheme.primary : scheme.outline,
size: 11,
animate: false,
);
}
}