Skip to content

Commit 51d70ce

Browse files
fix(appbar): prevent title overflow on narrow widths (#205)
Use width-aware layout in AppBarTitle to avoid RenderFlex overflows under tight title constraints and larger text scaling. Hide subtitle and signal indicators progressively when space is limited while preserving normal behavior on wider layouts.
1 parent b05b62e commit 51d70ce

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

lib/widgets/app_bar.dart

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,54 @@ class AppBarTitle extends StatelessWidget {
1414
@override
1515
Widget build(BuildContext context) {
1616
final connector = context.watch<MeshCoreConnector>();
17+
final selfName = connector.selfName;
1718

18-
return Row(
19-
mainAxisAlignment: MainAxisAlignment.start,
20-
children: [
21-
leading ?? const SizedBox.shrink(),
22-
Column(
23-
crossAxisAlignment: CrossAxisAlignment.start,
24-
mainAxisSize: MainAxisSize.min,
19+
return LayoutBuilder(
20+
builder: (context, constraints) {
21+
final availableWidth = constraints.hasBoundedWidth
22+
? constraints.maxWidth
23+
: MediaQuery.sizeOf(context).width;
24+
final compact = availableWidth < 240;
25+
final showSubtitle =
26+
!compact && connector.isConnected && selfName != null;
27+
final showBattery = availableWidth >= 60;
28+
final showSnr = availableWidth >= 110;
29+
final showIndicators = showBattery || showSnr;
30+
31+
return Row(
32+
mainAxisAlignment: MainAxisAlignment.start,
2533
children: [
26-
Text(title, overflow: TextOverflow.ellipsis),
27-
if (connector.isConnected && connector.selfName != null)
28-
Text(
29-
'(${connector.selfName})',
30-
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
31-
overflow: TextOverflow.ellipsis,
34+
leading ?? const SizedBox.shrink(),
35+
Expanded(
36+
child: Column(
37+
crossAxisAlignment: CrossAxisAlignment.start,
38+
mainAxisSize: MainAxisSize.min,
39+
children: [
40+
Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
41+
if (showSubtitle)
42+
Text(
43+
'($selfName)',
44+
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
45+
maxLines: 1,
46+
overflow: TextOverflow.ellipsis,
47+
),
48+
],
3249
),
50+
),
51+
if (showIndicators) const SizedBox(width: 6),
52+
if (showIndicators)
53+
Row(
54+
crossAxisAlignment: CrossAxisAlignment.start,
55+
mainAxisSize: MainAxisSize.min,
56+
children: [
57+
if (showBattery) BatteryIndicator(connector: connector),
58+
if (showSnr) SNRIndicator(connector: connector),
59+
],
60+
),
61+
trailing ?? const SizedBox.shrink(),
3362
],
34-
),
35-
const SizedBox(width: 8),
36-
Row(
37-
crossAxisAlignment: CrossAxisAlignment.start,
38-
mainAxisSize: MainAxisSize.min,
39-
children: [
40-
BatteryIndicator(connector: connector),
41-
SNRIndicator(connector: connector),
42-
],
43-
),
44-
trailing ?? const SizedBox.shrink(),
45-
],
63+
);
64+
},
4665
);
4766
}
4867
}

0 commit comments

Comments
 (0)