Solian/lib/theme.dart

44 lines
1.3 KiB
Dart
Raw Normal View History

2024-05-18 10:17:16 +00:00
import 'package:flutter/material.dart';
2024-06-22 15:59:11 +00:00
import 'package:solian/platform.dart';
2024-05-18 10:17:16 +00:00
2024-07-30 18:44:49 +00:00
ThemeData? currentLightTheme = SolianTheme.build(Brightness.light);
ThemeData? currentDarkTheme = SolianTheme.build(Brightness.dark);
2024-05-18 10:17:16 +00:00
abstract class SolianTheme {
static bool isLargeScreen(BuildContext context) =>
MediaQuery.of(context).size.width > 640;
2024-06-02 14:45:54 +00:00
static bool isExtraLargeScreen(BuildContext context) =>
MediaQuery.of(context).size.width > 720;
2024-06-22 15:59:11 +00:00
static bool isSpecializedMacOS(BuildContext context) =>
PlatformInfo.isMacOS && !SolianTheme.isLargeScreen(context);
static double? titleSpacing(BuildContext context) {
if (SolianTheme.isSpecializedMacOS(context)) {
return 24;
} else {
return SolianTheme.isLargeScreen(context) ? null : 24;
}
}
static double toolbarHeight(BuildContext context) {
if (isLargeScreen(context)) {
return kToolbarHeight;
} else {
return PlatformInfo.isMacOS ? 50 : kToolbarHeight;
}
}
2024-07-30 18:44:49 +00:00
static ThemeData build(Brightness brightness, {Color? seedColor}) {
2024-05-18 10:17:16 +00:00
return ThemeData(
brightness: brightness,
useMaterial3: true,
2024-06-02 14:45:54 +00:00
colorScheme: ColorScheme.fromSeed(
2024-07-30 03:50:26 +00:00
brightness: brightness,
2024-07-30 18:44:49 +00:00
seedColor: seedColor ?? const Color.fromRGBO(154, 98, 91, 1),
2024-07-30 03:50:26 +00:00
),
2024-05-18 10:17:16 +00:00
);
}
2024-06-02 14:45:54 +00:00
}