Files
pipelines/app/lib/features/search/domain/search_format.dart
T
alan 51140cd3b7 feat(app): add native omni-search screen over the search gateway
Pure request/parse/row logic in lib/features/search/domain, a
gateway-backed repository, and Material plus Cupertino bodies.
The header and rows share one scroll view, and the server's
truncation, scan and cap facts stay visible even when a bounded
scan returns no matches.

Tests cover the exact search envelope, token parsing, stale replies,
retry, truncation bounds and platform layouts. A Web-only fixture
and CDP probe support rendered verification; the screen is not yet
registered in the shell.
2026-10-21 16:41:30 +01:00

44 lines
1.1 KiB
Dart

/// Human bytes with the shared binary units (`2.0 KiB`), matching the browser.
String humanBytes(int size) {
const unit = 1024;
if (size < unit) return '$size B';
var divisor = unit;
var exponent = 0;
var scaled = size ~/ unit;
while (scaled >= unit && exponent < 5) {
divisor *= unit;
exponent++;
scaled ~/= unit;
}
return '${(size / divisor).toStringAsFixed(1)} ${'KMGTPE'[exponent]}iB';
}
const _months = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
];
/// An RFC3339 timestamp as the app's one human local rendering (`20 Oct 12:00`),
/// or null when blank/unparseable so the caller omits the value rather than
/// printing a blank.
String? formatSearchTimestamp(String value) {
final text = value.trim();
if (text.isEmpty) return null;
final instant = DateTime.tryParse(text);
if (instant == null) return null;
final local = instant.toLocal();
final hour = local.hour.toString().padLeft(2, '0');
final minute = local.minute.toString().padLeft(2, '0');
return '${local.day} ${_months[local.month - 1]} $hour:$minute';
}