fluffychat/lib/config/themes.dart

73 lines
2.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
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;
static bool isColumnMode(BuildContext context) =>
MediaQuery.of(context).size.width > columnWidth * 2;
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 ThemeData buildTheme(Brightness brightness,
[ColorScheme? colorScheme]) =>
ThemeData(
visualDensity: VisualDensity.standard,
2022-05-18 08:54:50 +02:00
useMaterial3: true,
brightness: brightness,
2022-05-18 12:13:59 +02:00
colorSchemeSeed: AppConfig.colorSchemeSeed ??
colorScheme?.primary ??
AppConfig.chatColor,
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-07-07 18:50:13 +02:00
inputDecorationTheme: const InputDecorationTheme(
border: UnderlineInputBorder(borderSide: BorderSide(width: 1)),
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: brightness == Brightness.light
? SystemUiOverlayStyle.dark
: SystemUiOverlayStyle.light,
),
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
}