fluffychat/lib/config/themes.dart

107 lines
3.6 KiB
Dart
Raw Normal View History

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