2021-07-13 00:47:26 +00:00
|
|
|
import 'package:flowy_infra/color.dart';
|
2021-06-19 15:41:19 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
enum ThemeType {
|
|
|
|
light,
|
|
|
|
dark,
|
|
|
|
}
|
|
|
|
|
|
|
|
class AppTheme {
|
|
|
|
static ThemeType defaultTheme = ThemeType.light;
|
|
|
|
|
|
|
|
bool isDark;
|
|
|
|
late Color surface; //
|
2021-09-05 10:02:49 +00:00
|
|
|
late Color hover;
|
|
|
|
late Color selector;
|
|
|
|
late Color red;
|
|
|
|
late Color yellow;
|
|
|
|
late Color green;
|
|
|
|
|
|
|
|
late Color shader1;
|
|
|
|
late Color shader2;
|
|
|
|
late Color shader3;
|
|
|
|
late Color shader4;
|
|
|
|
late Color shader5;
|
|
|
|
late Color shader6;
|
|
|
|
late Color shader7;
|
|
|
|
|
|
|
|
late Color bg1;
|
|
|
|
late Color bg2;
|
|
|
|
late Color bg3;
|
|
|
|
late Color bg4;
|
|
|
|
|
|
|
|
late Color tint1;
|
|
|
|
late Color tint2;
|
|
|
|
late Color tint3;
|
|
|
|
late Color tint4;
|
|
|
|
late Color tint5;
|
|
|
|
late Color tint6;
|
|
|
|
late Color tint7;
|
|
|
|
late Color tint8;
|
|
|
|
late Color tint9;
|
|
|
|
|
|
|
|
late Color main1;
|
|
|
|
late Color main2;
|
|
|
|
|
2021-06-19 15:41:19 +00:00
|
|
|
/// Default constructor
|
2021-09-05 14:52:20 +00:00
|
|
|
AppTheme({this.isDark = true});
|
2021-06-19 15:41:19 +00:00
|
|
|
|
|
|
|
/// fromType factory constructor
|
|
|
|
factory AppTheme.fromType(ThemeType t) {
|
|
|
|
switch (t) {
|
|
|
|
case ThemeType.light:
|
|
|
|
return AppTheme(isDark: false)
|
|
|
|
..surface = Colors.white
|
2021-09-05 10:02:49 +00:00
|
|
|
..hover = const Color(0xFFe0f8ff) //
|
|
|
|
..selector = const Color(0xfff2fcff)
|
|
|
|
..red = const Color(0xfffb006d)
|
|
|
|
..yellow = const Color(0xffffd667)
|
|
|
|
..green = const Color(0xff66cf80)
|
|
|
|
..shader1 = const Color(0xff333333)
|
|
|
|
..shader2 = const Color(0xff4f4f4f)
|
|
|
|
..shader3 = const Color(0xff828282)
|
|
|
|
..shader4 = const Color(0xffbdbdbd)
|
|
|
|
..shader5 = const Color(0xffe0e0e0)
|
|
|
|
..shader6 = const Color(0xfff2f2f2)
|
|
|
|
..shader7 = const Color(0xffffffff)
|
|
|
|
..bg1 = const Color(0xfff7f8fc)
|
|
|
|
..bg2 = const Color(0xffedeef2)
|
|
|
|
..bg3 = const Color(0xffe2e4eb)
|
|
|
|
..bg4 = const Color(0xff2c144b)
|
|
|
|
..tint1 = const Color(0xffe8e0ff)
|
|
|
|
..tint2 = const Color(0xffffe7fd)
|
|
|
|
..tint3 = const Color(0xffffe7ee)
|
|
|
|
..tint4 = const Color(0xffffefe3)
|
|
|
|
..tint5 = const Color(0xfffff2cd)
|
|
|
|
..tint6 = const Color(0xfff5ffdc)
|
|
|
|
..tint7 = const Color(0xffddffd6)
|
|
|
|
..tint8 = const Color(0xffdefff1)
|
|
|
|
..tint9 = const Color(0xffdefff1)
|
|
|
|
..main1 = const Color(0xff00bcf0)
|
|
|
|
..main2 = const Color(0xff00b7ea);
|
2021-06-19 15:41:19 +00:00
|
|
|
|
|
|
|
case ThemeType.dark:
|
|
|
|
return AppTheme(isDark: true)
|
|
|
|
..surface = const Color(0xff252525)
|
2021-09-05 10:02:49 +00:00
|
|
|
..hover = const Color(0xFFe0f8ff) //
|
|
|
|
..selector = const Color(0xfff2fcff)
|
|
|
|
..red = const Color(0xfffb006d)
|
|
|
|
..yellow = const Color(0xffffd667)
|
|
|
|
..green = const Color(0xff66cf80)
|
|
|
|
..shader1 = const Color(0xff333333)
|
|
|
|
..shader2 = const Color(0xff4f4f4f)
|
|
|
|
..shader3 = const Color(0xff828282)
|
|
|
|
..shader4 = const Color(0xffbdbdbd)
|
|
|
|
..shader5 = const Color(0xffe0e0e0)
|
|
|
|
..shader6 = const Color(0xfff2f2f2)
|
|
|
|
..shader7 = const Color(0xffffffff)
|
|
|
|
..bg1 = const Color(0xfff7f8fc)
|
|
|
|
..bg2 = const Color(0xffedeef2)
|
|
|
|
..bg3 = const Color(0xffe2e4eb)
|
|
|
|
..bg4 = const Color(0xff2c144b)
|
|
|
|
..tint1 = const Color(0xffe8e0ff)
|
|
|
|
..tint2 = const Color(0xffffe7fd)
|
|
|
|
..tint3 = const Color(0xffffe7ee)
|
|
|
|
..tint4 = const Color(0xffffefe3)
|
|
|
|
..tint5 = const Color(0xfffff2cd)
|
|
|
|
..tint6 = const Color(0xfff5ffdc)
|
|
|
|
..tint7 = const Color(0xffddffd6)
|
|
|
|
..tint8 = const Color(0xffdefff1)
|
|
|
|
..tint9 = const Color(0xffdefff1)
|
|
|
|
..main1 = const Color(0xff00bcf0)
|
|
|
|
..main2 = const Color(0xff00b7ea);
|
2021-06-19 15:41:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ThemeData get themeData {
|
2021-09-05 14:52:20 +00:00
|
|
|
var t = ThemeData(
|
2021-06-19 15:41:19 +00:00
|
|
|
textTheme: (isDark ? ThemeData.dark() : ThemeData.light()).textTheme,
|
2021-09-05 14:52:20 +00:00
|
|
|
textSelectionTheme: TextSelectionThemeData(cursorColor: main1),
|
2021-06-19 15:41:19 +00:00
|
|
|
colorScheme: ColorScheme(
|
|
|
|
brightness: isDark ? Brightness.dark : Brightness.light,
|
2021-09-05 10:02:49 +00:00
|
|
|
primary: main1,
|
|
|
|
primaryVariant: main2,
|
|
|
|
secondary: bg1,
|
|
|
|
secondaryVariant: bg2,
|
2021-06-19 15:41:19 +00:00
|
|
|
background: bg1,
|
|
|
|
surface: surface,
|
2021-09-05 10:02:49 +00:00
|
|
|
onBackground: bg1,
|
2021-09-05 14:52:20 +00:00
|
|
|
onSurface: surface,
|
2021-09-05 10:02:49 +00:00
|
|
|
onError: red,
|
|
|
|
onPrimary: bg1,
|
|
|
|
onSecondary: bg1,
|
2021-09-05 14:52:20 +00:00
|
|
|
error: red),
|
2021-06-19 15:41:19 +00:00
|
|
|
);
|
2021-09-05 14:52:20 +00:00
|
|
|
|
2021-06-19 15:41:19 +00:00
|
|
|
return t.copyWith(
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
2021-09-05 10:02:49 +00:00
|
|
|
highlightColor: main1,
|
2021-09-05 14:52:20 +00:00
|
|
|
indicatorColor: main1,
|
2021-09-05 10:02:49 +00:00
|
|
|
toggleableActiveColor: main1);
|
2021-06-19 15:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Color shift(Color c, double d) =>
|
|
|
|
ColorUtils.shiftHsl(c, d * (isDark ? -1 : 1));
|
|
|
|
}
|