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
+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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user