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,7 +2251,9 @@ class SensorMetricTile extends StatelessWidget {
border: Border.all(color: data.accent.withValues(alpha: 0.14)), border: Border.all(color: data.accent.withValues(alpha: 0.14)),
), ),
child: data.mapLocation == null || !allowMapPreview child: data.mapLocation == null || !allowMapPreview
? Row( ? Stack(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_MetricIcon(accent: data.accent, icon: data.icon), _MetricIcon(accent: data.accent, icon: data.icon),
@@ -2260,6 +2262,21 @@ class SensorMetricTile extends StatelessWidget {
child: _MetricText(data: data, keyPrefix: keyPrefix), 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( : Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -2395,11 +2412,7 @@ class _MetricText extends StatelessWidget {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Text(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
data.label, data.label,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -2408,27 +2421,6 @@ class _MetricText extends StatelessWidget {
fontWeight: FontWeight.w700, 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,
),
),
),
],
],
),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
data.value, data.value,