2021-08-08 23:16:54 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
part 'light.dart';
|
|
|
|
part 'dark.dart';
|
|
|
|
|
|
|
|
abstract class AppTheme {
|
|
|
|
static const ColorSet jishoGreen = ColorSet(
|
|
|
|
foreground: Colors.white,
|
|
|
|
background: Color(0xFF3EDD00),
|
|
|
|
);
|
|
|
|
|
|
|
|
static const Color jishoGrey = Color(0xFF5A5A5B);
|
|
|
|
|
|
|
|
static const ColorSet jishoLabel = ColorSet(
|
|
|
|
foreground: Colors.white,
|
|
|
|
background: Color(0xFF909DC0),
|
|
|
|
);
|
|
|
|
|
|
|
|
static const ColorSet jishoCommon = ColorSet(
|
|
|
|
foreground: Colors.white,
|
|
|
|
background: Color(0xFF8ABC83),
|
|
|
|
);
|
|
|
|
|
|
|
|
ColorSet get kanjiResultColor;
|
|
|
|
|
|
|
|
ColorSet get onyomiColor;
|
|
|
|
ColorSet get kunyomiColor;
|
|
|
|
|
|
|
|
Color get foreground;
|
|
|
|
Color get background;
|
|
|
|
|
|
|
|
ColorSet get menuGreyLight;
|
|
|
|
ColorSet get menuGreyNormal;
|
|
|
|
ColorSet get menuGreyDark;
|
|
|
|
|
|
|
|
ThemeData getMaterialTheme();
|
|
|
|
}
|
|
|
|
|
|
|
|
class ColorSet {
|
|
|
|
final Color foreground;
|
|
|
|
final Color background;
|
|
|
|
|
|
|
|
const ColorSet({
|
|
|
|
required this.foreground,
|
|
|
|
required this.background,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Source: https://blog.usejournal.com/creating-a-custom-color-swatch-in-flutter-554bcdcb27f3
|
|
|
|
MaterialColor createMaterialColor(Color color) {
|
2021-12-01 23:09:53 +01:00
|
|
|
final List<double> strengths = [.05];
|
2021-08-08 23:16:54 +02:00
|
|
|
final swatch = <int, Color>{};
|
2021-12-04 05:22:58 +01:00
|
|
|
final int r = color.red;
|
|
|
|
final int g = color.green;
|
|
|
|
final int b = color.blue;
|
2021-08-08 23:16:54 +02:00
|
|
|
|
|
|
|
for (int i = 1; i < 10; i++) {
|
|
|
|
strengths.add(0.1 * i);
|
|
|
|
}
|
2021-12-01 23:09:53 +01:00
|
|
|
|
|
|
|
for (final strength in strengths) {
|
2021-08-08 23:16:54 +02:00
|
|
|
final double ds = 0.5 - strength;
|
|
|
|
swatch[(strength * 1000).round()] = Color.fromRGBO(
|
|
|
|
r + ((ds < 0 ? r : (255 - r)) * ds).round(),
|
|
|
|
g + ((ds < 0 ? g : (255 - g)) * ds).round(),
|
|
|
|
b + ((ds < 0 ? b : (255 - b)) * ds).round(),
|
|
|
|
1,
|
|
|
|
);
|
2021-12-01 23:09:53 +01:00
|
|
|
}
|
2021-08-08 23:16:54 +02:00
|
|
|
return MaterialColor(color.value, swatch);
|
2021-12-01 23:09:53 +01:00
|
|
|
}
|