Skip to content

Commit b126c1f

Browse files
feat: implemented theming (#2730)
1 parent da2abd0 commit b126c1f

9 files changed

Lines changed: 69 additions & 30 deletions

File tree

assets/images/logo.png

4.19 KB
Loading

lib/main.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:pslab/view/oscilloscope_screen.dart';
1111
import 'package:pslab/view/settings_screen.dart';
1212
import 'package:pslab/view/about_us_screen.dart';
1313
import 'package:pslab/view/software_licenses_screen.dart';
14-
14+
import 'package:pslab/others/theme.dart';
1515
import 'constants.dart';
1616

1717
void main() {
@@ -38,10 +38,9 @@ class MyApp extends StatelessWidget {
3838
_preCacheImages(context);
3939
return MaterialApp(
4040
debugShowCheckedModeBanner: false,
41-
theme: ThemeData(
42-
colorSchemeSeed: Colors.white,
43-
useMaterial3: true,
44-
),
41+
theme: AppTheme.lightTheme,
42+
darkTheme: AppTheme.darkTheme,
43+
themeMode: ThemeMode.system,
4544
initialRoute: '/',
4645
routes: {
4746
'/': (context) => const InstrumentsScreen(),

lib/others/theme.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AppTheme {
4+
static final lightTheme = ThemeData(
5+
brightness: Brightness.light,
6+
useMaterial3: true,
7+
scaffoldBackgroundColor: Colors.white,
8+
colorSchemeSeed: Colors.white,
9+
);
10+
static final darkTheme = ThemeData(
11+
brightness: Brightness.dark,
12+
useMaterial3: true,
13+
scaffoldBackgroundColor: Colors.black,
14+
colorSchemeSeed: Colors.black,
15+
);
16+
}

lib/view/about_us_screen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class _AboutUsScreenState extends State<AboutUsScreen> {
9494
iconAboutUs,
9595
width: 250,
9696
height: 250,
97+
color: Theme.of(context).colorScheme.onSurface,
9798
),
9899
),
99100
Center(

lib/view/connect_device_screen.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
7272
textAlign: TextAlign.center,
7373
style: const TextStyle(
7474
decoration: TextDecoration.underline,
75-
color: Colors.black,
7675
fontSize: 18,
7776
fontWeight: FontWeight.bold,
7877
),
@@ -83,21 +82,18 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
8382
stepsToConnect[1],
8483
style: const TextStyle(
8584
fontSize: 16,
86-
color: Colors.black,
8785
),
8886
),
8987
Text(
9088
stepsToConnect[2],
9189
style: const TextStyle(
9290
fontSize: 16,
93-
color: Colors.black,
9491
),
9592
),
9693
Text(
9794
stepsToConnect[3],
9895
style: const TextStyle(
9996
fontSize: 16,
100-
color: Colors.black,
10197
),
10298
),
10399
],
@@ -110,7 +106,6 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
110106
child: Text(
111107
bluetoothWifiConnection,
112108
style: const TextStyle(
113-
color: Colors.black,
114109
fontSize: 14,
115110
),
116111
),

lib/view/settings_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
2626
shape: const RoundedRectangleBorder(
2727
borderRadius: BorderRadius.zero,
2828
),
29-
backgroundColor: Colors.white,
29+
backgroundColor: Theme.of(context).colorScheme.surface,
3030
title: Text(export,
3131
style:
3232
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),

lib/view/widgets/applications_list_item.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ApplicationsListItem extends StatelessWidget {
4040
verticalBarsIcon,
4141
width: 100,
4242
fit: BoxFit.fill,
43+
color: Colors.white,
4344
),
4445
),
4546
const SizedBox(
@@ -60,6 +61,7 @@ class ApplicationsListItem extends StatelessWidget {
6061
horizontalBarsIcon,
6162
height: 100,
6263
fit: BoxFit.fill,
64+
color: Colors.white,
6365
),
6466
),
6567
SizedBox(
@@ -68,6 +70,7 @@ class ApplicationsListItem extends StatelessWidget {
6870
child: Image.asset(
6971
instrumentIcon,
7072
fit: BoxFit.fill,
73+
color: Colors.white,
7174
),
7275
)
7376
],

lib/view/widgets/main_scaffold_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class _MainScaffoldState extends State<MainScaffold> {
3030
@override
3131
Widget build(BuildContext context) {
3232
return Scaffold(
33-
backgroundColor: Colors.white,
33+
backgroundColor: Theme.of(context).colorScheme.surface,
3434
resizeToAvoidBottomInset: true,
3535
appBar: AppBar(
3636
systemOverlayStyle:

lib/view/widgets/navigation_drawer.dart

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class _NavDrawerState extends State<NavDrawer> {
2424
shape: const RoundedRectangleBorder(
2525
borderRadius: BorderRadius.zero,
2626
),
27-
backgroundColor: const Color(0xFFFAFAFA),
27+
backgroundColor: Theme.of(context).colorScheme.surface,
2828
child: ScrollConfiguration(
2929
behavior: const ScrollBehavior(),
3030
child: ListView(
@@ -37,10 +37,9 @@ class _NavDrawerState extends State<NavDrawer> {
3737
SizedBox(
3838
height: 80,
3939
width: 80,
40-
child: Image.asset(
41-
navHeaderLogo,
42-
fit: BoxFit.contain,
43-
),
40+
child: Image.asset(navHeaderLogo,
41+
fit: BoxFit.contain,
42+
color: Theme.of(context).colorScheme.onSurface),
4443
),
4544
Consumer<BoardStateProvider>(
4645
builder: (context, provider, _) {
@@ -67,7 +66,9 @@ class _NavDrawerState extends State<NavDrawer> {
6766
title: Text(
6867
'Instruments',
6968
style: TextStyle(
70-
color: widget.selectedIndex == 0 ? Colors.red : Colors.black,
69+
color: widget.selectedIndex == 0
70+
? Colors.red
71+
: Theme.of(context).colorScheme.onSurface,
7172
fontWeight: FontWeight.bold,
7273
fontSize: 14,
7374
),
@@ -98,7 +99,9 @@ class _NavDrawerState extends State<NavDrawer> {
9899
title: Text(
99100
'Logged Data',
100101
style: TextStyle(
101-
color: widget.selectedIndex == 1 ? Colors.red : Colors.black,
102+
color: widget.selectedIndex == 1
103+
? Colors.red
104+
: Theme.of(context).colorScheme.onSurface,
102105
fontWeight: FontWeight.bold,
103106
fontSize: 14,
104107
),
@@ -118,7 +121,9 @@ class _NavDrawerState extends State<NavDrawer> {
118121
title: Text(
119122
'Connect Device',
120123
style: TextStyle(
121-
color: widget.selectedIndex == 2 ? Colors.red : Colors.black,
124+
color: widget.selectedIndex == 2
125+
? Colors.red
126+
: Theme.of(context).colorScheme.onSurface,
122127
fontWeight: FontWeight.bold,
123128
fontSize: 14,
124129
),
@@ -147,7 +152,9 @@ class _NavDrawerState extends State<NavDrawer> {
147152
title: Text(
148153
'Generate Config File',
149154
style: TextStyle(
150-
color: widget.selectedIndex == 3 ? Colors.red : Colors.black,
155+
color: widget.selectedIndex == 3
156+
? Colors.red
157+
: Theme.of(context).colorScheme.onSurface,
151158
fontWeight: FontWeight.bold,
152159
fontSize: 14,
153160
),
@@ -166,7 +173,9 @@ class _NavDrawerState extends State<NavDrawer> {
166173
title: Text(
167174
'Settings',
168175
style: TextStyle(
169-
color: widget.selectedIndex == 4 ? Colors.red : Colors.black,
176+
color: widget.selectedIndex == 4
177+
? Colors.red
178+
: Theme.of(context).colorScheme.onSurface,
170179
fontWeight: FontWeight.bold,
171180
fontSize: 14,
172181
),
@@ -195,7 +204,9 @@ class _NavDrawerState extends State<NavDrawer> {
195204
title: Text(
196205
'About Us',
197206
style: TextStyle(
198-
color: widget.selectedIndex == 5 ? Colors.red : Colors.black,
207+
color: widget.selectedIndex == 5
208+
? Colors.red
209+
: Theme.of(context).colorScheme.onSurface,
199210
fontWeight: FontWeight.bold,
200211
fontSize: 14,
201212
),
@@ -223,7 +234,9 @@ class _NavDrawerState extends State<NavDrawer> {
223234
title: Text(
224235
'Documentation',
225236
style: TextStyle(
226-
color: widget.selectedIndex == 6 ? Colors.red : Colors.black,
237+
color: widget.selectedIndex == 6
238+
? Colors.red
239+
: Theme.of(context).colorScheme.onSurface,
227240
fontWeight: FontWeight.bold,
228241
fontSize: 14,
229242
),
@@ -242,7 +255,9 @@ class _NavDrawerState extends State<NavDrawer> {
242255
title: Text(
243256
'Rate App',
244257
style: TextStyle(
245-
color: widget.selectedIndex == 7 ? Colors.red : Colors.black,
258+
color: widget.selectedIndex == 7
259+
? Colors.red
260+
: Theme.of(context).colorScheme.onSurface,
246261
fontWeight: FontWeight.bold,
247262
fontSize: 14,
248263
),
@@ -261,7 +276,9 @@ class _NavDrawerState extends State<NavDrawer> {
261276
title: Text(
262277
'Buy PSLab',
263278
style: TextStyle(
264-
color: widget.selectedIndex == 8 ? Colors.red : Colors.black,
279+
color: widget.selectedIndex == 8
280+
? Colors.red
281+
: Theme.of(context).colorScheme.onSurface,
265282
fontWeight: FontWeight.bold,
266283
fontSize: 14,
267284
),
@@ -280,7 +297,9 @@ class _NavDrawerState extends State<NavDrawer> {
280297
title: Text(
281298
'FAQ',
282299
style: TextStyle(
283-
color: widget.selectedIndex == 9 ? Colors.red : Colors.black,
300+
color: widget.selectedIndex == 9
301+
? Colors.red
302+
: Theme.of(context).colorScheme.onSurface,
284303
fontWeight: FontWeight.bold,
285304
fontSize: 14,
286305
),
@@ -299,7 +318,9 @@ class _NavDrawerState extends State<NavDrawer> {
299318
title: Text(
300319
'Share App',
301320
style: TextStyle(
302-
color: widget.selectedIndex == 10 ? Colors.red : Colors.black,
321+
color: widget.selectedIndex == 10
322+
? Colors.red
323+
: Theme.of(context).colorScheme.onSurface,
303324
fontWeight: FontWeight.bold,
304325
fontSize: 14,
305326
),
@@ -318,7 +339,9 @@ class _NavDrawerState extends State<NavDrawer> {
318339
title: Text(
319340
'Privacy Policy',
320341
style: TextStyle(
321-
color: widget.selectedIndex == 11 ? Colors.red : Colors.black,
342+
color: widget.selectedIndex == 11
343+
? Colors.red
344+
: Theme.of(context).colorScheme.onSurface,
322345
fontWeight: FontWeight.bold,
323346
fontSize: 14,
324347
),
@@ -337,7 +360,9 @@ class _NavDrawerState extends State<NavDrawer> {
337360
title: Text(
338361
softwareLicenses,
339362
style: TextStyle(
340-
color: widget.selectedIndex == 12 ? Colors.red : Colors.black,
363+
color: widget.selectedIndex == 12
364+
? Colors.red
365+
: Theme.of(context).colorScheme.onSurface,
341366
fontWeight: FontWeight.bold,
342367
fontSize: 14,
343368
),

0 commit comments

Comments
 (0)