chore: Merge upstream changes --------- Signed-off-by: Krille <c.kussowski@famedly.com> Co-authored-by: krille-chan <christian-kussowski@posteo.de> Co-authored-by: Krille <c.kussowski@famedly.com> Co-authored-by: Linerly <linerly@proton.me> Co-authored-by: Priit Jõerüüt <hwlate@joeruut.com> Co-authored-by: 大王叫我来巡山 <hamburger2048@users.noreply.hosted.weblate.org> Co-authored-by: fadelkon <fadelkon@posteo.net> Co-authored-by: Aindriú Mac Giolla Eoin <aindriu80@gmail.com> Co-authored-by: Edgars Andersons <Edgars+Weblate@gaitenis.id.lv> Co-authored-by: josé m <correoxm@disroot.org> Co-authored-by: Bezruchenko Simon <worcposj44@gmail.com> Co-authored-by: Christian <christian-pauly@posteo.de> Co-authored-by: - <hitekex@yandex.ru> Co-authored-by: Angelo Schirinzi <Odi-3@users.noreply.hosted.weblate.org> Co-authored-by: xabirequejo <xabi.rn@gmail.com> Co-authored-by: Piotr Orzechowski <piotr@orzechowski.tech> Co-authored-by: Rex_sa <rex.sa@pm.me> Co-authored-by: Tewuzij <tenajeza@outlook.com> Co-authored-by: goknarbahceli <goknarbahceli@proton.me> Co-authored-by: தமிழ்நேரம் <anishprabu.t@gmail.com> Co-authored-by: Erin <erin@erindesu.cz> Co-authored-by: EpicKiwi <me@epickiwi.fr> Co-authored-by: Christian Tietze <me@christiantietze.de> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
153 lines
5.1 KiB
Dart
153 lines
5.1 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'app_config.dart';
|
|
|
|
abstract class FluffyThemes {
|
|
static const double columnWidth = 380.0;
|
|
|
|
static const double navRailWidth = 64.0;
|
|
|
|
static bool isColumnModeByWidth(double width) =>
|
|
width > columnWidth * 2 + navRailWidth;
|
|
|
|
static bool isColumnMode(BuildContext context) =>
|
|
isColumnModeByWidth(MediaQuery.of(context).size.width);
|
|
|
|
static bool isThreeColumnMode(BuildContext context) =>
|
|
MediaQuery.of(context).size.width > FluffyThemes.columnWidth * 3.5;
|
|
|
|
static const fallbackTextStyle = TextStyle(
|
|
fontFamily: 'Ubuntu',
|
|
fontFamilyFallback: ['NotoEmoji'],
|
|
);
|
|
|
|
static var fallbackTextTheme = const TextTheme(
|
|
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,
|
|
);
|
|
|
|
static LinearGradient backgroundGradient(
|
|
BuildContext context,
|
|
int alpha,
|
|
) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
return LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
colors: [
|
|
colorScheme.primaryContainer.withAlpha(alpha),
|
|
colorScheme.secondaryContainer.withAlpha(alpha),
|
|
colorScheme.tertiaryContainer.withAlpha(alpha),
|
|
colorScheme.primaryContainer.withAlpha(alpha),
|
|
],
|
|
);
|
|
}
|
|
|
|
static const Duration animationDuration = Duration(milliseconds: 250);
|
|
static const Curve animationCurve = Curves.easeInOut;
|
|
|
|
static ThemeData buildTheme(
|
|
BuildContext context,
|
|
Brightness brightness, [
|
|
Color? seed,
|
|
]) {
|
|
final colorScheme = ColorScheme.fromSeed(
|
|
brightness: brightness,
|
|
seedColor: seed ?? AppConfig.colorSchemeSeed ?? AppConfig.primaryColor,
|
|
);
|
|
final isColumnMode = FluffyThemes.isColumnMode(context);
|
|
return ThemeData(
|
|
visualDensity: VisualDensity.standard,
|
|
useMaterial3: true,
|
|
brightness: brightness,
|
|
colorScheme: colorScheme,
|
|
textTheme: fallbackTextTheme,
|
|
dividerColor: colorScheme.surfaceContainer,
|
|
popupMenuTheme: PopupMenuThemeData(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
),
|
|
),
|
|
segmentedButtonTheme: SegmentedButtonThemeData(
|
|
style: SegmentedButton.styleFrom(
|
|
iconColor: colorScheme.onSurface,
|
|
disabledIconColor: colorScheme.onSurface,
|
|
),
|
|
),
|
|
textSelectionTheme: TextSelectionThemeData(
|
|
selectionColor: colorScheme.onSurface.withAlpha(128),
|
|
selectionHandleColor: colorScheme.secondary,
|
|
),
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
),
|
|
contentPadding: const EdgeInsets.all(12),
|
|
filled: false,
|
|
),
|
|
appBarTheme: AppBarTheme(
|
|
toolbarHeight: isColumnMode ? 72 : 56,
|
|
shadowColor:
|
|
isColumnMode ? colorScheme.surfaceContainer.withAlpha(128) : null,
|
|
surfaceTintColor: isColumnMode ? colorScheme.surface : null,
|
|
backgroundColor: isColumnMode ? colorScheme.surface : null,
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
statusBarColor: Colors.transparent,
|
|
statusBarIconBrightness: brightness.reversed,
|
|
statusBarBrightness: brightness,
|
|
systemNavigationBarIconBrightness: brightness.reversed,
|
|
systemNavigationBarColor: colorScheme.surface,
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: OutlinedButton.styleFrom(
|
|
side: BorderSide(
|
|
width: 1,
|
|
color: colorScheme.primary,
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(color: colorScheme.primary),
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
|
|
),
|
|
),
|
|
),
|
|
snackBarTheme: isColumnMode
|
|
? const SnackBarThemeData(
|
|
behavior: SnackBarBehavior.floating,
|
|
width: FluffyThemes.columnWidth * 1.5,
|
|
)
|
|
: const SnackBarThemeData(behavior: SnackBarBehavior.floating),
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: colorScheme.secondaryContainer,
|
|
foregroundColor: colorScheme.onSecondaryContainer,
|
|
elevation: 0,
|
|
padding: const EdgeInsets.all(16),
|
|
textStyle: const TextStyle(fontSize: 16),
|
|
),
|
|
),
|
|
// #Pangea
|
|
cupertinoOverrideTheme: const CupertinoThemeData(
|
|
textTheme: CupertinoTextThemeData(),
|
|
),
|
|
// Pangea#
|
|
);
|
|
}
|
|
}
|
|
|
|
extension on Brightness {
|
|
Brightness get reversed =>
|
|
this == Brightness.dark ? Brightness.light : Brightness.dark;
|
|
}
|