fluffychat/lib/config/themes.dart

105 lines
3.5 KiB
Dart
Raw Normal View History

2021-01-15 19:41:55 +01:00
import 'package:flutter/material.dart';
2022-08-27 10:12:40 +02:00
import 'package:flutter/services.dart';
2021-01-15 19:41:55 +01:00
2022-08-30 20:24:36 +02:00
import 'package:vrouter/vrouter.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
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;
2022-08-30 20:24:36 +02:00
static bool isColumnModeByWidth(double width) => width > columnWidth * 2 + 64;
static bool isColumnMode(BuildContext context) =>
2022-08-30 20:24:36 +02:00
isColumnModeByWidth(MediaQuery.of(context).size.width);
static bool getDisplayNavigationRail(BuildContext context) =>
!VRouter.of(context).path.startsWith('/settings');
2021-01-20 11:07:08 +01:00
2022-07-07 18:50:13 +02:00
static const fallbackTextStyle = TextStyle(
fontFamily: 'Roboto',
fontFamilyFallback: ['NotoEmoji'],
);
2022-04-15 11:42:59 +02:00
static var fallbackTextTheme = const TextTheme(
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
static const Duration animationDuration = Duration(milliseconds: 250);
static const Curve animationCurve = Curves.easeInOut;
2022-12-24 11:48:48 +01:00
static ThemeData buildTheme(Brightness brightness, [Color? seed]) =>
ThemeData(
visualDensity: VisualDensity.standard,
2022-05-18 08:54:50 +02:00
useMaterial3: true,
brightness: brightness,
2022-12-24 11:48:48 +01:00
colorSchemeSeed: seed ?? AppConfig.colorSchemeSeed,
textTheme: PlatformInfos.isDesktop
2022-08-21 07:29:03 +02:00
? brightness == Brightness.light
? Typography.material2018().black.merge(fallbackTextTheme)
: Typography.material2018().white.merge(fallbackTextTheme)
: null,
2022-07-07 18:50:13 +02:00
snackBarTheme: const SnackBarThemeData(
behavior: SnackBarBehavior.floating,
),
dividerColor: brightness == Brightness.light
? Colors.blueGrey.shade50
: Colors.blueGrey.shade900,
2022-12-25 10:45:13 +01:00
inputDecorationTheme: InputDecorationTheme(
border: UnderlineInputBorder(
borderSide: BorderSide.none,
2022-12-30 09:12:27 +01:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
2022-12-25 10:45:13 +01:00
),
filled: true,
),
2022-08-05 17:07:46 +02:00
appBarTheme: AppBarTheme(
surfaceTintColor:
brightness == Brightness.light ? Colors.white : Colors.black,
2022-08-05 17:07:46 +02:00
shadowColor: Colors.black.withAlpha(64),
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: brightness.reversed,
statusBarBrightness: brightness,
),
),
2022-12-30 09:12:27 +01:00
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
),
),
),
2022-08-06 13:35:59 +02:00
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(16),
textStyle: const TextStyle(fontSize: 16),
),
),
);
2021-01-15 19:41:55 +01:00
}
extension on Brightness {
Brightness get reversed =>
this == Brightness.dark ? Brightness.light : Brightness.dark;
}