mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Keep status pills inline and show tooltips only on overflow
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
0beca44496
commit
408585c056
@@ -218,9 +218,8 @@ Widget _cellContent(
|
|||||||
) {
|
) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case DeviceSortColumn.name:
|
case DeviceSortColumn.name:
|
||||||
return Text(
|
return _OverflowTooltipText(
|
||||||
_displayName(device),
|
text: _displayName(device),
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodyMedium,
|
style: theme.textTheme.bodyMedium,
|
||||||
);
|
);
|
||||||
case DeviceSortColumn.owner:
|
case DeviceSortColumn.owner:
|
||||||
@@ -233,21 +232,18 @@ Widget _cellContent(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Text(
|
return _OverflowTooltipText(
|
||||||
device.owner.isEmpty ? '—' : device.owner,
|
text: device.owner.isEmpty ? '—' : device.owner,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodyMedium,
|
style: theme.textTheme.bodyMedium,
|
||||||
);
|
);
|
||||||
case DeviceSortColumn.macAddress:
|
case DeviceSortColumn.macAddress:
|
||||||
return Text(
|
return _OverflowTooltipText(
|
||||||
device.macAddress,
|
text: device.macAddress,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(fontFamily: 'monospace'),
|
style: theme.textTheme.bodyMedium?.copyWith(fontFamily: 'monospace'),
|
||||||
);
|
);
|
||||||
case DeviceSortColumn.ipAddress:
|
case DeviceSortColumn.ipAddress:
|
||||||
return Text(
|
return _OverflowTooltipText(
|
||||||
device.ipv4Address,
|
text: device.ipv4Address,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(fontFamily: 'monospace'),
|
style: theme.textTheme.bodyMedium?.copyWith(fontFamily: 'monospace'),
|
||||||
);
|
);
|
||||||
case DeviceSortColumn.lastSeen:
|
case DeviceSortColumn.lastSeen:
|
||||||
@@ -256,23 +252,51 @@ Widget _cellContent(
|
|||||||
_StatusDot(lastSeen: device.lastSeen),
|
_StatusDot(lastSeen: device.lastSeen),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: _OverflowTooltipText(
|
||||||
formatter.format(device.lastSeen),
|
text: formatter.format(device.lastSeen),
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodyMedium,
|
style: theme.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
case DeviceSortColumn.vendor:
|
case DeviceSortColumn.vendor:
|
||||||
return Text(
|
return _OverflowTooltipText(
|
||||||
device.vendor.isEmpty ? '—' : device.vendor,
|
text: device.vendor.isEmpty ? '—' : device.vendor,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodyMedium,
|
style: theme.textTheme.bodyMedium,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _OverflowTooltipText extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final TextStyle? style;
|
||||||
|
|
||||||
|
const _OverflowTooltipText({required this.text, this.style});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final effectiveStyle = DefaultTextStyle.of(context).style.merge(style);
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final painter = TextPainter(
|
||||||
|
text: TextSpan(text: text, style: effectiveStyle),
|
||||||
|
maxLines: 1,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
|
textScaler: MediaQuery.textScalerOf(context),
|
||||||
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
|
final child = Text(
|
||||||
|
text,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: style,
|
||||||
|
);
|
||||||
|
return painter.didExceedMaxLines
|
||||||
|
? Tooltip(message: text, child: child)
|
||||||
|
: child;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DeviceRowCompact extends StatelessWidget {
|
class DeviceRowCompact extends StatelessWidget {
|
||||||
final Device device;
|
final Device device;
|
||||||
final FriendlyDateFormatter formatter;
|
final FriendlyDateFormatter formatter;
|
||||||
@@ -301,10 +325,7 @@ class DeviceRowCompact extends StatelessWidget {
|
|||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: _OverflowTooltipText(text: _displayName(device)),
|
||||||
_displayName(device),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
if (device.isRegistered)
|
if (device.isRegistered)
|
||||||
@@ -323,18 +344,19 @@ class DeviceRowCompact extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
_OverflowTooltipText(
|
||||||
'${device.isRegistered ? (device.owner.isEmpty ? '—' : device.owner) : device.ipv4Address} · ${device.macAddress}',
|
text:
|
||||||
|
'${device.isRegistered ? (device.owner.isEmpty ? '—' : device.owner) : device.ipv4Address} · ${device.macAddress}',
|
||||||
),
|
),
|
||||||
if (!device.isRegistered && device.vendor.isNotEmpty)
|
if (!device.isRegistered && device.vendor.isNotEmpty)
|
||||||
Text(device.vendor),
|
_OverflowTooltipText(text: device.vendor),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
_StatusDot(lastSeen: device.lastSeen),
|
_StatusDot(lastSeen: device.lastSeen),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: _OverflowTooltipText(
|
||||||
'Last seen: ${formatter.format(device.lastSeen)}',
|
text: 'Last seen: ${formatter.format(device.lastSeen)}',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ class StatusBadge extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
label,
|
label,
|
||||||
|
maxLines: 1,
|
||||||
|
softWrap: false,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
style: theme.textTheme.labelSmall?.copyWith(color: fg),
|
style: theme.textTheme.labelSmall?.copyWith(color: fg),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user