Merge origin/dev into feat/group-editor-members-first
This commit is contained in:
commit
0cc5fd4e1f
88 files changed
+5799
-742
No files matched your search
@@ -44,21 +44,34 @@ class ChatDaySeparator extends StatelessWidget {
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
line,
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
formatChatDayLabel(context, day),
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
child: LayoutBuilder(
|
||||
// Large text on a narrow phone wraps the label instead of overflowing;
|
||||
// each rule keeps at least 16dp.
|
||||
builder: (context, constraints) => Row(
|
||||
children: [
|
||||
line,
|
||||
const SizedBox(width: 10),
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: (constraints.maxWidth - 2 * (10 + 16)).clamp(
|
||||
0.0,
|
||||
double.infinity,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
formatChatDayLabel(context, day),
|
||||
textAlign: TextAlign.center,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
line,
|
||||
],
|
||||
const SizedBox(width: 10),
|
||||
line,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../l10n/app_localizations.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../theme/theme_icons.dart';
|
||||
import '../utils/emoji_utils.dart';
|
||||
|
||||
/// Shared node-type visuals and last-seen formatting for contact lists
|
||||
/// (contacts, discovery, nearby-node scan).
|
||||
@@ -41,6 +42,40 @@ ThemeIconSlot? contactTypeIconSlot(int type) {
|
||||
}
|
||||
}
|
||||
|
||||
final RegExp _letterOrDigit = RegExp(r'^[\p{L}\p{N}]', unicode: true);
|
||||
|
||||
/// Avatar initials for a display name, or null when the name has nothing
|
||||
/// usable so the caller can show an icon or key prefix instead.
|
||||
///
|
||||
/// Only letters and digits count: punctuation such as `-`, `(` or `[` splits
|
||||
/// words but never becomes an initial, so "(Base) Node" gives "BN" and
|
||||
/// "- Relay" gives "RE". Characters are whole grapheme clusters, so accented
|
||||
/// letters and emoji are never cut in half. A name with no letters or digits
|
||||
/// but an emoji shows that emoji.
|
||||
String? avatarInitials(String name) {
|
||||
final words = <String>[];
|
||||
final current = StringBuffer();
|
||||
String? emoji;
|
||||
for (final cluster in name.characters) {
|
||||
if (_letterOrDigit.hasMatch(cluster)) {
|
||||
current.write(cluster);
|
||||
continue;
|
||||
}
|
||||
if (current.isNotEmpty) {
|
||||
words.add(current.toString());
|
||||
current.clear();
|
||||
}
|
||||
emoji ??= firstEmoji(cluster);
|
||||
}
|
||||
if (current.isNotEmpty) words.add(current.toString());
|
||||
|
||||
if (words.isEmpty) return emoji;
|
||||
if (words.length == 1) {
|
||||
return words.first.characters.take(2).toString().toUpperCase();
|
||||
}
|
||||
return (words[0].characters.first + words[1].characters.first).toUpperCase();
|
||||
}
|
||||
|
||||
/// The most recent activity for [contact]: for chat nodes this includes the
|
||||
/// last message, for other node types only the last advert or telemetry fix.
|
||||
/// [addedAt] (the phone time the contact was added from a card) stands in
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../theme/theme_icons.dart';
|
||||
import 'contact_visuals.dart';
|
||||
|
||||
/// MeshCore shared design kit.
|
||||
///
|
||||
@@ -283,7 +284,8 @@ class StatTile extends StatelessWidget {
|
||||
|
||||
/// Initials avatar with a deterministic per-name hue, or a fixed [color]
|
||||
/// for node-type coloring. Optional [icon] or themeable [iconSlot] replaces
|
||||
/// initials.
|
||||
/// initials. Initials come from [avatarInitials]; a name with no letters,
|
||||
/// digits or emoji shows a generic person icon instead.
|
||||
class AvatarCircle extends StatelessWidget {
|
||||
final String name;
|
||||
final double size;
|
||||
@@ -320,7 +322,7 @@ class AvatarCircle extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final accent = color ?? _colorFor(name);
|
||||
final initials = _initials(name);
|
||||
final initials = avatarInitials(name);
|
||||
final background = _tintedCardBackground(context, accent, 0.14);
|
||||
// A theme picture (e.g. a holiday marker) fills the whole circle, the
|
||||
// same as on the map, rather than sitting small inside the tint.
|
||||
@@ -360,9 +362,9 @@ class AvatarCircle extends StatelessWidget {
|
||||
size: size * 0.55,
|
||||
color: readableAccent(accent, background, minContrast: 3),
|
||||
)
|
||||
: icon != null
|
||||
: icon != null || initials == null
|
||||
? Icon(
|
||||
icon,
|
||||
icon ?? Icons.person_outline,
|
||||
size: size * 0.5,
|
||||
color: readableAccent(accent, background, minContrast: 3),
|
||||
)
|
||||
@@ -376,21 +378,6 @@ class AvatarCircle extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String _initials(String name) {
|
||||
final words = name
|
||||
.trim()
|
||||
.split(RegExp(r'\s+'))
|
||||
.where((w) => w.isNotEmpty)
|
||||
.toList();
|
||||
if (words.isEmpty) return '?';
|
||||
if (words.length == 1) {
|
||||
return words.first.characters.take(2).toString().toUpperCase();
|
||||
}
|
||||
return (words.first.characters.take(1).toString() +
|
||||
words[1].characters.take(1).toString())
|
||||
.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
/// Four-bar signal strength indicator driven by an SNR value (dB), colored
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../l10n/contact_localization.dart';
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import '../services/repeater_command_service.dart';
|
||||
import '../connector/meshcore_connector.dart';
|
||||
@@ -40,7 +41,9 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
String? _loginError;
|
||||
late MeshCoreConnector _connector;
|
||||
int _currentAttempt = 0;
|
||||
static const int _maxAttempts = 5;
|
||||
|
||||
int get _maxAttempts =>
|
||||
context.read<AppSettingsService>().settings.loginAttempts;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -195,10 +198,13 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
await _storage.removeRepeaterPassword(widget.repeater.publicKeyHex);
|
||||
}
|
||||
|
||||
final autoClockSync = await _storage
|
||||
.getRepeaterAutoClockSyncAfterLoginEnabled(
|
||||
widget.repeater.publicKeyHex,
|
||||
);
|
||||
final globalClockSync = mounted
|
||||
? context.read<AppSettingsService>().settings.clockSyncAfterLogin
|
||||
: false;
|
||||
final autoClockSync = await _storage.repeaterClockSyncAfterLogin(
|
||||
widget.repeater.publicKeyHex,
|
||||
globalDefault: globalClockSync,
|
||||
);
|
||||
if (autoClockSync) {
|
||||
try {
|
||||
final timestampSeconds =
|
||||
@@ -390,7 +396,12 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
}
|
||||
},
|
||||
onSubmitted: (_) => _handleLogin(),
|
||||
autofocus: _passwordController.text.isEmpty,
|
||||
autofocus:
|
||||
context
|
||||
.watch<AppSettingsService>()
|
||||
.settings
|
||||
.loginPasswordAutofocus &&
|
||||
_passwordController.text.isEmpty,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
CheckboxListTile(
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../l10n/contact_localization.dart';
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../connector/meshcore_protocol.dart';
|
||||
@@ -36,7 +37,9 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
bool _obscurePassword = true;
|
||||
late MeshCoreConnector _connector;
|
||||
int _currentAttempt = 0;
|
||||
static const int _maxAttempts = 5;
|
||||
|
||||
int get _maxAttempts =>
|
||||
context.read<AppSettingsService>().settings.loginAttempts;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -321,6 +324,10 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
),
|
||||
onSubmitted: (_) => _handleLogin(),
|
||||
autofocus:
|
||||
context
|
||||
.watch<AppSettingsService>()
|
||||
.settings
|
||||
.loginPasswordAutofocus &&
|
||||
!PlatformInfo.isMobile &&
|
||||
_passwordController.text.isEmpty,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user