fix: Sensor tiles — move channel label to bottom-right, smaller

Channel chip (ch2) was inline with the label, stealing horizontal
space and causing label truncation ('Temper...'). Now positioned as
a tiny 9px label anchored bottom-right of the tile, giving the full
width to the metric label and value.
This commit is contained in:
Janez T
2026-03-18 16:58:48 +01:00
parent 6af8b62d9b
commit 68ec72534d

View File

@@ -2251,14 +2251,31 @@ class SensorMetricTile extends StatelessWidget {
border: Border.all(color: data.accent.withValues(alpha: 0.14)),
),
child: data.mapLocation == null || !allowMapPreview
? Row(
crossAxisAlignment: CrossAxisAlignment.start,
? Stack(
children: [
_MetricIcon(accent: data.accent, icon: data.icon),
const SizedBox(width: 10),
Expanded(
child: _MetricText(data: data, keyPrefix: keyPrefix),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_MetricIcon(accent: data.accent, icon: data.icon),
const SizedBox(width: 10),
Expanded(
child: _MetricText(data: data, keyPrefix: keyPrefix),
),
],
),
if (data.channel != null)
Positioned(
right: 0,
bottom: 0,
child: Text(
'ch${data.channel}',
style: TextStyle(
fontSize: 9,
fontWeight: FontWeight.w700,
color: data.accent.withValues(alpha: 0.5),
),
),
),
],
)
: Column(
@@ -2395,39 +2412,14 @@ class _MetricText extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
data.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelMedium?.copyWith(
color: data.accent,
fontWeight: FontWeight.w700,
),
),
),
if (data.channel != null) ...[
const SizedBox(width: 8),
Container(
key: ValueKey('${keyPrefix}_channel_${data.fieldKey}'),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: data.accent.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(999),
),
child: Text(
'ch${data.channel}',
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: data.accent,
fontWeight: FontWeight.w800,
),
),
),
],
],
Text(
data.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelMedium?.copyWith(
color: data.accent,
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 4),
Text(