Skip to content

Commit

Permalink
Added Dark theme with toggle to switch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
VarunS2002 committed Dec 28, 2020
1 parent 1033130 commit 77f671a
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 69 deletions.
56 changes: 40 additions & 16 deletions sudoku/lib/Alerts.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'main.dart';
import 'package:sudoku/Styles.dart';

class AlertGameOver extends StatelessWidget {
static bool newGame = false;
Expand All @@ -10,19 +10,26 @@ class AlertGameOver extends StatelessWidget {
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: Text('Game Over'),
content: Text('You successfully solved the Sudoku'),
backgroundColor: Styles.bg_2,
title: Text(
'Game Over',
style: TextStyle(color: Styles.fg),
),
content: Text(
'You successfully solved the Sudoku',
style: TextStyle(color: Styles.fg),
),
actions: [
FlatButton(
textColor: MyApp.primaryColor,
textColor: Styles.primaryColor,
onPressed: () {
Navigator.pop(context);
restartGame = true;
},
child: Text('Restart Game'),
),
FlatButton(
textColor: MyApp.primaryColor,
textColor: Styles.primaryColor,
onPressed: () {
Navigator.pop(context);
newGame = true;
Expand Down Expand Up @@ -72,7 +79,12 @@ class AlertDifficulty extends State<AlertDifficultyState> {
Widget build(BuildContext context) {
return SimpleDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: Center(child: Text('Select Difficulty Level')),
title: Center(
child: Text(
'Select Difficulty Level',
style: TextStyle(color: Styles.fg),
)),
backgroundColor: Styles.bg_2,
contentPadding: EdgeInsets.fromLTRB(10, 10, 10, 10),
children: <Widget>[
for (String level in difficulties)
Expand All @@ -90,8 +102,8 @@ class AlertDifficulty extends State<AlertDifficultyState> {
style: TextStyle(
fontSize: 15,
color: level == this.currentDifficultyLevel
? MyApp.primaryColor
: Colors.black)),
? Styles.primaryColor
: Styles.fg)),
),
],
);
Expand All @@ -103,18 +115,25 @@ class AlertExit extends StatelessWidget {
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: Text('Exit Game'),
content: Text('Are you sure you want to exit the game ?'),
backgroundColor: Styles.bg_2,
title: Text(
'Exit Game',
style: TextStyle(color: Styles.fg),
),
content: Text(
'Are you sure you want to exit the game ?',
style: TextStyle(color: Styles.fg),
),
actions: [
FlatButton(
textColor: MyApp.primaryColor,
textColor: Styles.primaryColor,
onPressed: () {
Navigator.pop(context);
},
child: Text('No'),
),
FlatButton(
textColor: MyApp.primaryColor,
textColor: Styles.primaryColor,
onPressed: () {
SystemNavigator.pop();
},
Expand Down Expand Up @@ -159,12 +178,12 @@ class AlertNumbers extends State<AlertNumbersState> {
Navigator.pop(context);
})
},
color: Colors.white,
textColor: MyApp.primaryColor,
color: Styles.bg_2,
textColor: Styles.primaryColor,
highlightColor: Colors.blueAccent,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.black,
color: Styles.fg,
width: 1,
style: BorderStyle.solid,
),
Expand Down Expand Up @@ -199,7 +218,12 @@ class AlertNumbers extends State<AlertNumbersState> {
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: Center(child: Text('Choose a Number')),
backgroundColor: Styles.bg_2,
title: Center(
child: Text(
'Choose a Number',
style: TextStyle(color: Styles.fg),
)),
content: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
77 changes: 77 additions & 0 deletions sudoku/lib/Styles.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'package:flutter/material.dart';

class Styles {
// #121212
static MaterialColor dark = MaterialColor(4279374354, {
50: Color(0xff7d7d7d),
100: Color(0xff717171),
200: Color(0xff595959),
300: Color(0xff414141),
400: Color(0xff2a2a2a),
500: Color(0xff121212),
600: Color(0xff101010),
700: Color(0xff0e0e0e),
800: Color(0xff0d0d0d),
900: Color(0xff0b0b0b)
});

// #FFFFFF
static MaterialColor light = MaterialColor(4294967295, {
50: Color(0xffffffff),
100: Color(0xffffffff),
200: Color(0xffffffff),
300: Color(0xffffffff),
400: Color(0xffffffff),
500: Color(0xffffffff),
600: Color(0xffe5e5e5),
700: Color(0xffcccccc),
800: Color(0xffb2b2b2),
900: Color(0xff999999)
});

// 303030
static MaterialColor grey = MaterialColor(4281348144, {
50: Color(0xff8d8d8d),
100: Color(0xff838383),
200: Color(0xff6e6e6e),
300: Color(0xff595959),
400: Color(0xff454545),
500: Color(0xff303030),
600: Color(0xff2b2b2b),
700: Color(0xff262626),
800: Color(0xff222222),
900: Color(0xff1d1d1d)
});

// #3880ff
static MaterialColor primaryColor = MaterialColor(4281893119, {
50: Color(0xff92b9ff),
100: Color(0xff88b3ff),
200: Color(0xff74a6ff),
300: Color(0xff6099ff),
400: Color(0xff4c8dff),
500: Color(0xff3880ff),
600: Color(0xff3273e5),
700: Color(0xff2d66cc),
800: Color(0xff275ab2),
900: Color(0xff224d99)
});

// #eb445a
static MaterialColor secondaryColor = MaterialColor(4293608538, {
50: Color(0xfff498a4),
100: Color(0xfff38f9c),
200: Color(0xfff17c8c),
300: Color(0xffef697b),
400: Color(0xffed576a),
500: Color(0xffeb445a),
600: Color(0xffd33d51),
700: Color(0xffbc3648),
800: Color(0xffa4303f),
900: Color(0xff8d2936)
});

static MaterialColor bg = dark;
static MaterialColor bg_2 = grey;
static MaterialColor fg = light;
}
Loading

0 comments on commit 77f671a

Please sign in to comment.