Skip to content

Commit be3ebfd

Browse files
feat: added guide drawer for barometer (#2771)
1 parent 7463f92 commit be3ebfd

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

assets/images/bmp180_schematic.png

64.8 KB
Loading

lib/constants.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,11 @@ String shareAppMenu = 'Share App';
368368
String privacyPolicyMenu = 'Privacy Policy';
369369
String shopLink = 'https://pslab.io/shop/';
370370
String shopError = 'Could not open the shop link';
371+
String baroMeterBulletPoint1 =
372+
'The Barometer can be used to measure Atmospheric pressure. This instrument is compatible with either the built in pressure sensor on any android device or the BMP-180 pressure sensor';
373+
String baroMeterBulletPoint2 =
374+
'If you want to use the sensor BMP-180, connect the sensor to PSLab device as shown in the figure.';
375+
String baroMeterBulletPoint3 =
376+
'The above pin configuration has to be same except for the pin GND. GND is meant for Ground and any of the PSLab device GND pins can be used since they are common.';
377+
String baroMeterBulletPoint4 =
378+
'Select the sensor by going to the Configure tab from the bottom navigation bar and choose BMP-180 in the drop down menu under Select Sensor.';

lib/view/barometer_screen.dart

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:pslab/theme/colors.dart';
88
import 'package:pslab/view/widgets/common_scaffold_widget.dart';
99
import 'package:pslab/view/widgets/barometer_card.dart';
1010
import 'package:fl_chart/fl_chart.dart';
11+
import 'package:pslab/view/widgets/guide_widget.dart';
1112

1213
class BarometerScreen extends StatefulWidget {
1314
const BarometerScreen({super.key});
@@ -16,6 +17,9 @@ class BarometerScreen extends StatefulWidget {
1617
}
1718

1819
class _BarometerScreenState extends State<BarometerScreen> {
20+
bool _showGuide = false;
21+
static const imagePath = 'assets/images/bmp180_schematic.png';
22+
1923
void _showSensorErrorSnackbar(String message) {
2024
if (mounted) {
2125
ScaffoldMessenger.of(context).showSnackBar(
@@ -32,6 +36,36 @@ class _BarometerScreenState extends State<BarometerScreen> {
3236
}
3337
}
3438

39+
void _showInstrumentGuide() {
40+
setState(() {
41+
_showGuide = true;
42+
});
43+
}
44+
45+
void _hideInstrumentGuide() {
46+
setState(() {
47+
_showGuide = false;
48+
});
49+
}
50+
51+
List<Widget> _getBarometerContent() {
52+
return [
53+
InstrumentBulletPoint(
54+
text: baroMeterBulletPoint1,
55+
),
56+
InstrumentBulletPoint(
57+
text: baroMeterBulletPoint2,
58+
),
59+
const InstrumentImage(
60+
imagePath: imagePath,
61+
),
62+
InstrumentBulletPoint(
63+
text: baroMeterBulletPoint3,
64+
),
65+
InstrumentBulletPoint(text: baroMeterBulletPoint4),
66+
];
67+
}
68+
3569
@override
3670
Widget build(BuildContext context) {
3771
return MultiProvider(
@@ -41,23 +75,32 @@ class _BarometerScreenState extends State<BarometerScreen> {
4175
..initializeSensors(onError: _showSensorErrorSnackbar),
4276
),
4377
],
44-
child: CommonScaffold(
45-
title: barometerTitle,
46-
body: SafeArea(
47-
child: Column(
48-
children: [
49-
const Expanded(
50-
flex: 45,
51-
child: BarometerCard(),
52-
),
53-
Expanded(
54-
flex: 55,
55-
child: _buildChartSection(),
56-
),
57-
],
78+
child: Stack(children: [
79+
CommonScaffold(
80+
title: barometerTitle,
81+
onGuidePressed: _showInstrumentGuide,
82+
body: SafeArea(
83+
child: Column(
84+
children: [
85+
const Expanded(
86+
flex: 45,
87+
child: BarometerCard(),
88+
),
89+
Expanded(
90+
flex: 55,
91+
child: _buildChartSection(),
92+
),
93+
],
94+
),
5895
),
5996
),
60-
),
97+
if (_showGuide)
98+
InstrumentOverviewDrawer(
99+
instrumentName: barometerTitle,
100+
content: _getBarometerContent(),
101+
onHide: _hideInstrumentGuide,
102+
),
103+
]),
61104
);
62105
}
63106

0 commit comments

Comments
 (0)