33 lines
1.4 KiB
Dart
33 lines
1.4 KiB
Dart
import '../domain/artifact_groups.dart';
|
|
import '../domain/artifact_kind.dart';
|
|
import '../domain/artifact_record.dart';
|
|
import '../domain/gallery_navigation.dart';
|
|
|
|
/// A selection callback carrying the recorded group and the exact record the
|
|
/// operator chose, so the visit is never lost when two groups share a name.
|
|
typedef ArtifactSelected =
|
|
void Function(ArtifactGroup group, ArtifactRecord artifact);
|
|
|
|
/// The identity of [artifact] inside [group], shared by rows and the viewer.
|
|
String artifactVisitIdentity(ArtifactGroup group, ArtifactRecord artifact) =>
|
|
artifactVisitIdentityOf(group, artifact);
|
|
|
|
/// The recorded group heading, matching the web client's group vocabulary.
|
|
String artifactGroupLabel(ArtifactGroup group) =>
|
|
'${group.stageKey} · visit ${group.visit}';
|
|
|
|
/// The displayed artifact name: a missing server name stays explicit.
|
|
String artifactDisplayName(ArtifactRecord artifact) =>
|
|
artifact.name.isEmpty ? '(unnamed artifact)' : artifact.name;
|
|
|
|
/// The recorded MIME and byte size, never inferred from the name.
|
|
///
|
|
/// The value and its unit are joined by a non-breaking space so a narrow row
|
|
/// never wraps `120.6` away from `KiB`.
|
|
String artifactFactsLabel(ArtifactRecord artifact) {
|
|
final type = artifact.contentType.split(';').first.trim();
|
|
final mime = type.isEmpty ? 'type not recorded' : type;
|
|
final size = humanBytes(artifact.sizeBytes).replaceFirst(' ', '\u00a0');
|
|
return '$mime · $size';
|
|
}
|