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';
|
2022-08-30 20:24:36 +02:00
|
|
|
import '../widgets/matrix.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;
|
|
|
|
|
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) =>
|
|
|
|
!VRouter.of(context).path.startsWith('/settings') &&
|
|
|
|
(Matrix.of(context).client.rooms.any((room) => room.isSpace) ||
|
|
|
|
AppConfig.separateChatTypes);
|
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(
|
|
|
|
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
|
|
|
|
2022-08-19 08:32:08 +02:00
|
|
|
static ThemeData buildTheme(Brightness brightness,
|
|
|
|
[ColorScheme? colorScheme]) =>
|
|
|
|
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-05-18 12:13:59 +02:00
|
|
|
colorSchemeSeed: AppConfig.colorSchemeSeed ??
|
|
|
|
colorScheme?.primary ??
|
|
|
|
AppConfig.chatColor,
|
2021-12-25 18:52:38 +01:00
|
|
|
textTheme: PlatformInfos.isDesktop
|
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,
|
|
|
|
),
|
2022-08-19 08:32:08 +02:00
|
|
|
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)),
|
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-08-06 13:35:59 +02:00
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
textStyle: const TextStyle(fontSize: 16),
|
|
|
|
),
|
|
|
|
),
|
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;
|
|
|
|
}
|