Skip to content

Commit 5071e55

Browse files
Merge pull request #36 from defuncart/feat/dark-mode
feat: Support Dark Mode
2 parents f2e6347 + b14ac12 commit 5071e55

File tree

4 files changed

+50
-28
lines changed

4 files changed

+50
-28
lines changed

lib/interface/home.dart

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,10 @@ class HomeScreenState extends ConsumerState<HomeScreen>
956956
Widget buildSectionTitle(String text) {
957957
return Padding(
958958
padding: const EdgeInsets.only(left: 16, right: 16),
959-
child: Text(text.toUpperCase(),
960-
style: const TextStyle(color: Colors.black54, fontSize: 13)),
959+
child: Text(
960+
text.toUpperCase(),
961+
style: Theme.of(context).textTheme.titleSmall,
962+
),
961963
);
962964
}
963965

@@ -1006,7 +1008,6 @@ class HomeScreenState extends ConsumerState<HomeScreen>
10061008
},
10071009
selected: selected,
10081010
trailing: selected ? const Icon(Icons.check) : null,
1009-
selectedTileColor: Colors.grey[100],
10101011
leading: Column(
10111012
mainAxisAlignment: MainAxisAlignment.center,
10121013
children: [
@@ -1049,17 +1050,11 @@ class HomeScreenState extends ConsumerState<HomeScreen>
10491050
}
10501051

10511052
Widget buildOwnDeviceView(Device device) {
1052-
return Container(
1053-
decoration: const BoxDecoration(
1054-
color: Colors.white,
1055-
boxShadow: [
1056-
BoxShadow(
1057-
color: Colors.black12,
1058-
offset: Offset(0, 0),
1059-
blurRadius: 10.0,
1060-
),
1061-
],
1062-
),
1053+
print(Theme.of(context).brightness);
1054+
print(MediaQuery.platformBrightnessOf(context));
1055+
1056+
return Material(
1057+
elevation: 2,
10631058
child: SafeArea(
10641059
bottom: false,
10651060
child: Column(

lib/interface/pairing_dialog.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class PairingDialogState extends State<PairingDialog> {
6161
Row(
6262
mainAxisAlignment: MainAxisAlignment.spaceBetween,
6363
children: [
64-
const Text('Pairing Code',
65-
style: TextStyle(color: Color.fromRGBO(0, 0, 0, 0.7))),
64+
const Text('Pairing Code'),
6665
Padding(
6766
padding: const EdgeInsets.only(top: 8, bottom: 8),
6867
child: Container(
@@ -108,13 +107,11 @@ class PairingDialogState extends State<PairingDialog> {
108107
),
109108
],
110109
),
111-
const Divider(color: Colors.grey),
110+
const Divider(),
112111
Row(
113112
mainAxisAlignment: MainAxisAlignment.spaceBetween,
114113
children: [
115-
const Text('Your Pairing Code',
116-
style: TextStyle(
117-
color: Color.fromRGBO(0, 0, 0, 0.7), height: 2)),
114+
const Text('Your Pairing Code', style: TextStyle(height: 2)),
118115
Padding(
119116
padding: const EdgeInsets.only(top: 16.0, bottom: 8.0),
120117
child: Text(localPairingCode,
@@ -127,14 +124,19 @@ class PairingDialogState extends State<PairingDialog> {
127124
),
128125
if (errorMessage != null)
129126
Padding(
130-
padding: const EdgeInsets.only(top: 16.0),
127+
padding: const EdgeInsets.symmetric(vertical: 16.0),
131128
child: Container(
132129
padding: const EdgeInsets.only(
133130
top: 8, bottom: 8, right: 15, left: 15),
134131
decoration: BoxDecoration(
135-
borderRadius: BorderRadius.circular(100),
136-
color: const Color.fromRGBO(0, 0, 0, 0.1)),
137-
child: Text(errorMessage ?? ''),
132+
borderRadius: BorderRadius.circular(100),
133+
color: Theme.of(context).colorScheme.error,
134+
),
135+
child: Text(
136+
errorMessage ?? '',
137+
style: TextStyle(
138+
color: Theme.of(context).colorScheme.onError),
139+
),
138140
),
139141
),
140142
],

lib/interface/themes.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import 'package:flutter/material.dart';
2+
3+
const _primaryColor = Color.fromRGBO(150, 150, 250, 1);
4+
5+
final lightTheme = ThemeData(
6+
colorScheme: ColorScheme.fromSeed(seedColor: _primaryColor),
7+
useMaterial3: true,
8+
textTheme: const TextTheme(
9+
titleSmall: TextStyle(color: Colors.black54),
10+
),
11+
);
12+
13+
final darkTheme = ThemeData.dark(
14+
useMaterial3: true,
15+
).copyWith(
16+
colorScheme: ColorScheme.fromSeed(
17+
brightness: Brightness.dark,
18+
seedColor: _primaryColor,
19+
),
20+
textTheme: TextTheme(
21+
titleSmall: TextStyle(
22+
color: Colors.white.withOpacity(0.87),
23+
),
24+
),
25+
);

lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:airdash/interface/themes.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter_riverpod/flutter_riverpod.dart';
34
import 'package:sentry_flutter/sentry_flutter.dart';
@@ -24,12 +25,11 @@ class App extends StatelessWidget {
2425

2526
@override
2627
Widget build(BuildContext context) {
27-
var primaryColor = const Color.fromRGBO(150, 150, 250, 1);
2828
return MaterialApp(
2929
debugShowCheckedModeBanner: false,
30-
theme: ThemeData(
31-
colorScheme: ColorScheme.fromSeed(seedColor: primaryColor),
32-
useMaterial3: true),
30+
theme: lightTheme,
31+
darkTheme: darkTheme,
32+
themeMode: ThemeMode.system,
3333
home: const SetupScreen(),
3434
);
3535
}

0 commit comments

Comments
 (0)