Skip to content

Commit

Permalink
Improve pure dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
lomirus committed Dec 13, 2023
1 parent 8177eda commit b17032e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/libs/misc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dynamic tryParseString(String str) {
}

String colorToHex(Color color) {
return "#${color.toString().substring(10, 16)}";
return "#${color.value.toRadixString(16).substring(2)}";
}

extension StringExtension on String {
Expand Down
36 changes: 23 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ Future<int> getInitialDarkTheme() async {
}
}

ColorScheme createPureDarkColorScheme() {
ColorScheme baseColorScheme = ThemeData(
colorSchemeSeed: Colors.deepPurple,
brightness: Brightness.dark,
useMaterial3: true,
).colorScheme;
return ColorScheme(
brightness: baseColorScheme.brightness,
primary: baseColorScheme.primary,
onPrimary: baseColorScheme.onPrimary,
secondary: baseColorScheme.secondary,
onSecondary: baseColorScheme.onSecondary,
error: baseColorScheme.error,
onError: baseColorScheme.onError,
background: Colors.black,
onBackground: baseColorScheme.onBackground,
surface: Colors.black,
onSurface: baseColorScheme.onSurface,
);
}

class App extends StatelessWidget {
const App({super.key});

Expand All @@ -53,19 +74,8 @@ class App extends StatelessWidget {
),
darkTheme: theme.darkTheme == 2
? ThemeData(
colorScheme: const ColorScheme(
brightness: Brightness.dark,
primary: Colors.grey,
onPrimary: Colors.grey,
secondary: Colors.black,
onSecondary: Colors.grey,
error: Colors.grey,
onError: Colors.grey,
background: Colors.black,
onBackground: Colors.grey,
surface: Colors.black,
onSurface: Colors.grey,
),
colorScheme: createPureDarkColorScheme(),
brightness: Brightness.dark,
useMaterial3: true,
)
: ThemeData(
Expand Down

0 comments on commit b17032e

Please sign in to comment.