fluffychat/lib/config/themes.dart

238 lines
8.2 KiB
Dart
Raw Normal View History

2021-09-18 11:08:00 +02:00
import 'package:flutter/cupertino.dart';
2021-01-15 19:41:55 +01:00
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
2021-01-20 11:07:08 +01:00
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/services.dart';
2021-01-15 19:41:55 +01:00
2021-04-09 16:29:48 +02:00
import 'app_config.dart';
2021-01-24 16:38:25 +01:00
2021-01-15 19:41:55 +01:00
abstract class FluffyThemes {
2021-01-16 12:46:38 +01:00
static const double columnWidth = 360.0;
static bool isColumnMode(BuildContext context) =>
MediaQuery.of(context).size.width > columnWidth * 2;
2021-01-20 11:07:08 +01:00
2021-04-14 10:37:15 +02:00
static const fallbackTextStyle =
2021-10-10 03:42:48 +02:00
TextStyle(fontFamily: 'Roboto', fontFamilyFallback: ['NotoEmoji']);
2021-01-20 11:07:08 +01:00
static var fallback_text_theme = PlatformInfos.isDesktop
? TextTheme(
2021-04-14 10:37:15 +02:00
bodyText1: fallbackTextStyle,
bodyText2: fallbackTextStyle,
button: fallbackTextStyle,
caption: fallbackTextStyle,
overline: fallbackTextStyle,
headline1: fallbackTextStyle,
headline2: fallbackTextStyle,
headline3: fallbackTextStyle,
headline4: fallbackTextStyle,
headline5: fallbackTextStyle,
headline6: fallbackTextStyle,
subtitle1: fallbackTextStyle,
subtitle2: fallbackTextStyle)
2021-01-20 11:07:08 +01:00
: TextTheme();
2021-01-15 19:41:55 +01:00
static ThemeData light = ThemeData(
2021-03-04 12:28:06 +01:00
visualDensity: VisualDensity.standard,
2021-01-15 19:41:55 +01:00
primaryColorDark: Colors.white,
primaryColorLight: Color(0xff121212),
brightness: Brightness.light,
2021-01-24 16:38:25 +01:00
primaryColor: AppConfig.primaryColor,
2021-05-24 10:59:00 +02:00
colorScheme: ThemeData.light().colorScheme.copyWith(
primary: AppConfig.primaryColor,
secondary: AppConfig.primaryColor,
secondaryVariant: AppConfig.secondaryColor,
2021-05-24 10:59:00 +02:00
),
2021-01-15 19:41:55 +01:00
backgroundColor: Colors.white,
2021-09-02 09:38:44 +02:00
secondaryHeaderColor: Color(0xffeeeffe),
2021-01-15 19:41:55 +01:00
scaffoldBackgroundColor: Colors.white,
2021-01-20 11:07:08 +01:00
textTheme: Typography.material2018().black.merge(fallback_text_theme),
2021-05-22 10:40:34 +02:00
snackBarTheme: SnackBarThemeData(behavior: SnackBarBehavior.floating),
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.fuchsia: ZoomPageTransitionsBuilder(),
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.linux: CupertinoPageTransitionsBuilder(),
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.windows: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
2021-01-15 19:41:55 +01:00
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
2021-02-07 09:12:34 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-01-15 19:41:55 +01:00
),
),
2021-06-06 16:55:31 +02:00
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
),
),
2021-01-15 19:41:55 +01:00
popupMenuTheme: PopupMenuThemeData(
2021-05-31 19:33:40 +02:00
elevation: 4,
2021-01-15 19:41:55 +01:00
shape: RoundedRectangleBorder(
2021-02-07 09:12:34 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-01-15 19:41:55 +01:00
),
),
2021-01-24 16:38:25 +01:00
floatingActionButtonTheme: FloatingActionButtonThemeData(
backgroundColor: AppConfig.primaryColor,
foregroundColor: Colors.white,
),
2021-03-04 12:28:06 +01:00
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
primary: AppConfig.primaryColor,
onPrimary: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
padding: EdgeInsets.all(12),
),
),
2021-04-09 14:56:23 +02:00
cardTheme: CardTheme(
2021-05-31 21:17:00 +02:00
elevation: 4,
2021-04-09 14:56:23 +02:00
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
clipBehavior: Clip.hardEdge,
),
2021-01-24 17:26:59 +01:00
inputDecorationTheme: InputDecorationTheme(
2021-02-07 09:12:34 +01:00
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius)),
2021-02-03 15:05:05 +01:00
enabledBorder: OutlineInputBorder(
2021-02-07 09:12:34 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-02-03 15:05:05 +01:00
borderSide: BorderSide(
2021-02-07 09:31:24 +01:00
color: lighten(AppConfig.primaryColor, .51),
2021-02-03 15:05:05 +01:00
),
),
2021-01-24 17:26:59 +01:00
filled: true,
2021-02-07 09:31:24 +01:00
fillColor: lighten(AppConfig.primaryColor, .51),
2021-01-24 17:26:59 +01:00
),
2021-01-15 19:41:55 +01:00
appBarTheme: AppBarTheme(
2021-05-30 15:37:39 +02:00
elevation: 2,
2021-09-13 17:41:53 +02:00
systemOverlayStyle: SystemUiOverlayStyle.dark,
2021-09-14 08:50:25 +02:00
backgroundColor: Colors.white,
2021-09-13 17:41:53 +02:00
titleTextStyle: TextStyle(
color: Colors.black,
fontSize: 20,
2021-01-15 19:41:55 +01:00
),
iconTheme: IconThemeData(color: Colors.black),
),
);
2021-01-24 16:45:05 +01:00
static ThemeData dark = ThemeData.dark().copyWith(
2021-03-04 12:28:06 +01:00
visualDensity: VisualDensity.standard,
2021-01-15 19:41:55 +01:00
primaryColorDark: Color(0xff121212),
primaryColorLight: Colors.white,
2021-01-24 17:37:55 +01:00
primaryColor: AppConfig.primaryColor,
2021-01-15 19:41:55 +01:00
errorColor: Color(0xFFCF6679),
backgroundColor: Colors.black,
scaffoldBackgroundColor: Colors.black,
2021-05-24 10:59:00 +02:00
colorScheme: ThemeData.dark().colorScheme.copyWith(
primary: AppConfig.primaryColorLight,
secondary: AppConfig.primaryColorLight,
secondaryVariant: AppConfig.secondaryColor,
2021-05-24 10:59:00 +02:00
),
2021-09-02 09:38:44 +02:00
secondaryHeaderColor: Color(0xff232543),
2021-01-20 11:07:08 +01:00
textTheme: Typography.material2018().white.merge(fallback_text_theme),
2021-01-24 16:45:05 +01:00
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
2021-02-07 09:12:34 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-01-24 16:45:05 +01:00
),
),
popupMenuTheme: PopupMenuThemeData(
shape: RoundedRectangleBorder(
2021-02-07 09:12:34 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-01-24 16:45:05 +01:00
),
),
2021-04-09 14:56:23 +02:00
cardTheme: CardTheme(
elevation: 7,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
clipBehavior: Clip.hardEdge,
),
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.fuchsia: ZoomPageTransitionsBuilder(),
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.linux: CupertinoPageTransitionsBuilder(),
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.windows: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
2021-01-24 16:45:05 +01:00
floatingActionButtonTheme: FloatingActionButtonThemeData(
backgroundColor: AppConfig.primaryColor,
foregroundColor: Colors.white,
),
2021-01-24 17:37:55 +01:00
inputDecorationTheme: InputDecorationTheme(
2021-02-07 09:12:34 +01:00
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius)),
2021-01-24 17:37:55 +01:00
filled: true,
2021-02-07 09:31:24 +01:00
fillColor: FluffyThemes.darken(AppConfig.primaryColorLight, .71),
2021-02-03 15:05:05 +01:00
enabledBorder: OutlineInputBorder(
2021-02-07 09:12:34 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-02-03 15:05:05 +01:00
borderSide: BorderSide(
2021-02-07 09:31:24 +01:00
color: FluffyThemes.darken(AppConfig.primaryColor, .31),
2021-02-03 15:05:05 +01:00
),
),
2021-01-24 17:37:55 +01:00
),
2021-06-06 16:55:31 +02:00
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
),
),
2021-04-09 14:56:23 +02:00
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
primary: AppConfig.primaryColor,
onPrimary: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
padding: EdgeInsets.all(12),
),
),
2021-05-22 10:40:34 +02:00
snackBarTheme: SnackBarThemeData(behavior: SnackBarBehavior.floating),
2021-01-15 19:41:55 +01:00
appBarTheme: AppBarTheme(
2021-05-30 15:37:39 +02:00
elevation: 2,
2021-09-13 17:41:53 +02:00
systemOverlayStyle: SystemUiOverlayStyle.light,
2021-09-14 08:50:25 +02:00
backgroundColor: Color(0xff1D1D1D),
2021-09-13 17:41:53 +02:00
titleTextStyle: TextStyle(
color: Colors.white,
fontSize: 20,
2021-01-15 19:41:55 +01:00
),
iconTheme: IconThemeData(color: Colors.white),
),
2021-09-18 11:08:00 +02:00
cupertinoOverrideTheme: const CupertinoThemeData(
textTheme: CupertinoTextThemeData(),
),
2021-01-15 19:41:55 +01:00
);
static Color blackWhiteColor(BuildContext context) =>
Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.black;
2021-02-07 09:31:24 +01:00
static Color darken(Color color, [double amount = .1]) {
assert(amount >= 0 && amount <= 1);
final hsl = HSLColor.fromColor(color);
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
return hslDark.toColor();
}
static Color lighten(Color color, [double amount = .1]) {
assert(amount >= 0 && amount <= 1);
final hsl = HSLColor.fromColor(color);
final hslLight =
hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
return hslLight.toColor();
}
2021-01-15 19:41:55 +01:00
}