Skip to content

Commit d94cfbf

Browse files
fix: handled theming for instrument screens (#2732)
1 parent 1169df0 commit d94cfbf

8 files changed

Lines changed: 138 additions & 71 deletions

lib/constants.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ String maxValue = 'Max: ';
144144
String gyroscopeTitle = "Gyroscope";
145145
String gyroscopeAxisLabel = 'rad/s';
146146
String noData = 'No data available';
147+
String xyPlot = 'XY Plot';
148+
String enablePlot = 'Enable XY Plot';
149+
String trigger = 'Trigger';
150+
String timeBase = 'Timebase';
151+
String timeBaseAndTrigger = 'Timebase & Trigger';
152+
String offsets = 'Offsets';
153+
String dataAnalysis = 'Data Analysis';
154+
String fourierAnalysis = 'Fourier Analysis';
155+
String channels = 'Channels';
156+
String pslabMic = 'PSLab MIC';
157+
String inBuiltMic = 'In-Built MIC';
158+
String ch3Range = 'CH3 (+/- 3.3V)';
159+
String rangeValue = '+/-16V';
160+
String range = 'Range';
161+
String ch2 = 'CH2';
162+
String ch1 = 'CH1';
147163
String luxMeterTitle = 'Lux Meter';
148164
String builtIn = 'Built-In';
149165
String lx = 'Lx';

lib/others/theme.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,34 @@ class AppTheme {
66
useMaterial3: true,
77
scaffoldBackgroundColor: Colors.white,
88
colorSchemeSeed: Colors.white,
9+
checkboxTheme: const CheckboxThemeData(
10+
side: BorderSide(color: Colors.black, width: 2),
11+
),
12+
radioTheme: RadioThemeData(
13+
fillColor: WidgetStateProperty.resolveWith<Color>((states) {
14+
if (states.contains(WidgetState.selected)) {
15+
return const Color(0xFFCE525F);
16+
}
17+
return Colors.black;
18+
}),
19+
),
920
);
21+
1022
static final darkTheme = ThemeData(
1123
brightness: Brightness.dark,
1224
useMaterial3: true,
1325
scaffoldBackgroundColor: Colors.black,
1426
colorSchemeSeed: Colors.black,
27+
checkboxTheme: const CheckboxThemeData(
28+
side: BorderSide(color: Colors.black, width: 2),
29+
),
30+
radioTheme: RadioThemeData(
31+
fillColor: WidgetStateProperty.resolveWith<Color>((states) {
32+
if (states.contains(WidgetState.selected)) {
33+
return const Color(0xFFCE525F);
34+
}
35+
return Colors.black;
36+
}),
37+
),
1538
);
1639
}

lib/view/widgets/accelerometer_card.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ class _AccelerometerCardState extends State<AccelerometerCard> {
6767
margin: const EdgeInsets.only(top: 8, bottom: 12),
6868
child: Text(
6969
"${currVal.toStringAsFixed(1)} $accelerationAxisLabel",
70-
style: const TextStyle(fontSize: 14),
70+
style: const TextStyle(color: Colors.black, fontSize: 14),
7171
),
7272
),
7373
Container(
7474
alignment: Alignment.topLeft,
7575
margin: const EdgeInsets.only(left: 8, top: 4),
7676
child: Text(
7777
"$minValue ${minVal.toStringAsFixed(1)} $accelerationAxisLabel",
78-
style: const TextStyle(fontSize: 10),
78+
style: const TextStyle(color: Colors.black, fontSize: 10),
7979
),
8080
),
8181
Container(
8282
alignment: Alignment.topLeft,
8383
margin: const EdgeInsets.only(left: 8, top: 2),
8484
child: Text(
8585
"$maxValue ${maxVal.toStringAsFixed(1)} $accelerationAxisLabel",
86-
style: const TextStyle(fontSize: 10),
86+
style: const TextStyle(color: Colors.black, fontSize: 10),
8787
),
8888
),
8989
]),

