loris/lib/themes/themes.dart

271 lines
8.6 KiB
Dart
Raw Normal View History

2022-07-02 17:32:44 +00:00
import 'package:flutter/material.dart';
2022-07-02 22:03:10 +00:00
import 'dracula.dart' as color_dracula;
2022-09-02 21:19:25 +00:00
import 'tess.dart' as color_tess;
import 'adwaita.dart' as color_adwaita;
2022-09-02 21:47:22 +00:00
import 'gruvbox.dart' as color_gruvbox;
2022-09-05 17:01:04 +00:00
import 'fourth_website.dart' as color_fourth;
2022-09-11 20:29:41 +00:00
import 'second.dart' as color_second;
import 'first.dart' as color_first;
2022-07-02 17:32:44 +00:00
bool checkActive(Set<MaterialState> states) {
return states.intersection({
MaterialState.focused,
MaterialState.hovered,
MaterialState.pressed
}).isNotEmpty;
}
const defaultRadius = Radius.circular(8);
2022-09-26 14:30:02 +00:00
const defaultSeperatorHeight = 4.0;
const defaultInsideMargins = EdgeInsets.all(18);
2022-09-26 17:16:11 +00:00
const defaultMargins = EdgeInsets.fromLTRB(18, 8, 18, 8);
2022-08-12 19:30:58 +00:00
// color schemes to pick from can be added here
// there is a class to create these
2022-09-02 21:19:25 +00:00
final available = [
color_dracula.theme,
color_adwaita.themeDark,
color_adwaita.themeLight,
color_tess.theme,
2022-09-02 21:47:22 +00:00
color_gruvbox.themeDark,
color_gruvbox.themeLight,
2022-09-11 20:29:41 +00:00
color_first.theme,
color_second.theme,
2022-09-05 17:01:04 +00:00
color_fourth.theme,
2022-09-02 21:19:25 +00:00
];
2022-07-02 22:03:10 +00:00
ThemeData getTheme(CustomColors colors) {
return ThemeData(
applyElevationOverlayColor: false,
2022-09-26 10:04:53 +00:00
floatingActionButtonTheme: FloatingActionButtonThemeData(
hoverColor: colors.colorScheme.onSurface,
2022-08-29 21:16:13 +00:00
elevation: 0,
enableFeedback: false,
hoverElevation: 0,
2022-08-29 21:16:13 +00:00
),
2022-08-12 18:26:38 +00:00
fontFamily: 'Atkinson',
textTheme: TextTheme(
bodyLarge: TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 24,
),
bodyMedium: TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 18,
),
bodySmall: TextStyle(
2022-08-12 19:30:58 +00:00
color: colors.colorScheme.secondary,
2022-08-26 22:29:36 +00:00
fontSize: 18,
2022-08-12 18:26:38 +00:00
),
displayLarge: TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 42,
fontWeight: FontWeight.w700,
),
displayMedium: TextStyle(
color: colors.colorScheme.onSurface,
fontWeight: FontWeight.w700,
fontSize: 36,
),
displaySmall: TextStyle(
color: colors.colorScheme.onSurface,
fontWeight: FontWeight.w700,
fontSize: 24,
),
headlineLarge: TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 42,
),
headlineMedium: TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 36,
),
headlineSmall: TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 24,
),
),
2022-08-12 19:30:58 +00:00
iconTheme: IconThemeData(
2022-08-27 22:29:17 +00:00
size: 24,
2022-08-12 19:30:58 +00:00
color: colors.colorScheme.onSurface,
),
2022-09-05 19:40:56 +00:00
elevatedButtonTheme: ElevatedButtonThemeData(
2022-09-26 09:50:00 +00:00
style: ButtonStyle(
shadowColor: MaterialStateProperty.all(Colors.transparent),
shape: MaterialStateProperty.resolveWith((states) {
if (checkActive(states)) {
return RoundedRectangleBorder(
borderRadius: const BorderRadius.all(defaultRadius),
2022-09-27 19:49:11 +00:00
side: BorderSide(color: colors.colorScheme.primary, width: 2),
);
}
return const RoundedRectangleBorder(
borderRadius: BorderRadius.all(defaultRadius));
}),
elevation: MaterialStateProperty.all(0),
2022-09-26 10:04:53 +00:00
foregroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) {
return colors.colorScheme.surface;
}
if (checkActive(states)) return colors.colorScheme.primary;
2022-09-26 10:04:53 +00:00
return null;
}),
backgroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) return colors.hintColor;
if (checkActive(states)) return colors.colorScheme.onPrimary;
2022-09-26 10:04:53 +00:00
return null;
}),
overlayColor: MaterialStateProperty.all(Colors.transparent),
2022-09-26 09:50:00 +00:00
textStyle: MaterialStateProperty.resolveWith((states) =>
const TextStyle(
fontSize: 18,
fontFamily: "atkinson",
fontWeight: FontWeight.w700)),
2022-09-05 19:40:56 +00:00
),
2022-09-06 08:30:41 +00:00
),
2022-08-12 19:30:58 +00:00
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
colors.colorScheme.primary,
),
foregroundColor: MaterialStateProperty.all(
colors.colorScheme.onPrimary,
),
textStyle: MaterialStateProperty.all(
const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
),
),
2022-08-12 18:26:38 +00:00
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
shape: MaterialStateProperty.all(const RoundedRectangleBorder(
borderRadius: BorderRadius.all(defaultRadius))),
shadowColor: MaterialStateProperty.all(Colors.transparent),
backgroundColor: MaterialStateProperty.resolveWith((states) {
if (checkActive(states)) return colors.colorScheme.primary;
return null;
}),
foregroundColor: MaterialStateProperty.resolveWith((states) {
if (checkActive(states)) return colors.colorScheme.onPrimary;
return null;
}),
2022-08-12 18:26:38 +00:00
textStyle: MaterialStateProperty.all(
const TextStyle(fontSize: 18),
),
),
),
popupMenuTheme: PopupMenuThemeData(
color: colors.colorScheme.background,
textStyle: TextStyle(
color: colors.colorScheme.onBackground,
),
),
2022-07-02 22:03:10 +00:00
scaffoldBackgroundColor: colors.colorScheme.background,
bottomAppBarColor: colors.colorScheme.background,
hintColor: colors.hintColor,
colorScheme: colors.colorScheme,
errorColor: colors.colorScheme.error,
bottomAppBarTheme: BottomAppBarTheme(
elevation: 0,
2022-07-02 22:03:10 +00:00
color: colors.colorScheme.surface,
),
2022-08-12 18:26:38 +00:00
navigationBarTheme: NavigationBarThemeData(
2022-09-26 17:16:11 +00:00
indicatorShape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(defaultRadius),
),
2022-08-12 19:30:58 +00:00
labelTextStyle: MaterialStateProperty.all(
TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 14,
),
),
2022-07-02 22:03:10 +00:00
backgroundColor: Colors.transparent,
2022-09-26 17:16:11 +00:00
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
indicatorColor: colors.hoverColor,
2022-07-02 22:03:10 +00:00
elevation: 0,
2022-09-26 17:16:11 +00:00
height: 52,
2022-07-02 22:03:10 +00:00
),
2022-08-12 19:30:58 +00:00
scrollbarTheme: ScrollbarThemeData(
thumbColor: MaterialStateProperty.all(colors.hintColor),
),
2022-08-12 22:28:00 +00:00
sliderTheme: SliderThemeData(
valueIndicatorColor: colors.colorScheme.primary,
valueIndicatorTextStyle: TextStyle(
color: colors.colorScheme.onPrimary,
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
tooltipTheme: TooltipThemeData(
textStyle: TextStyle(
color: colors.colorScheme.onPrimary,
fontSize: 18,
fontWeight: FontWeight.w700,
),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(defaultRadius),
color: colors.colorScheme.primary,
),
),
2022-08-15 13:08:37 +00:00
canvasColor: colors.colorScheme.surface,
dialogTheme: DialogTheme(
elevation: 0,
backgroundColor: colors.colorScheme.surface,
2022-09-26 14:30:02 +00:00
shape: RoundedRectangleBorder(
side: BorderSide(
width: 2,
color: colors.colorScheme.secondary,
style: BorderStyle.solid),
borderRadius: const BorderRadius.all(defaultRadius))),
2022-08-15 13:08:37 +00:00
selectedRowColor: colors.colorScheme.background,
textSelectionTheme:
TextSelectionThemeData(selectionColor: colors.hintColor),
2022-08-27 22:29:17 +00:00
primaryIconTheme: const IconThemeData(size: 24),
2022-09-11 20:29:41 +00:00
hoverColor: colors.hoverColor,
2022-09-26 14:30:02 +00:00
shadowColor: Colors.transparent,
2022-09-11 20:29:41 +00:00
focusColor: colors.hoverColor,
2022-08-29 21:16:13 +00:00
indicatorColor: colors.hintColor,
disabledColor: colors.hintColor,
unselectedWidgetColor: colors.hintColor,
toggleableActiveColor: colors.colorScheme.primary,
splashColor: colors.colorScheme.onSurface,
2022-09-26 10:31:32 +00:00
splashFactory: NoSplash.splashFactory,
2022-08-29 21:16:13 +00:00
highlightColor: colors.hintColor,
inputDecorationTheme: InputDecorationTheme(
2022-09-02 21:19:25 +00:00
helperStyle: TextStyle(
color: colors.hintColor,
),
hintStyle: TextStyle(
color: colors.hintColor,
),
2022-08-29 21:16:13 +00:00
fillColor: colors.colorScheme.background,
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: colors.hintColor,
width: 2,
),
),
),
2022-09-05 17:01:04 +00:00
progressIndicatorTheme: ProgressIndicatorThemeData(
color: colors.colorScheme.primary,
refreshBackgroundColor: colors.hintColor,
linearTrackColor: colors.hintColor,
circularTrackColor: colors.hintColor,
),
2022-07-02 22:03:10 +00:00
);
}
class CustomColors {
late String name;
late Color hintColor;
2022-09-11 20:29:41 +00:00
// must be set for twilight themes
late Color hoverColor;
2022-07-02 22:03:10 +00:00
late ColorScheme colorScheme;
2022-09-11 20:29:41 +00:00
CustomColors(this.name, this.hintColor, this.colorScheme, this.hoverColor);
2022-07-02 22:03:10 +00:00
}