Files
meshcore-open/lib/widgets/language_picker_sheet.dart
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

83 lines
2.8 KiB
Dart

import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../l10n/l10n.dart';
import '../services/app_settings_service.dart';
import 'mesh_nav_tile.dart';
import 'mesh_ui.dart';
/// App UI languages offered in settings, in display order. A null code means
/// "follow the system language". Add a locale here (and only here) to make it
/// selectable and labelled.
final List<(String?, String Function(AppLocalizations))> appLanguageOptions = [
(null, (l) => l.appSettings_languageSystem),
('en', (l) => l.appSettings_languageEn),
('fr', (l) => l.appSettings_languageFr),
('es', (l) => l.appSettings_languageEs),
('de', (l) => l.appSettings_languageDe),
('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),
('nl', (l) => l.appSettings_languageNl),
('sk', (l) => l.appSettings_languageSk),
('cs', (l) => l.appSettings_languageCs),
('bg', (l) => l.appSettings_languageBg),
('ru', (l) => l.appSettings_languageRu),
('uk', (l) => l.appSettings_languageUk),
('hu', (l) => l.appSettings_languageHu),
('ja', (l) => l.appSettings_languageJa),
('ko', (l) => l.appSettings_languageKo),
];
/// Localized label for [languageCode]; unknown codes and null read as
/// "System".
String appLanguageLabel(BuildContext context, String? languageCode) {
final l10n = context.l10n;
for (final (code, label) in appLanguageOptions) {
if (code == languageCode) return label(l10n);
}
return l10n.appSettings_languageSystem;
}
/// Bottom sheet for choosing the app UI language override.
void showLanguagePickerSheet(
BuildContext context,
AppSettingsService settingsService,
) {
final l10n = context.l10n;
final current = settingsService.settings.languageOverride;
showMeshSheet(
context,
builder: (ctx) => Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomSheetHeader(title: l10n.appSettings_language),
SizedBox(
// Capped so the sheet still fits short screens and landscape.
height: math.min(400, MediaQuery.sizeOf(ctx).height * 0.6),
child: ListView(
children: [
for (final (code, label) in appLanguageOptions)
MeshSheetOption(
label: label(l10n),
selected: current == code,
onTap: () {
settingsService.setLanguageOverride(code);
Navigator.pop(ctx);
},
),
SizedBox(height: MediaQuery.paddingOf(ctx).bottom + 8),
],
),
),
],
),
);
}