Skip to content

Commit 1a67c39

Browse files
committed
Theme Manager
1 parent 386f5a4 commit 1a67c39

File tree

5 files changed

+479
-16
lines changed

5 files changed

+479
-16
lines changed

lib/editor.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:io';
22

33
import 'package:corecoder_develop/util/custom_code_box.dart';
44
import 'package:corecoder_develop/editor_drawer.dart';
5+
import 'package:corecoder_develop/util/theme_manager.dart';
56
import 'package:tabbed_view/tabbed_view.dart';
67
import 'package:flutter/material.dart';
78
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@@ -141,7 +142,7 @@ class _EditorPageState extends State<EditorPage> {
141142
constraints: BoxConstraints(
142143
minHeight: MediaQuery.of(context).size.height * 2),
143144
child: InnerField(
144-
language: language, theme: 'atom-one-dark', source: source),
145+
language: language, theme: ThemeManager.getHighlighting(), source: source),
145146
)));
146147
}
147148

@@ -165,7 +166,7 @@ class _EditorPageState extends State<EditorPage> {
165166
initializeTreeView();
166167
}
167168
final codeBox = InnerField(
168-
language: 'json', theme: 'atom-one-dark', source: project.name);
169+
language: 'json', theme: ThemeManager.getHighlighting(), source: project.name);
169170
final page = Column(//direction: Axis.vertical,
170171
children: [
171172
Expanded(
@@ -184,12 +185,10 @@ class _EditorPageState extends State<EditorPage> {
184185
]);
185186

186187
return Scaffold(
187-
backgroundColor: const Color(0xFF363636),
188188
drawer: MyDrawer(documentList, project, (String filepath) {
189189
openFile(filepath);
190190
}),
191191
appBar: AppBar(
192-
backgroundColor: Color(0xff23241f),
193192
title: null,
194193
// title: Text("Recursive Fibonacci"),
195194
centerTitle: false,

lib/main.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'dart:io' show File, Platform;
44
import 'package:corecoder_develop/editor.dart';
55
import 'package:corecoder_develop/util/modules_manager.dart'
66
show Module, ModulesManager, Template;
7+
import 'package:corecoder_develop/util/theme_manager.dart';
78
import 'package:flutter/material.dart';
89
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
910
import 'package:permission_handler/permission_handler.dart';
@@ -57,9 +58,7 @@ class MyApp extends StatelessWidget {
5758
child: MaterialApp(
5859
debugShowCheckedModeBanner: false,
5960
title: 'CoreCoder Develop',
60-
theme: ThemeData(
61-
primarySwatch: Colors.blueGrey,
62-
),
61+
theme: ThemeManager.getThemeData(name:"atom-one-dark"),
6362
//home: HomePage(),
6463
initialRoute: "/",
6564
routes: {
@@ -300,7 +299,6 @@ class _HomePageState extends State<HomePage> {
300299
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
301300
const Text(
302301
"Recent Projects",
303-
style: TextStyle(color: Colors.white),
304302
),
305303
Wrap(
306304
children: projectsWidgets,
@@ -310,9 +308,7 @@ class _HomePageState extends State<HomePage> {
310308
]),
311309
));
312310
return Scaffold(
313-
backgroundColor: const Color(0xFF363636),
314311
appBar: AppBar(
315-
backgroundColor: const Color(0xff23241f),
316312
title: const Text("CoreCoder Develop"),
317313
// title: Text("Recursive Fibonacci"),
318314
centerTitle: true,

lib/util/custom_code_box.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:corecoder_develop/contrib/code_text_field-1.0.2m/lib/code_text_f
55
import 'package:highlight/languages/all.dart';
66
class CustomCodeBox extends StatefulWidget {
77
final String language;
8-
final String theme;
8+
final Map<String, TextStyle> theme;
99
final String source;
1010

1111
const CustomCodeBox({Key? key, required this.language, required this.theme, required this.source})
@@ -17,7 +17,7 @@ class CustomCodeBox extends StatefulWidget {
1717

1818
class _CustomCodeBoxState extends State<CustomCodeBox> {
1919
String? language;
20-
String? theme;
20+
late Map<String,TextStyle> theme;
2121
String? source;
2222

2323
@override
@@ -99,9 +99,9 @@ class _CustomCodeBoxState extends State<CustomCodeBox> {
9999
// themeDropdown,
100100
// ]);
101101
final codeField = InnerField(
102-
key: ValueKey("$language - $theme"),
102+
key: ValueKey("$language"),
103103
language: language!,
104-
theme: theme!,
104+
theme: theme,
105105
source: source!,
106106
);
107107
// return Column(children: [
@@ -114,7 +114,7 @@ class _CustomCodeBoxState extends State<CustomCodeBox> {
114114

115115
class InnerField extends StatefulWidget {
116116
final String language;
117-
final String theme;
117+
final Map<String, TextStyle> theme;
118118
final String source;
119119

120120
const InnerField({Key? key, required this.language, required this.theme, required this.source})
@@ -151,7 +151,7 @@ class _InnerFieldState extends State<InnerField> {
151151
"bev": TextStyle(color: Colors.indigo),
152152
},
153153
language: allLanguages[widget.language],
154-
theme: THEMES[widget.theme],
154+
theme: widget.theme,
155155
);
156156
}
157157

0 commit comments

Comments
 (0)