update to zjs81/dev 9334d55
This commit is contained in:
commit
38eef0970e
175 files changed
+23224
-6470
No files matched your search
@@ -54,6 +54,11 @@ class ByteCountedTextField extends StatelessWidget {
|
||||
/// If provided, byte limits and counters will use the encoded text length.
|
||||
final String Function(String)? encoder;
|
||||
|
||||
/// Optional byte count above which [softLimitNote] is shown next to the
|
||||
/// counter (the text is still allowed up to [maxBytes]).
|
||||
final int? softLimitBytes;
|
||||
final String? softLimitNote;
|
||||
|
||||
const ByteCountedTextField({
|
||||
super.key,
|
||||
required this.maxBytes,
|
||||
@@ -69,6 +74,8 @@ class ByteCountedTextField extends StatelessWidget {
|
||||
this.errorThreshold = 0.9,
|
||||
this.hideCounterWhenEmpty = true,
|
||||
this.encoder,
|
||||
this.softLimitBytes,
|
||||
this.softLimitNote,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -82,6 +89,10 @@ class ByteCountedTextField extends StatelessWidget {
|
||||
final usedBytes = utf8.encode(effectiveText).length;
|
||||
final ratio = maxBytes > 0 ? usedBytes / maxBytes : 0.0;
|
||||
final showCounter = !(hideCounterWhenEmpty && value.text.isEmpty);
|
||||
final showSoftLimitNote =
|
||||
softLimitNote != null &&
|
||||
softLimitBytes != null &&
|
||||
usedBytes > softLimitBytes!;
|
||||
|
||||
final counterColor = ratio > errorThreshold
|
||||
? Theme.of(context).colorScheme.error
|
||||
@@ -122,12 +133,25 @@ class ByteCountedTextField extends StatelessWidget {
|
||||
opacity: showCounter ? 1 : 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 4, right: 4),
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
'$usedBytes / $maxBytes',
|
||||
style: TextStyle(fontSize: 11, color: counterColor),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: showSoftLimitNote
|
||||
? Text(
|
||||
softLimitNote!,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'$usedBytes / $maxBytes',
|
||||
style: TextStyle(fontSize: 11, color: counterColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
|
||||
bool isSameChatDay(DateTime a, DateTime b) {
|
||||
final la = a.toLocal();
|
||||
final lb = b.toLocal();
|
||||
return la.year == lb.year && la.month == lb.month && la.day == lb.day;
|
||||
}
|
||||
|
||||
final Map<(String, bool), DateFormat> _timeFormats = {};
|
||||
|
||||
String formatChatTime(BuildContext context, DateTime time) {
|
||||
final locale = Localizations.localeOf(context).toString();
|
||||
final use24h = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
final format = _timeFormats.putIfAbsent((
|
||||
locale,
|
||||
use24h,
|
||||
), () => use24h ? DateFormat.Hm(locale) : DateFormat.jm(locale));
|
||||
return format.format(time.toLocal());
|
||||
}
|
||||
|
||||
String formatChatDayLabel(BuildContext context, DateTime time) {
|
||||
final now = DateTime.now();
|
||||
if (isSameChatDay(time, now)) return context.l10n.chat_today;
|
||||
final yesterday = DateTime(now.year, now.month, now.day - 1);
|
||||
if (isSameChatDay(time, yesterday)) return context.l10n.chat_yesterday;
|
||||
final locale = Localizations.localeOf(context).toString();
|
||||
return DateFormat.yMMMd(locale).format(time.toLocal());
|
||||
}
|
||||
|
||||
class ChatDaySeparator extends StatelessWidget {
|
||||
final DateTime day;
|
||||
|
||||
const ChatDaySeparator({super.key, required this.day});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final line = Expanded(
|
||||
child: Container(height: 1, color: color.withValues(alpha: 0.2)),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
line,
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
formatChatDayLabel(context, day),
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
line,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -232,6 +232,7 @@ class EmojiPicker extends StatelessWidget {
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
tooltip: l10n.common_close,
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -136,6 +136,7 @@ class _GifPickerState extends State<GifPicker> {
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
tooltip: context.l10n.common_close,
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
@@ -151,6 +152,7 @@ class _GifPickerState extends State<GifPicker> {
|
||||
suffixIcon: _searchController.text.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
tooltip: context.l10n.common_clearSearch,
|
||||
onPressed: () {
|
||||
_searchController.clear();
|
||||
_loadTrendingGifs();
|
||||
|
||||
@@ -121,6 +121,10 @@ abstract class ImageSendCodec {
|
||||
/// Implementations are expected to centre-crop to
|
||||
/// [kImageCodecSquareSize] square first.
|
||||
Future<Uint8List> encode(Uint8List imageBytes, ImageCodecRatePoint rate);
|
||||
|
||||
/// Decodes [payload] to PNG exactly as a recipient would, or null when this
|
||||
/// device cannot decode.
|
||||
Future<Uint8List?> decodePreview(Uint8List payload);
|
||||
}
|
||||
|
||||
/// A deterministic stand-in used for widget previews and tests.
|
||||
@@ -157,4 +161,7 @@ class FakeImageSendCodec implements ImageSendCodec {
|
||||
List<int>.generate(size, (i) => (i * 31 + rate.index) & 0xFF),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uint8List?> decodePreview(Uint8List payload) async => null;
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/image_chunk_transport.dart';
|
||||
import '../utils/lora_airtime.dart';
|
||||
import 'image_send_codec_binding.dart';
|
||||
|
||||
@@ -151,15 +153,76 @@ class _ImageSendPreviewSheetState extends State<ImageSendPreviewSheet> {
|
||||
/// does not have to touch an InheritedWidget after an await.
|
||||
ImageSendRadio? _radio;
|
||||
|
||||
/// Source `width / height`. Recipients un-stretch the 512x512 square back to
|
||||
/// this shape, so both preview views use it.
|
||||
double _aspect = 1;
|
||||
// The shape recipients restore: the nearest supported ratio, or square.
|
||||
double _recipientAspect = 1;
|
||||
|
||||
bool _showReconstruction = false;
|
||||
Uint8List? _reconstruction;
|
||||
bool _reconstructing = false;
|
||||
bool _reconstructionUnavailable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_parity = widget.initialParity;
|
||||
_probeAspect();
|
||||
if (widget.codec.availability == ImageCodecAvailability.ready) {
|
||||
_encode();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _probeAspect() async {
|
||||
try {
|
||||
final buffer = await ui.ImmutableBuffer.fromUint8List(widget.imageBytes);
|
||||
final descriptor = await ui.ImageDescriptor.encoded(buffer);
|
||||
final ratio = descriptor.width / descriptor.height;
|
||||
final code =
|
||||
kImageAspectCodes[imageAspectCodeFor(
|
||||
descriptor.width,
|
||||
descriptor.height,
|
||||
)];
|
||||
final recipientRatio = code[0] / code[1];
|
||||
descriptor.dispose();
|
||||
buffer.dispose();
|
||||
if (mounted && ratio.isFinite && ratio > 0) {
|
||||
setState(() {
|
||||
_aspect = ratio;
|
||||
_recipientAspect = recipientRatio;
|
||||
});
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> _selectView(bool reconstruction) async {
|
||||
setState(() => _showReconstruction = reconstruction);
|
||||
final payload = _encoded;
|
||||
if (!reconstruction ||
|
||||
payload == null ||
|
||||
_reconstruction != null ||
|
||||
_reconstructing) {
|
||||
return;
|
||||
}
|
||||
setState(() => _reconstructing = true);
|
||||
Uint8List? png;
|
||||
try {
|
||||
png = await widget.codec.decodePreview(payload);
|
||||
} catch (_) {
|
||||
png = null;
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_reconstructing = false;
|
||||
_reconstruction = png;
|
||||
if (png == null) {
|
||||
_reconstructionUnavailable = true;
|
||||
_showReconstruction = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<Uint8List?> _encode() async {
|
||||
final cached = _encoded;
|
||||
if (cached != null) return cached;
|
||||
@@ -297,7 +360,7 @@ class _ImageSendPreviewSheetState extends State<ImageSendPreviewSheet> {
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
children: [
|
||||
_preview(theme, colors),
|
||||
_preview(theme, colors, selected, ready),
|
||||
const SizedBox(height: 16),
|
||||
if (!ready) _unavailableBanner(theme, colors),
|
||||
if (ready) ...[
|
||||
@@ -344,44 +407,85 @@ class _ImageSendPreviewSheetState extends State<ImageSendPreviewSheet> {
|
||||
),
|
||||
);
|
||||
|
||||
/// The square render. [BoxFit.fill] on a 1:1 box is exactly the 512x512
|
||||
/// centre crop the codec will take, so what is shown is what is sent.
|
||||
///
|
||||
/// The preview is deliberately capped in height: the packet count and airtime
|
||||
/// below it are the reason this screen exists and must not be pushed off the
|
||||
/// first screenful by a full-width square.
|
||||
Widget _preview(ThemeData theme, ColorScheme colors) {
|
||||
Widget _preview(
|
||||
ThemeData theme,
|
||||
ColorScheme colors,
|
||||
_RateEstimate estimate,
|
||||
bool ready,
|
||||
) {
|
||||
final l10n = context.l10n;
|
||||
final maxSide = MediaQuery.sizeOf(context).height * 0.28;
|
||||
final reconstruction = _showReconstruction ? _reconstruction : null;
|
||||
return Column(
|
||||
children: [
|
||||
if (ready) ...[
|
||||
SegmentedButton<bool>(
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
label: Text(l10n.imageSend_viewOriginal),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
label: Text(l10n.imageSend_viewReconstruction),
|
||||
enabled: _encoded != null && !_reconstructionUnavailable,
|
||||
),
|
||||
],
|
||||
selected: {_showReconstruction},
|
||||
onSelectionChanged: (s) => _selectView(s.first),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: maxSide, maxWidth: maxSide),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
aspectRatio: reconstruction != null ? _recipientAspect : _aspect,
|
||||
child: Container(
|
||||
color: colors.surfaceContainerHighest,
|
||||
child: Image.memory(
|
||||
widget.imageBytes,
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
gaplessPlayback: true,
|
||||
errorBuilder: (context, error, stack) => Center(
|
||||
child: Icon(
|
||||
Icons.broken_image_outlined,
|
||||
size: 48,
|
||||
color: colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _showReconstruction && _reconstructing
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Image.memory(
|
||||
reconstruction ?? widget.imageBytes,
|
||||
// The reconstruction is the stretched square; fill
|
||||
// undoes the stretch into the recipient's shape.
|
||||
fit: reconstruction != null
|
||||
? BoxFit.fill
|
||||
: BoxFit.contain,
|
||||
alignment: Alignment.center,
|
||||
gaplessPlayback: true,
|
||||
errorBuilder: (context, error, stack) => Center(
|
||||
child: Icon(
|
||||
Icons.broken_image_outlined,
|
||||
size: 48,
|
||||
color: colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_reconstructionUnavailable) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.imageSend_reconstructionUnavailable,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
context.l10n.imageSend_cropNote,
|
||||
l10n.imageSend_lossyNote(
|
||||
estimate.payloadBytes ??
|
||||
ImageCodecRateStats.forRate(kImageSendRatePoint).meanBytes,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: colors.onSurfaceVariant,
|
||||
|
||||
+34
-25
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
|
||||
/// MeshCore shared design kit.
|
||||
@@ -191,35 +192,39 @@ class StatTile extends StatelessWidget {
|
||||
label.toUpperCase(),
|
||||
style: MeshTheme.accentLabel(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontSize: 9,
|
||||
fontSize: 11,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: value,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
children: [
|
||||
if (unit != null)
|
||||
TextSpan(
|
||||
text: ' $unit',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 11,
|
||||
color: scheme.onSurfaceVariant,
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
text: value,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
children: [
|
||||
if (unit != null)
|
||||
TextSpan(
|
||||
text: ' $unit',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 11,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -352,11 +357,14 @@ class RouteChip extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final label = isDirect
|
||||
? (hops == null || hops == 0
|
||||
? 'DIRECT'
|
||||
: '$hops HOP${hops == 1 ? '' : 'S'}')
|
||||
: 'FLOOD';
|
||||
final l10n = context.l10n;
|
||||
final label =
|
||||
(isDirect
|
||||
? (hops == null || hops == 0
|
||||
? l10n.chat_direct
|
||||
: l10n.chat_hopsCount(hops!))
|
||||
: l10n.routing_modeFlood)
|
||||
.toUpperCase();
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
@@ -518,6 +526,7 @@ class BottomSheetHeader extends StatelessWidget {
|
||||
?trailing,
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -8,7 +8,19 @@ class MessageStatusIcon extends StatefulWidget {
|
||||
final bool isAcked;
|
||||
final bool isFailed;
|
||||
final bool isPending;
|
||||
final bool isRepeated;
|
||||
|
||||
/// Channel messages have no delivery ACK. Instead of a delivered tick they
|
||||
/// show how many times the mesh was heard repeating the message.
|
||||
final bool isChannel;
|
||||
final int repeatCount;
|
||||
|
||||
/// While the app is resending a channel message to reach more repeaters:
|
||||
/// how many resends so far and the limit.
|
||||
final ({int resends, int maxResends})? resendProgress;
|
||||
|
||||
/// Set when resending gave up before the message was heard through the
|
||||
/// required number of repeaters.
|
||||
final ({int hops, int required})? hopShortfall;
|
||||
final double size;
|
||||
|
||||
/// Base tint for the sent/sending state. On a colored (outgoing) bubble a
|
||||
@@ -21,8 +33,11 @@ class MessageStatusIcon extends StatefulWidget {
|
||||
required this.isAcked,
|
||||
this.isFailed = false,
|
||||
this.isPending = false,
|
||||
this.isRepeated = false,
|
||||
this.size = 14,
|
||||
this.isChannel = false,
|
||||
this.repeatCount = 0,
|
||||
this.resendProgress,
|
||||
this.hopShortfall,
|
||||
this.size = 16,
|
||||
this.onColor,
|
||||
});
|
||||
|
||||
@@ -68,46 +83,91 @@ class _MessageStatusIconState extends State<MessageStatusIcon>
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final double size = widget.size;
|
||||
final Color baseColor = widget.onColor ?? colorScheme.onSurfaceVariant;
|
||||
final Color confirmedColor = MeshPalette.signal.withValues(alpha: 0.9);
|
||||
|
||||
final String label;
|
||||
final Widget icon;
|
||||
if (widget.isFailed) {
|
||||
return Semantics(
|
||||
label: l10n.messageStatus_failed,
|
||||
child: Icon(Icons.cancel, size: size, color: colorScheme.error),
|
||||
label = widget.isChannel
|
||||
? l10n.messageStatus_failedChannel
|
||||
: l10n.messageStatus_failed;
|
||||
icon = Icon(Icons.cancel, size: size, color: colorScheme.error);
|
||||
} else if (widget.isPending) {
|
||||
label = l10n.messageStatus_pending;
|
||||
icon = _SendingDots(
|
||||
controller: _controller,
|
||||
color: baseColor,
|
||||
size: size,
|
||||
);
|
||||
} else if (widget.isChannel && widget.hopShortfall != null) {
|
||||
final shortfall = widget.hopShortfall!;
|
||||
label = l10n.messageStatus_hopsNotReached(
|
||||
shortfall.hops,
|
||||
shortfall.required,
|
||||
);
|
||||
icon = Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: size,
|
||||
color: MeshPalette.warn,
|
||||
);
|
||||
} else if (widget.isChannel && (widget.resendProgress?.resends ?? 0) > 0) {
|
||||
final progress = widget.resendProgress!;
|
||||
label = l10n.messageStatus_resending(
|
||||
progress.resends,
|
||||
progress.maxResends,
|
||||
);
|
||||
icon = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.autorenew, size: size, color: MeshPalette.warn),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
'${progress.resends}/${progress.maxResends}',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: size * 0.8,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MeshPalette.warn,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (widget.isChannel && widget.repeatCount > 0) {
|
||||
label = l10n.messageStatus_heardRepeatedCount(widget.repeatCount);
|
||||
icon = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.repeat, size: size, color: confirmedColor),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
'${widget.repeatCount}',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: size * 0.8,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: confirmedColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (widget.isChannel) {
|
||||
label = l10n.messageStatus_sentChannel;
|
||||
icon = Icon(Icons.done, size: size, color: baseColor);
|
||||
} else if (widget.isAcked) {
|
||||
label = l10n.messageStatus_delivered;
|
||||
icon = SvgPicture.asset(
|
||||
'assets/icons/done_all.svg',
|
||||
width: size,
|
||||
height: size,
|
||||
colorFilter: ColorFilter.mode(confirmedColor, BlendMode.srcIn),
|
||||
);
|
||||
} else {
|
||||
label = l10n.messageStatus_sentDirect;
|
||||
icon = Icon(Icons.done, size: size, color: baseColor);
|
||||
}
|
||||
|
||||
if (widget.isPending) {
|
||||
return Semantics(
|
||||
label: l10n.messageStatus_pending,
|
||||
child: _SendingDots(
|
||||
controller: _controller,
|
||||
color: baseColor,
|
||||
size: size,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final bool delivered = widget.isAcked || widget.isRepeated;
|
||||
final String label = widget.isRepeated
|
||||
? l10n.messageStatus_repeated
|
||||
: widget.isAcked
|
||||
? l10n.messageStatus_delivered
|
||||
: l10n.messageStatus_sent;
|
||||
// Use palette colors: tertiary (warn/amber) for acked/repeated, base for sent.
|
||||
final Color color = delivered
|
||||
? MeshPalette.signal.withValues(alpha: 0.9)
|
||||
: baseColor;
|
||||
|
||||
return Semantics(
|
||||
label: label,
|
||||
child: delivered
|
||||
? SvgPicture.asset(
|
||||
'assets/icons/done_all.svg',
|
||||
width: size,
|
||||
height: size,
|
||||
colorFilter: ColorFilter.mode(color, BlendMode.srcIn),
|
||||
)
|
||||
: Icon(Icons.done, size: size, color: color),
|
||||
return Tooltip(
|
||||
message: label,
|
||||
triggerMode: TooltipTriggerMode.tap,
|
||||
child: icon,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import '../connector/meshcore_protocol.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../helpers/utf8_length_limiter.dart';
|
||||
import 'routing_sheet.dart';
|
||||
|
||||
class RepeaterLoginDialog extends StatefulWidget {
|
||||
@@ -280,6 +281,9 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
final repeater = _resolveRepeater(connector);
|
||||
final isFloodMode = repeater.pathOverride == -1;
|
||||
return AlertDialog(
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
titlePadding: const EdgeInsets.fromLTRB(16, 20, 16, 0),
|
||||
contentPadding: const EdgeInsets.fromLTRB(16, 16, 16, 0),
|
||||
title: Row(
|
||||
children: [
|
||||
AvatarCircle(
|
||||
@@ -351,6 +355,10 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
TextField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
// Firmware stores at most 15 bytes (CommonCLI.h password[16]).
|
||||
inputFormatters: const [
|
||||
Utf8LengthLimitingTextInputFormatter(15),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.login_password,
|
||||
hintText: l10n.login_enterPassword,
|
||||
@@ -361,6 +369,9 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
tooltip: _obscurePassword
|
||||
? l10n.login_showPassword
|
||||
: l10n.login_hidePassword,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
@@ -397,101 +408,116 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
const Divider(),
|
||||
Row(
|
||||
ExpansionTile(
|
||||
title: Text(l10n.login_advanced),
|
||||
tilePadding: EdgeInsets.zero,
|
||||
childrenPadding: EdgeInsets.zero,
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.start,
|
||||
shape: const Border(),
|
||||
collapsedShape: const Border(),
|
||||
children: [
|
||||
Text(
|
||||
l10n.login_routing,
|
||||
style: MeshTheme.accentLabel(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(isFloodMode ? Icons.waves : Icons.route),
|
||||
tooltip: l10n.login_routingMode,
|
||||
onSelected: (mode) async {
|
||||
if (mode == 'flood') {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: -1,
|
||||
);
|
||||
} else {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: null,
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'auto',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_mode,
|
||||
size: 20,
|
||||
color: !isFloodMode ? scheme.primary : null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_autoUseSavedPath,
|
||||
style: TextStyle(
|
||||
fontWeight: !isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.login_routing,
|
||||
style: MeshTheme.accentLabel(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'flood',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.waves,
|
||||
size: 20,
|
||||
color: isFloodMode ? scheme.primary : null,
|
||||
const Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(isFloodMode ? Icons.waves : Icons.route),
|
||||
tooltip: l10n.login_routingMode,
|
||||
onSelected: (mode) async {
|
||||
if (mode == 'flood') {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: -1,
|
||||
);
|
||||
} else {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: null,
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'auto',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_mode,
|
||||
size: 20,
|
||||
color: !isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_autoUseSavedPath,
|
||||
style: TextStyle(
|
||||
fontWeight: !isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_forceFloodMode,
|
||||
style: TextStyle(
|
||||
fontWeight: isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'flood',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.waves,
|
||||
size: 20,
|
||||
color: isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_forceFloodMode,
|
||||
style: TextStyle(
|
||||
fontWeight: isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
repeater.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: connector.pathHashByteWidth,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: () => ContactRoutingSheet.show(
|
||||
context,
|
||||
contact: repeater,
|
||||
),
|
||||
icon: const Icon(Icons.timeline, size: 18),
|
||||
label: Text(l10n.login_managePaths),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
repeater.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: connector.pathHashByteWidth,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: () =>
|
||||
ContactRoutingSheet.show(context, contact: repeater),
|
||||
icon: const Icon(Icons.timeline, size: 18),
|
||||
label: Text(l10n.login_managePaths),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -14,6 +14,7 @@ import '../theme/mesh_theme.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../helpers/utf8_length_limiter.dart';
|
||||
import 'routing_sheet.dart';
|
||||
|
||||
class RoomLoginDialog extends StatefulWidget {
|
||||
@@ -233,6 +234,9 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
final repeater = _resolveRepeater(connector);
|
||||
final isFloodMode = repeater.pathOverride == -1;
|
||||
return AlertDialog(
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
titlePadding: const EdgeInsets.fromLTRB(16, 20, 16, 0),
|
||||
contentPadding: const EdgeInsets.fromLTRB(16, 16, 16, 0),
|
||||
title: Row(
|
||||
children: [
|
||||
AvatarCircle(
|
||||
@@ -288,6 +292,10 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
TextField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
// Firmware stores at most 15 bytes (CommonCLI.h password[16]).
|
||||
inputFormatters: const [
|
||||
Utf8LengthLimitingTextInputFormatter(15),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.login_password,
|
||||
hintText: l10n.login_enterPassword,
|
||||
@@ -298,6 +306,9 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
tooltip: _obscurePassword
|
||||
? l10n.login_showPassword
|
||||
: l10n.login_hidePassword,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
@@ -329,101 +340,116 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
const Divider(),
|
||||
Row(
|
||||
ExpansionTile(
|
||||
title: Text(l10n.login_advanced),
|
||||
tilePadding: EdgeInsets.zero,
|
||||
childrenPadding: EdgeInsets.zero,
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.start,
|
||||
shape: const Border(),
|
||||
collapsedShape: const Border(),
|
||||
children: [
|
||||
Text(
|
||||
l10n.login_routing,
|
||||
style: MeshTheme.accentLabel(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(isFloodMode ? Icons.waves : Icons.route),
|
||||
tooltip: l10n.login_routingMode,
|
||||
onSelected: (mode) async {
|
||||
if (mode == 'flood') {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: -1,
|
||||
);
|
||||
} else {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: null,
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'auto',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_mode,
|
||||
size: 20,
|
||||
color: !isFloodMode ? scheme.primary : null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_autoUseSavedPath,
|
||||
style: TextStyle(
|
||||
fontWeight: !isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.login_routing,
|
||||
style: MeshTheme.accentLabel(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'flood',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.waves,
|
||||
size: 20,
|
||||
color: isFloodMode ? scheme.primary : null,
|
||||
const Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(isFloodMode ? Icons.waves : Icons.route),
|
||||
tooltip: l10n.login_routingMode,
|
||||
onSelected: (mode) async {
|
||||
if (mode == 'flood') {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: -1,
|
||||
);
|
||||
} else {
|
||||
await connector.setPathOverride(
|
||||
repeater,
|
||||
pathLen: null,
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'auto',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_mode,
|
||||
size: 20,
|
||||
color: !isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_autoUseSavedPath,
|
||||
style: TextStyle(
|
||||
fontWeight: !isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_forceFloodMode,
|
||||
style: TextStyle(
|
||||
fontWeight: isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'flood',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.waves,
|
||||
size: 20,
|
||||
color: isFloodMode
|
||||
? scheme.primary
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.login_forceFloodMode,
|
||||
style: TextStyle(
|
||||
fontWeight: isFloodMode
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
repeater.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: connector.pathHashByteWidth,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: () => ContactRoutingSheet.show(
|
||||
context,
|
||||
contact: repeater,
|
||||
),
|
||||
icon: const Icon(Icons.timeline, size: 18),
|
||||
label: Text(l10n.login_managePaths),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
repeater.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: connector.pathHashByteWidth,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: () =>
|
||||
ContactRoutingSheet.show(context, contact: repeater),
|
||||
icon: const Icon(Icons.timeline, size: 18),
|
||||
label: Text(l10n.login_managePaths),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -99,7 +99,10 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
final override = contact.pathOverride;
|
||||
final initial = override != null && override > 0
|
||||
? (contact.pathOverrideBytes ?? Uint8List(0))
|
||||
: (contact.pathLength > 0 ? contact.path : Uint8List(0));
|
||||
: (contact.pathLength > 0 &&
|
||||
contact.pathHashWidth == connector.pathHashByteWidth
|
||||
? contact.path
|
||||
: Uint8List(0));
|
||||
final available = connector.allContacts
|
||||
.where((c) => c.publicKeyHex != contact.publicKeyHex)
|
||||
.toList();
|
||||
@@ -169,7 +172,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
for (var i = 0; i < ranked.length && i < 3; i++) {
|
||||
if (ranked[i].matchesPathStart(
|
||||
record.pathBytes,
|
||||
connector.pathHashByteWidth,
|
||||
_recordPathHashWidth(record),
|
||||
)) {
|
||||
return switch (i) {
|
||||
0 => _PathQuality.strong,
|
||||
@@ -252,7 +255,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
return PathHelper.resolvePathNames(
|
||||
contact.path,
|
||||
connector.allContacts,
|
||||
connector.pathHashByteWidth,
|
||||
contact.pathHashWidth,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -285,21 +288,26 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
);
|
||||
}
|
||||
|
||||
int _recordPathHashWidth(PathRecord record) =>
|
||||
Contact.inferPathHashWidth(record.hopCount, record.pathBytes.length);
|
||||
|
||||
void _showPathDetail(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Contact contact,
|
||||
List<int> pathBytes,
|
||||
PathRecord record,
|
||||
) {
|
||||
final l10n = context.l10n;
|
||||
final pathBytes = record.pathBytes;
|
||||
final width = _recordPathHashWidth(record);
|
||||
final formattedPath = PathHelper.splitPathBytes(
|
||||
pathBytes,
|
||||
connector.pathHashByteWidth,
|
||||
width,
|
||||
).map(PathHelper.formatHopHex).join(',');
|
||||
final resolvedNames = PathHelper.resolvePathNames(
|
||||
pathBytes,
|
||||
connector.allContacts,
|
||||
connector.pathHashByteWidth,
|
||||
width,
|
||||
);
|
||||
|
||||
showDialog(
|
||||
@@ -545,13 +553,13 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
? PathHelper.resolvePathNames(
|
||||
record.pathBytes,
|
||||
connector.allContacts,
|
||||
connector.pathHashByteWidth,
|
||||
_recordPathHashWidth(record),
|
||||
)
|
||||
: l10n.chat_hopsCount(record.hopCount);
|
||||
final displayHopCount = hasBytes
|
||||
? PathHelper.splitPathBytes(
|
||||
record.pathBytes,
|
||||
connector.pathHashByteWidth,
|
||||
_recordPathHashWidth(record),
|
||||
).length
|
||||
: record.hopCount;
|
||||
|
||||
@@ -569,8 +577,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onSecondaryTapUp: PlatformInfo.isDesktop && hasBytes
|
||||
? (_) =>
|
||||
_showPathDetail(context, connector, contact, record.pathBytes)
|
||||
? (_) => _showPathDetail(context, connector, contact, record)
|
||||
: null,
|
||||
child: Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||
@@ -619,12 +626,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
? () => _applyHistoryPath(connector, contact, record)
|
||||
: null,
|
||||
onLongPress: hasBytes
|
||||
? () => _showPathDetail(
|
||||
context,
|
||||
connector,
|
||||
contact,
|
||||
record.pathBytes,
|
||||
)
|
||||
? () => _showPathDetail(context, connector, contact, record)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -226,79 +226,110 @@ class _SNRIndicatorState extends State<SNRIndicator> {
|
||||
title: Text(l10n.snrIndicator_nearByRepeaters),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Scrollbar(
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
itemCount: directBestRepeaters.length,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final repeater = directBestRepeaters[index];
|
||||
final allContacts = widget.connector.allContacts;
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.snrIndicator_nearByRepeatersDescription,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Flexible(
|
||||
child: Scrollbar(
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
itemCount: directBestRepeaters.length,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final repeater = directBestRepeaters[index];
|
||||
final allContacts = widget.connector.allContacts;
|
||||
|
||||
final selfLat = widget.connector.selfLatitude;
|
||||
final selfLon = widget.connector.selfLongitude;
|
||||
final selfLat = widget.connector.selfLatitude;
|
||||
final selfLon = widget.connector.selfLongitude;
|
||||
|
||||
LatLng? selfPoint;
|
||||
if (selfLat != null &&
|
||||
selfLon != null &&
|
||||
_isValidSelfLocation(selfLat, selfLon)) {
|
||||
selfPoint = LatLng(selfLat, selfLon);
|
||||
}
|
||||
LatLng? selfPoint;
|
||||
if (selfLat != null &&
|
||||
selfLon != null &&
|
||||
_isValidSelfLocation(selfLat, selfLon)) {
|
||||
selfPoint = LatLng(selfLat, selfLon);
|
||||
}
|
||||
|
||||
final contact = _getRepeaterPrefixMatchNearLocation(
|
||||
allContacts,
|
||||
repeater.pubkeyPrefix,
|
||||
contactKeyHex: repeater.contactKeyHex,
|
||||
searchPoint: selfPoint,
|
||||
preferFavorites: true,
|
||||
);
|
||||
final contact = _getRepeaterPrefixMatchNearLocation(
|
||||
allContacts,
|
||||
repeater.pubkeyPrefix,
|
||||
contactKeyHex: repeater.contactKeyHex,
|
||||
searchPoint: selfPoint,
|
||||
preferFavorites: true,
|
||||
);
|
||||
|
||||
final name = contact?.name;
|
||||
final prefixLabel = PathHelper.formatHopHex(
|
||||
repeater.pubkeyPrefix,
|
||||
);
|
||||
final snrColor = MeshTheme.snrColor(
|
||||
repeater.snr,
|
||||
blocked: false,
|
||||
);
|
||||
final name = contact?.name;
|
||||
final prefixLabel = PathHelper.formatHopHex(
|
||||
repeater.pubkeyPrefix,
|
||||
);
|
||||
final snrColor = MeshTheme.snrColor(
|
||||
repeater.snr,
|
||||
blocked: false,
|
||||
);
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarCircle(
|
||||
name: name ?? prefixLabel,
|
||||
size: 36,
|
||||
color: snrColor,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
name ?? prefixLabel,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
AvatarCircle(
|
||||
name: name ?? prefixLabel,
|
||||
size: 36,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
Text(
|
||||
'${repeater.snr.toStringAsFixed(1)} dB • ${_formatLastUpdated(repeater.lastUpdated)}',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 11,
|
||||
color: snrColor,
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
name ?? prefixLabel,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.circle,
|
||||
size: 8,
|
||||
color: snrColor,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'${repeater.snr.toStringAsFixed(1)} dB • ${_formatLastUpdated(repeater.lastUpdated)}',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 11,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
|
||||
Reference in new issue
Block a user