Skip to content

Commit b0518b9

Browse files
authored
fix(ui): improve accelerometer screen responsiveness
1 parent dca7953 commit b0518b9

4 files changed

Lines changed: 537 additions & 217 deletions

File tree

lib/l10n/app_en.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,5 +666,7 @@
666666
"pin_res_desc": "Resistance Measurement Pin",
667667
"stopSound" : "Stop Sound",
668668
"saw" : "Saw",
669-
"comingSoon": "Coming Soon"
669+
"comingSoon": "Coming Soon",
670+
"startRecording": "Start Recording",
671+
"stopRecording": "Stop Recording"
670672
}

lib/view/accelerometer_screen.dart

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,52 @@ class _AccelerometerScreenState extends State<AccelerometerScreen> {
266266
}
267267
: null,
268268
body: SafeArea(
269-
child: Column(
270-
children: [
271-
Expanded(
272-
child: AccelerometerCard(
269+
child: LayoutBuilder(
270+
builder: (context, constraints) {
271+
// Each card needs ~150dp minimum to render its compact
272+
// header + a usable chart. Three cards = ~450dp. If the
273+
// available height falls below that, switch to screen-
274+
// level vertical scrolling with a fixed per-card height
275+
// so nothing overflows. Above the threshold we keep the
276+
// current Expanded layout so cards fill the screen.
277+
const double kPerCardMin = 150.0;
278+
const double kPerCardScrollHeight = 220.0;
279+
final double available = constraints.maxHeight;
280+
final bool needsScroll = available < kPerCardMin * 3;
281+
282+
final List<Widget> cards = [
283+
AccelerometerCard(
273284
color: xOrientationChartLineColor,
274285
axis: appLocalizations.xAxis),
275-
),
276-
Expanded(
277-
child: AccelerometerCard(
286+
AccelerometerCard(
278287
color: yOrientationChartLineColor,
279288
axis: appLocalizations.yAxis),
280-
),
281-
Expanded(
282-
child: AccelerometerCard(
289+
AccelerometerCard(
283290
color: zOrientationChartLineColor,
284291
axis: appLocalizations.zAxis),
285-
),
286-
],
292+
];
293+
294+
if (needsScroll) {
295+
return SingleChildScrollView(
296+
physics: const ClampingScrollPhysics(),
297+
child: Column(
298+
children: [
299+
for (final card in cards)
300+
SizedBox(
301+
height: kPerCardScrollHeight,
302+
child: card,
303+
),
304+
],
305+
),
306+
);
307+
}
308+
309+
return Column(
310+
children: [
311+
for (final card in cards) Expanded(child: card),
312+
],
313+
);
314+
},
287315
),
288316
),
289317
);

0 commit comments

Comments
 (0)