Skip to content

Commit 77f671a

Browse files
committed
Added Dark theme with toggle to switch
Moved all Color variables to Styles.dart Now saves current theme locally for subsequent runs Saves it automatically every time you change it Default at first run is Dark theme FAB labels don't support theming yet, will be added if (fysoul17/flutter_speed_dial_material_design#7) is merged
1 parent 1033130 commit 77f671a

File tree

3 files changed

+213
-69
lines changed

3 files changed

+213
-69
lines changed

sudoku/lib/Alerts.dart

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3-
import 'main.dart';
3+
import 'package:sudoku/Styles.dart';
44

55
class AlertGameOver extends StatelessWidget {
66
static bool newGame = false;
@@ -10,19 +10,26 @@ class AlertGameOver extends StatelessWidget {
1010
Widget build(BuildContext context) {
1111
return AlertDialog(
1212
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
13-
title: Text('Game Over'),
14-
content: Text('You successfully solved the Sudoku'),
13+
backgroundColor: Styles.bg_2,
14+
title: Text(
15+
'Game Over',
16+
style: TextStyle(color: Styles.fg),
17+
),
18+
content: Text(
19+
'You successfully solved the Sudoku',
20+
style: TextStyle(color: Styles.fg),
21+
),
1522
actions: [
1623
FlatButton(
17-
textColor: MyApp.primaryColor,
24+
textColor: Styles.primaryColor,
1825
onPressed: () {
1926
Navigator.pop(context);
2027
restartGame = true;
2128
},
2229
child: Text('Restart Game'),
2330
),
2431
FlatButton(
25-
textColor: MyApp.primaryColor,
32+
textColor: Styles.primaryColor,
2633
onPressed: () {
2734
Navigator.pop(context);
2835
newGame = true;
@@ -72,7 +79,12 @@ class AlertDifficulty extends State<AlertDifficultyState> {
7279
Widget build(BuildContext context) {
7380
return SimpleDialog(
7481
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
75-
title: Center(child: Text('Select Difficulty Level')),
82+
title: Center(
83+
child: Text(
84+
'Select Difficulty Level',
85+
style: TextStyle(color: Styles.fg),
86+
)),
87+
backgroundColor: Styles.bg_2,
7688
contentPadding: EdgeInsets.fromLTRB(10, 10, 10, 10),
7789
children: <Widget>[
7890
for (String level in difficulties)
@@ -90,8 +102,8 @@ class AlertDifficulty extends State<AlertDifficultyState> {
90102
style: TextStyle(
91103
fontSize: 15,
92104
color: level == this.currentDifficultyLevel
93-
? MyApp.primaryColor
94-
: Colors.black)),
105+
? Styles.primaryColor
106+
: Styles.fg)),
95107
),
96108
],
97109
);
@@ -103,18 +115,25 @@ class AlertExit extends StatelessWidget {
103115
Widget build(BuildContext context) {
104116
return AlertDialog(
105117
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
106-
title: Text('Exit Game'),
107-
content: Text('Are you sure you want to exit the game ?'),
118+
backgroundColor: Styles.bg_2,
119+
title: Text(
120+
'Exit Game',
121+
style: TextStyle(color: Styles.fg),
122+
),
123+
content: Text(
124+
'Are you sure you want to exit the game ?',
125+
style: TextStyle(color: Styles.fg),
126+
),
108127
actions: [
109128
FlatButton(
110-
textColor: MyApp.primaryColor,
129+
textColor: Styles.primaryColor,
111130
onPressed: () {
112131
Navigator.pop(context);
113132
},
114133
child: Text('No'),
115134
),
116135
FlatButton(
117-
textColor: MyApp.primaryColor,
136+
textColor: Styles.primaryColor,
118137
onPressed: () {
119138
SystemNavigator.pop();
120139
},
@@ -159,12 +178,12 @@ class AlertNumbers extends State<AlertNumbersState> {
159178
Navigator.pop(context);
160179
})
161180
},
162-
color: Colors.white,
163-
textColor: MyApp.primaryColor,
181+
color: Styles.bg_2,
182+
textColor: Styles.primaryColor,
164183
highlightColor: Colors.blueAccent,
165184
shape: RoundedRectangleBorder(
166185
side: BorderSide(
167-
color: Colors.black,
186+
color: Styles.fg,
168187
width: 1,
169188
style: BorderStyle.solid,
170189
),
@@ -199,7 +218,12 @@ class AlertNumbers extends State<AlertNumbersState> {
199218
Widget build(BuildContext context) {
200219
return AlertDialog(
201220
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
202-
title: Center(child: Text('Choose a Number')),
221+
backgroundColor: Styles.bg_2,
222+
title: Center(
223+
child: Text(
224+
'Choose a Number',
225+
style: TextStyle(color: Styles.fg),
226+
)),
203227
content: Column(
204228
mainAxisSize: MainAxisSize.min,
205229
mainAxisAlignment: MainAxisAlignment.center,

sudoku/lib/Styles.dart

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Styles {
4+
// #121212
5+
static MaterialColor dark = MaterialColor(4279374354, {
6+
50: Color(0xff7d7d7d),
7+
100: Color(0xff717171),
8+
200: Color(0xff595959),
9+
300: Color(0xff414141),
10+
400: Color(0xff2a2a2a),
11+
500: Color(0xff121212),
12+
600: Color(0xff101010),
13+
700: Color(0xff0e0e0e),
14+
800: Color(0xff0d0d0d),
15+
900: Color(0xff0b0b0b)
16+
});
17+
18+
// #FFFFFF
19+
static MaterialColor light = MaterialColor(4294967295, {
20+
50: Color(0xffffffff),
21+
100: Color(0xffffffff),
22+
200: Color(0xffffffff),
23+
300: Color(0xffffffff),
24+
400: Color(0xffffffff),
25+
500: Color(0xffffffff),
26+
600: Color(0xffe5e5e5),
27+
700: Color(0xffcccccc),
28+
800: Color(0xffb2b2b2),
29+
900: Color(0xff999999)
30+
});
31+
32+
// 303030
33+
static MaterialColor grey = MaterialColor(4281348144, {
34+
50: Color(0xff8d8d8d),
35+
100: Color(0xff838383),
36+
200: Color(0xff6e6e6e),
37+
300: Color(0xff595959),
38+
400: Color(0xff454545),
39+
500: Color(0xff303030),
40+
600: Color(0xff2b2b2b),
41+
700: Color(0xff262626),
42+
800: Color(0xff222222),
43+
900: Color(0xff1d1d1d)
44+
});
45+
46+
// #3880ff
47+
static MaterialColor primaryColor = MaterialColor(4281893119, {
48+
50: Color(0xff92b9ff),
49+
100: Color(0xff88b3ff),
50+
200: Color(0xff74a6ff),
51+
300: Color(0xff6099ff),
52+
400: Color(0xff4c8dff),
53+
500: Color(0xff3880ff),
54+
600: Color(0xff3273e5),
55+
700: Color(0xff2d66cc),
56+
800: Color(0xff275ab2),
57+
900: Color(0xff224d99)
58+
});
59+
60+
// #eb445a
61+
static MaterialColor secondaryColor = MaterialColor(4293608538, {
62+
50: Color(0xfff498a4),
63+
100: Color(0xfff38f9c),
64+
200: Color(0xfff17c8c),
65+
300: Color(0xffef697b),
66+
400: Color(0xffed576a),
67+
500: Color(0xffeb445a),
68+
600: Color(0xffd33d51),
69+
700: Color(0xffbc3648),
70+
800: Color(0xffa4303f),
71+
900: Color(0xff8d2936)
72+
});
73+
74+
static MaterialColor bg = dark;
75+
static MaterialColor bg_2 = grey;
76+
static MaterialColor fg = light;
77+
}

0 commit comments

Comments
 (0)