Skip to content

Commit a5f7dd0

Browse files
committed
+ dark mode
1 parent c441e3d commit a5f7dd0

File tree

9 files changed

+328
-95
lines changed

9 files changed

+328
-95
lines changed

lib/main.dart

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import 'dart:ui';
44
import 'dart:async';
55
import 'dart:io';
66
import 'package:window_manager/window_manager.dart';
7+
import 'package:provider/provider.dart';
78
import 'services/tunnel_service.dart';
89
import 'services/system_tray_service.dart';
10+
import 'services/theme_service.dart';
911
import 'screens/tunnel_list_screen.dart';
1012

1113
void main() async {
@@ -69,7 +71,12 @@ void main() async {
6971
await _initializeSystemTrayDelayed();
7072
});
7173

72-
runApp(const TunstunApp());
74+
runApp(
75+
ChangeNotifierProvider(
76+
create: (_) => ThemeService(),
77+
child: const TunstunApp(),
78+
),
79+
);
7380
}
7481

7582
// Delayed system tray initialization to prevent segfaults on problematic systems
@@ -192,14 +199,37 @@ class _TunstunAppState extends State<TunstunApp> {
192199

193200
@override
194201
Widget build(BuildContext context) {
195-
return MaterialApp(
196-
title: 'Tunstun',
197-
theme: ThemeData(
198-
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo.shade700),
199-
useMaterial3: true,
200-
),
201-
home: TunnelListScreen(tunnelService: tunnelService),
202-
debugShowCheckedModeBanner: false,
202+
return Consumer<ThemeService>(
203+
builder: (context, themeService, child) {
204+
return MaterialApp(
205+
title: 'Tunstun',
206+
themeMode: themeService.themeMode,
207+
theme: ThemeData(
208+
colorScheme: ColorScheme.fromSeed(
209+
seedColor: Colors.indigo.shade700,
210+
brightness: Brightness.light,
211+
),
212+
useMaterial3: true,
213+
appBarTheme: const AppBarTheme(
214+
centerTitle: true,
215+
elevation: 0,
216+
),
217+
),
218+
darkTheme: ThemeData(
219+
colorScheme: ColorScheme.fromSeed(
220+
seedColor: Colors.indigo.shade700,
221+
brightness: Brightness.dark,
222+
),
223+
useMaterial3: true,
224+
appBarTheme: const AppBarTheme(
225+
centerTitle: true,
226+
elevation: 0,
227+
),
228+
),
229+
home: TunnelListScreen(tunnelService: tunnelService),
230+
debugShowCheckedModeBanner: false,
231+
);
232+
},
203233
);
204234
}
205235
}

lib/screens/add_tunnel_screen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class _AddTunnelScreenState extends State<AddTunnelScreen> {
3737
return Scaffold(
3838
appBar: AppBar(
3939
title: const Text('New Tunnel'),
40-
foregroundColor: Colors.white,
41-
backgroundColor: Colors.indigo.shade500,
4240
),
4341
body: Padding(
4442
padding: const EdgeInsets.all(16.0),

lib/screens/config_manager_screen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ class _ConfigManagerScreenState extends State<ConfigManagerScreen> {
6060
return Scaffold(
6161
appBar: AppBar(
6262
title: const Text('Configuration Manager'),
63-
backgroundColor: Colors.blue,
64-
foregroundColor: Colors.white,
6563
actions: [
6664
IconButton(
6765
icon: const Icon(Icons.refresh),

lib/screens/edit_tunnel_screen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ class _EditTunnelScreenState extends State<EditTunnelScreen> {
6060
return Scaffold(
6161
appBar: AppBar(
6262
title: const Text('Edit Tunnel'),
63-
foregroundColor: Colors.white,
64-
backgroundColor: Colors.indigo.shade500,
6563
),
6664
body: Padding(
6765
padding: const EdgeInsets.all(16.0),

0 commit comments

Comments
 (0)