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
|
|
|
|
2023-03-15 21:07:36 +01:00
|
|
|
static const double navRailWidth = 64.0;
|
|
|
|
|
|
|
|
static bool isColumnModeByWidth(double width) =>
|
|
|
|
width > columnWidth * 2 + navRailWidth;
|
2022-08-30 20:24:36 +02:00
|
|
|
|
2021-09-19 13:48:23 +02:00
|
|
|
static bool isColumnMode(BuildContext context) =>
|
2022-08-30 20:24:36 +02:00
|
|
|
isColumnModeByWidth(MediaQuery.of(context).size.width);
|
|
|
|
|
|
|
|
static bool getDisplayNavigationRail(BuildContext context) =>
|
2022-09-11 11:07:04 +02:00
|
|
|
!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
|
|
|
|
2021-12-25 18:52:38 +01:00
|
|
|
static var fallbackTextTheme = const TextTheme(
|
2023-01-26 09:47:30 +01: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-12-25 18:52:38 +01:00
|
|
|
);
|
2021-01-20 11:07:08 +01:00
|
|
|
|
2023-01-07 09:22:31 +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]) =>
|
2022-08-19 08:32:08 +02:00
|
|
|
ThemeData(
|
2021-11-13 17:57:55 +01:00
|
|
|
visualDensity: VisualDensity.standard,
|
2022-05-18 08:54:50 +02:00
|
|
|
useMaterial3: true,
|
2022-08-19 08:32:08 +02:00
|
|
|
brightness: brightness,
|
2022-12-24 11:48:48 +01:00
|
|
|
colorSchemeSeed: seed ?? AppConfig.colorSchemeSeed,
|
2023-02-07 12:24:22 +01:00
|
|
|
textTheme: PlatformInfos.isDesktop || PlatformInfos.isWeb
|
2022-08-21 07:29:03 +02:00
|
|
|
? brightness == Brightness.light
|
|
|
|
? Typography.material2018().black.merge(fallbackTextTheme)
|
|
|
|
: Typography.material2018().white.merge(fallbackTextTheme)
|
2021-12-25 18:52:38 +01:00
|
|
|
: null,
|
2022-07-07 18:50:13 +02:00
|
|
|
snackBarTheme: const SnackBarThemeData(
|
|
|
|
behavior: SnackBarBehavior.floating,
|
|
|
|
),
|
2023-02-03 08:06:38 +01:00
|
|
|
dividerColor: brightness == Brightness.light
|
|
|
|
? Colors.blueGrey.shade50
|
|
|
|
: Colors.blueGrey.shade900,
|
2023-02-02 09:47:35 +01:00
|
|
|
popupMenuTheme: PopupMenuThemeData(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
),
|
|
|
|
),
|
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
|
|
|
),
|
2021-11-13 17:57:55 +01:00
|
|
|
filled: true,
|
|
|
|
),
|
2022-08-05 17:07:46 +02:00
|
|
|
appBarTheme: AppBarTheme(
|
2022-08-19 08:32:08 +02:00
|
|
|
surfaceTintColor:
|
|
|
|
brightness == Brightness.light ? Colors.white : Colors.black,
|
2022-08-05 17:07:46 +02:00
|
|
|
shadowColor: Colors.black.withAlpha(64),
|
2022-08-28 11:39:33 +02:00
|
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
|
|
statusBarColor: Colors.transparent,
|
|
|
|
statusBarIconBrightness: brightness.reversed,
|
|
|
|
statusBarBrightness: brightness,
|
|
|
|
),
|
2021-11-13 17:57:55 +01:00
|
|
|
),
|
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),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-02-05 10:34:50 +01:00
|
|
|
dialogTheme: DialogTheme(
|
|
|
|
shape: RoundedRectangleBorder(
|
2023-02-17 13:01:44 +01:00
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
|
2023-02-05 10:34:50 +01:00
|
|
|
),
|
|
|
|
),
|
2022-08-06 13:35:59 +02:00
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
textStyle: const TextStyle(fontSize: 16),
|
2023-02-17 13:01:44 +01:00
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
),
|
2022-08-06 13:35:59 +02:00
|
|
|
),
|
|
|
|
),
|
2021-11-13 17:57:55 +01:00
|
|
|
);
|
2021-01-15 19:41:55 +01:00
|
|
|
}
|
2022-08-28 11:39:33 +02:00
|
|
|
|
|
|
|
extension on Brightness {
|
|
|
|
Brightness get reversed =>
|
|
|
|
this == Brightness.dark ? Brightness.light : Brightness.dark;
|
|
|
|
}
|