lib/view/widgets/channel_parameters_widget.dart

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
4545
);
4646
},
4747
),
48-
const Text(
49-
'CH1',
50-
style: TextStyle(
48+
Text(
49+
ch1,
50+
style: const TextStyle(
51+
color: Colors.black,
5152
fontWeight: FontWeight.bold,
5253
fontStyle: FontStyle.normal,
5354
fontSize: 15,
5455
),
5556
),
56-
const Padding(
57-
padding: EdgeInsets.only(left: 8),
57+
Padding(
58+
padding: const EdgeInsets.only(left: 8),
5859
child: Text(
59-
'Range',
60-
style: TextStyle(
60+
range,
61+
style: const TextStyle(
6162
color: Color(0xFF424242),
6263
fontWeight: FontWeight.normal,
6364
fontStyle: FontStyle.normal,
@@ -82,7 +83,8 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
8283
inputDecorationTheme: const InputDecorationTheme(
8384
border: InputBorder.none,
8485
),
85-
textStyle: const TextStyle(fontSize: 15),
86+
textStyle:
87+
const TextStyle(color: Colors.black, fontSize: 15),
8688
onSelected: (String? value) {
8789
switch (yAxisRanges.indexOf(value!)) {
8890
case 0:
@@ -143,33 +145,35 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
143145
);
144146
},
145147
),
146-
const Text(
147-
'CH2',
148-
style: TextStyle(
148+
Text(
149+
ch2,
150+
style: const TextStyle(
151+
color: Colors.black,
149152
fontWeight: FontWeight.bold,
150153
fontStyle: FontStyle.normal,
151154
fontSize: 15,
152155
),
153156
),
154-
const Padding(
155-
padding: EdgeInsets.only(left: 8),
157+
Padding(
158+
padding: const EdgeInsets.only(left: 8),
156159
child: Text(
157-
'Range',
158-
style: TextStyle(
160+
range,
161+
style: const TextStyle(
159162
color: Color(0xFF424242),
160163
fontWeight: FontWeight.normal,
161164
fontStyle: FontStyle.normal,
162165
fontSize: 15,
163166
),
164167
),
165168
),
166-
const Padding(
167-
padding: EdgeInsets.only(left: 8),
169+
Padding(
170+
padding: const EdgeInsets.only(left: 8),
168171
child: SizedBox(
169172
width: 120,
170173
child: Text(
171-
'+/-16V',
172-
style: TextStyle(
174+
rangeValue,
175+
style: const TextStyle(
176+
color: Colors.black,
173177
fontStyle: FontStyle.normal,
174178
fontWeight: FontWeight.normal,
175179
fontSize: 15,
@@ -199,9 +203,10 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
199203
);
200204
},
201205
),
202-
const Text(
203-
'CH3 (+/- 3.3V)',
204-
style: TextStyle(
206+
Text(
207+
ch3Range,
208+
style: const TextStyle(
209+
color: Colors.black,
205210
fontWeight: FontWeight.bold,
206211
fontStyle: FontStyle.normal,
207212
fontSize: 15,
@@ -251,9 +256,10 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
251256
);
252257
},
253258
),
254-
const Text(
255-
'In-Built MIC',
256-
style: TextStyle(
259+
Text(
260+
inBuiltMic,
261+
style: const TextStyle(
262+
color: Colors.black,
257263
fontSize: 15,
258264
fontWeight: FontWeight.bold,
259265
fontStyle: FontStyle.normal,
@@ -283,9 +289,10 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
283289
);
284290
},
285291
),
286-
const Text(
287-
'PSLab MIC',
288-
style: TextStyle(
292+
Text(
293+
pslabMic,
294+
style: const TextStyle(
295+
color: Colors.black,
289296
fontSize: 15,
290297
fontWeight: FontWeight.bold,
291298
fontStyle: FontStyle.normal,
@@ -306,9 +313,9 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
306313
child: Container(
307314
padding: const EdgeInsets.symmetric(horizontal: 2),
308315
decoration: const BoxDecoration(color: Colors.white),
309-
child: const Text(
310-
'Channels',
311-
style: TextStyle(
316+
child: Text(
317+
channels,
318+
style: const TextStyle(
312319
color: Color(0xFFC72C2C),
313320
fontStyle: FontStyle.normal,
314321
fontWeight: FontWeight.bold,

lib/view/widgets/data_analysis_widget.dart

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
33
import 'package:pslab/providers/oscilloscope_state_provider.dart';
4+
import 'package:pslab/constants.dart';
45

56
class DataAnalysisWidget extends StatefulWidget {
67
const DataAnalysisWidget({super.key});
@@ -50,9 +51,10 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
5051
);
5152
},
5253
),
53-
const Text(
54-
'Fourier Analysis',
55-
style: TextStyle(
54+
Text(
55+
fourierAnalysis,
56+
style: const TextStyle(
57+
color: Colors.black,
5658
fontSize: 15,
5759
fontWeight: FontWeight.normal,
5860
fontStyle: FontStyle.normal,
@@ -88,6 +90,7 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
8890
border: InputBorder.none,
8991
),
9092
textStyle: const TextStyle(
93+
color: Colors.black,
9194
fontSize: 15,
9295
),
9396
onSelected: (String? value) {
@@ -128,6 +131,7 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
128131
border: InputBorder.none,
129132
),
130133
textStyle: const TextStyle(
134+
color: Colors.black,
131135
fontSize: 15,
132136
),
133137
onSelected: (value) {
@@ -165,6 +169,7 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
165169
border: InputBorder.none,
166170
),
167171
textStyle: const TextStyle(
172+
color: Colors.black,
168173
fontSize: 15,
169174
),
170175
onSelected: (value) {
@@ -189,9 +194,9 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
189194
child: Container(
190195
padding: const EdgeInsets.symmetric(horizontal: 2),
191196
decoration: const BoxDecoration(color: Colors.white),
192-
child: const Text(
193-
'Data Analysis',
194-
style: TextStyle(
197+
child: Text(
198+
dataAnalysis,
199+
style: const TextStyle(
195200
color: Color(0xFFC72C2C),
196201
fontStyle: FontStyle.normal,
197202
fontWeight: FontWeight.bold,
@@ -241,6 +246,7 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
241246
border: InputBorder.none,
242247
),
243248
textStyle: const TextStyle(
249+
color: Colors.black,
244250
fontSize: 15,
245251
),
246252
onSelected: (value) => {
@@ -262,9 +268,10 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
262268
children: [
263269
Expanded(
264270
child: SliderTheme(
265-
data: const SliderThemeData(
271+
data: SliderThemeData(
272+
inactiveTrackColor: Colors.blueGrey[100],
266273
trackHeight: 1,
267-
thumbShape: RoundSliderThumbShape(
274+
thumbShape: const RoundSliderThumbShape(
268275
enabledThumbRadius: 6),
269276
),
270277
child: Slider(
@@ -304,6 +311,7 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
304311
border: InputBorder.none,
305312
),
306313
style: const TextStyle(
314+
color: Colors.black,
307315
fontSize: 14,
308316
fontWeight: FontWeight.normal,
309317
fontStyle: FontStyle.normal,
@@ -343,9 +351,10 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
343351
children: [
344352
Expanded(
345353
child: SliderTheme(
346-
data: const SliderThemeData(
354+
data: SliderThemeData(
355+
inactiveTrackColor: Colors.blueGrey[100],
347356
trackHeight: 1,
348-
thumbShape: RoundSliderThumbShape(
357+
thumbShape: const RoundSliderThumbShape(
349358
enabledThumbRadius: 6),
350359
),
351360
child: Slider(
@@ -403,6 +412,7 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
403412
: '${oscilloscopeStateProvider.xOffsets[oscilloscopeStateProvider.selectedChannelOffset]!.toStringAsFixed(2)} ms',
404413
),
405414
style: const TextStyle(
415+
color: Colors.black,
406416
fontSize: 14,
407417
fontWeight: FontWeight.normal,
408418
fontStyle: FontStyle.normal,
@@ -456,9 +466,9 @@ class _DataAnalysisState extends State<DataAnalysisWidget> {
456466
child: Container(
457467
padding: const EdgeInsets.symmetric(horizontal: 2),
458468
decoration: const BoxDecoration(color: Colors.white),
459-
child: const Text(
460-
'Offsets',
461-
style: TextStyle(
469+
child: Text(
470+
offsets,
471+
style: const TextStyle(
462472
color: Color(0xFFC72C2C),
463473
fontStyle: FontStyle.normal,
464474
fontWeight: FontWeight.bold,

lib/view/widgets/gyroscope_card.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ class _GyroscopeCardState extends State<GyroscopeCard> {
101101
margin: const EdgeInsets.only(top: 8, bottom: 12),
102102
child: Text(
103103
"${currVal.toStringAsFixed(1)} $gyroscopeAxisLabel",
104-
style: const TextStyle(fontSize: 14),
104+
style: const TextStyle(color: Colors.black, fontSize: 14),
105105
),
106106
),
107107
Container(
108108
alignment: Alignment.topLeft,
109109
margin: const EdgeInsets.only(left: 8, top: 4),
110110
child: Text(
111111
"$minValue ${minVal.toStringAsFixed(1)} $gyroscopeAxisLabel",
112-
style: const TextStyle(fontSize: 10),
112+
style: const TextStyle(color: Colors.black, fontSize: 10),
113113
),
114114
),
115115
Container(
116116
alignment: Alignment.topLeft,
117117
margin: const EdgeInsets.only(left: 8, top: 2),
118118
child: Text(
119119
"$maxValue ${maxVal.toStringAsFixed(1)} $gyroscopeAxisLabel",
120-
style: const TextStyle(fontSize: 10),
120+
style: const TextStyle(color: Colors.black, fontSize: 10),
121121
),
122122
),
123123
]),

0 commit comments

Comments
 (0)