mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 06:13:42 +00:00
feat: new ui (#1455)
This commit is contained in:
742 files changed
+59951
-5934
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import 'app_design_tokens.dart';
|
||||
import 'app_palette.dart';
|
||||
|
||||
class AppComponentThemes extends StatelessWidget {
|
||||
const AppComponentThemes({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = shad.Theme.of(context);
|
||||
final palette = AppPalette.of(context);
|
||||
return shad.ComponentTheme<shad.FocusOutlineTheme>(
|
||||
data: shad.FocusOutlineTheme(
|
||||
align: 1,
|
||||
border: Border.all(color: theme.colorScheme.ring.withValues(alpha: 0.65), width: 1),
|
||||
),
|
||||
child: shad.ComponentTheme<shad.SecondaryButtonTheme>(
|
||||
data: shad.SecondaryButtonTheme(
|
||||
decoration: (context, states, value) {
|
||||
final decoration = switch (value) {
|
||||
final BoxDecoration decoration => decoration,
|
||||
_ => BoxDecoration(borderRadius: BorderRadius.circular(theme.radiusMd)),
|
||||
};
|
||||
if (states.contains(WidgetState.disabled)) {
|
||||
return decoration.copyWith(color: palette.surfaceSoft);
|
||||
}
|
||||
if (theme.brightness == Brightness.light) {
|
||||
final background = Color.alphaBlend(palette.textPrimary.withValues(alpha: 0.08), palette.surfaceSoft);
|
||||
final hoverBackground = Color.alphaBlend(
|
||||
palette.textPrimary.withValues(alpha: 0.13),
|
||||
palette.surfaceSoft,
|
||||
);
|
||||
return decoration.copyWith(color: states.contains(WidgetState.hovered) ? hoverBackground : background);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
textStyle: (context, states, value) => states.contains(WidgetState.disabled)
|
||||
? value.copyWith(color: palette.textMuted.withValues(alpha: 0.62))
|
||||
: value,
|
||||
iconTheme: (context, states, value) => states.contains(WidgetState.disabled)
|
||||
? value.copyWith(color: palette.textMuted.withValues(alpha: 0.62))
|
||||
: value,
|
||||
),
|
||||
child: shad.ComponentTheme<shad.CheckboxTheme>(
|
||||
data: shad.CheckboxTheme(
|
||||
size: AppDesignTokens.checkboxSize,
|
||||
gap: AppDesignTokens.checkboxLabelGap,
|
||||
borderColor: theme.brightness == Brightness.dark ? palette.textMuted : palette.border,
|
||||
),
|
||||
child: shad.ComponentTheme<shad.ToastTheme>(
|
||||
data: const shad.ToastTheme(toastConstraints: BoxConstraints(maxWidth: 420)),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class AppDesignTokens {
|
||||
const AppDesignTokens._();
|
||||
|
||||
static const double windowHeaderHeight = 30;
|
||||
static const double windowRadius = 12;
|
||||
static const double railWidth = 68;
|
||||
static const double filterSidebarWidth = 192;
|
||||
static const double contentHeaderHeight = 48;
|
||||
static const double taskRowHeight = 72;
|
||||
static const double controlRadius = 4;
|
||||
static const double checkboxSize = 18;
|
||||
static const double checkboxLabelGap = 10;
|
||||
static const double taskDetailsDrawerMinWidth = 440;
|
||||
static const double taskDetailsDrawerMaxWidth = 720;
|
||||
static const double taskDetailsDrawerViewportRatio = 0.42;
|
||||
static const double taskDetailsDesktopPadding = 24;
|
||||
static const double taskDetailsMobilePadding = 16;
|
||||
static const double settingsContentMaxWidth = 920;
|
||||
static const double settingsFormControlWidth = 420;
|
||||
static const double settingsNumberControlWidth = 168;
|
||||
static const double settingsItemMinLabelWidth = 160;
|
||||
|
||||
static const EdgeInsets pagePadding = EdgeInsets.symmetric(horizontal: 32);
|
||||
static const EdgeInsets sidebarPadding = EdgeInsets.symmetric(horizontal: 16);
|
||||
|
||||
static const double space4 = 4;
|
||||
static const double space8 = 8;
|
||||
static const double space12 = 12;
|
||||
static const double space16 = 16;
|
||||
static const double space24 = 24;
|
||||
static const double space32 = 32;
|
||||
|
||||
static double taskDetailsDrawerWidth(double viewportWidth) {
|
||||
return (viewportWidth * taskDetailsDrawerViewportRatio)
|
||||
.clamp(taskDetailsDrawerMinWidth, taskDetailsDrawerMaxWidth)
|
||||
.toDouble();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import 'app_theme_color.dart';
|
||||
|
||||
class AppPalette extends ThemeExtension<AppPalette> {
|
||||
const AppPalette({
|
||||
required this.bg,
|
||||
required this.railBg,
|
||||
required this.sideBg,
|
||||
required this.cardBg,
|
||||
required this.cardHoverBg,
|
||||
required this.surfaceSoft,
|
||||
required this.inputBg,
|
||||
required this.footerBg,
|
||||
required this.border,
|
||||
required this.textPrimary,
|
||||
required this.textSecondary,
|
||||
required this.textMuted,
|
||||
required this.primaryActionBg,
|
||||
required this.primaryActionForeground,
|
||||
required this.primaryActionHoverBg,
|
||||
required this.brand,
|
||||
required this.brandForeground,
|
||||
required this.brandSoft,
|
||||
required this.brandTrack,
|
||||
required this.brandProgress,
|
||||
required this.accent,
|
||||
required this.accentOn,
|
||||
required this.error,
|
||||
required this.success,
|
||||
required this.toggleBg,
|
||||
required this.toggleIcon,
|
||||
required this.itemActiveBg,
|
||||
required this.filterActiveBg,
|
||||
required this.progressTrack,
|
||||
required this.taskCardSelectedBorder,
|
||||
required this.taskCardHoverBg,
|
||||
required this.taskCardAction,
|
||||
required this.taskCardProgressFill,
|
||||
required this.taskCardIconBg,
|
||||
required this.taskCardFailedIconBg,
|
||||
required this.taskMeta,
|
||||
required this.taskMetaSubtle,
|
||||
required this.taskErrorMeta,
|
||||
required this.searchHint,
|
||||
required this.headerDivider,
|
||||
required this.captionButtonHover,
|
||||
required this.captionButtonCloseHover,
|
||||
});
|
||||
|
||||
static const Color lightAccent = Color(0xFF79C476);
|
||||
|
||||
static const light = AppPalette(
|
||||
bg: Color(0xFFF6F8F7),
|
||||
railBg: Color(0xFFE8EEEA),
|
||||
sideBg: Color(0xFFF0F4F1),
|
||||
cardBg: Color(0xFFFFFFFF),
|
||||
cardHoverBg: Color(0xFFF5F7F5),
|
||||
surfaceSoft: Color(0xFFEDF0EE),
|
||||
inputBg: Color(0xFFE7E8E9),
|
||||
footerBg: Color(0xFFF3F4F5),
|
||||
border: Color(0x66C0C9BA),
|
||||
textPrimary: Color(0xFF191C1D),
|
||||
textSecondary: Color(0xFF5F6368),
|
||||
textMuted: Color(0xFF707A6D),
|
||||
primaryActionBg: Color(0xFF191C1D),
|
||||
primaryActionForeground: Color(0xFFFFFFFF),
|
||||
primaryActionHoverBg: Color(0xFF303435),
|
||||
brand: lightAccent,
|
||||
brandForeground: Color(0xFFFFFFFF),
|
||||
brandSoft: Color(0x1479C476),
|
||||
brandTrack: Color(0x2679C476),
|
||||
brandProgress: Color(0xFF79C476),
|
||||
accent: Color(0xFFE7E8E9),
|
||||
accentOn: Color(0xFFF4F7F6),
|
||||
error: Color(0xFFBA1A1A),
|
||||
success: Color(0xFF2E7D32),
|
||||
toggleBg: Color(0xFFFFFFFF),
|
||||
toggleIcon: Color(0xFF5F6368),
|
||||
itemActiveBg: Color(0x0F191C1D),
|
||||
filterActiveBg: Color(0x3379C476),
|
||||
progressTrack: Color(0x33C0C9BA),
|
||||
taskCardSelectedBorder: Color(0x24191C1D),
|
||||
taskCardHoverBg: Color(0xFFEAF0EC),
|
||||
taskCardAction: Color(0xFF5F6368),
|
||||
taskCardProgressFill: Color(0xFF79C476),
|
||||
taskCardIconBg: Color(0xFFF5F7F5),
|
||||
taskCardFailedIconBg: Color(0x14BA1A1A),
|
||||
taskMeta: Color(0xFF5F6368),
|
||||
taskMetaSubtle: Color(0xFF707A6D),
|
||||
taskErrorMeta: Color(0xCCBA1A1A),
|
||||
searchHint: Color(0xFF707A6D),
|
||||
headerDivider: Color(0xA3C0C9BA),
|
||||
captionButtonHover: Color(0x0F191C1D),
|
||||
captionButtonCloseHover: Color(0xFFE81123),
|
||||
);
|
||||
|
||||
static final dark = AppPalette(
|
||||
bg: const Color(0xFF09090B),
|
||||
railBg: Colors.black,
|
||||
sideBg: const Color(0xFF111111),
|
||||
cardBg: const Color(0xFF0F0F11),
|
||||
cardHoverBg: const Color(0xFF121215),
|
||||
surfaceSoft: const Color(0xFF1F1F24),
|
||||
inputBg: const Color(0xFF111111),
|
||||
footerBg: Colors.black.withValues(alpha: 0.2),
|
||||
border: const Color(0xFF1B1B1D),
|
||||
textPrimary: const Color(0xFFFFFFFF),
|
||||
textSecondary: const Color(0xFFA1A1AA),
|
||||
textMuted: const Color(0xFF71717A),
|
||||
primaryActionBg: const Color(0xFFFAFAFA),
|
||||
primaryActionForeground: const Color(0xFF18181B),
|
||||
primaryActionHoverBg: const Color(0xFFE4E4E7),
|
||||
brand: const Color(0xFFA7F5A2),
|
||||
brandForeground: const Color(0xFF07310B),
|
||||
brandSoft: const Color(0x1AA7F5A2),
|
||||
brandTrack: const Color(0x2CA7F5A2),
|
||||
brandProgress: const Color(0xFFA7F5A2),
|
||||
accent: const Color(0xFF111111),
|
||||
accentOn: const Color(0xFF09090B),
|
||||
error: const Color(0xFFFFB4AB),
|
||||
success: const Color(0xFF81C784),
|
||||
toggleBg: Colors.white.withValues(alpha: 0.08),
|
||||
toggleIcon: const Color(0xFFA1A1AA),
|
||||
itemActiveBg: Colors.white.withValues(alpha: 0.08),
|
||||
filterActiveBg: const Color(0x3DA7F5A2),
|
||||
progressTrack: const Color(0xFF272729),
|
||||
taskCardSelectedBorder: const Color(0xFF3F3F41),
|
||||
taskCardHoverBg: const Color(0xFF171719),
|
||||
taskCardAction: const Color(0xFFC6C6C6),
|
||||
taskCardProgressFill: const Color(0xFFA7F5A2),
|
||||
taskCardIconBg: const Color(0xFF1B1B1E),
|
||||
taskCardFailedIconBg: const Color(0xFF272020),
|
||||
taskMeta: const Color(0xFF8F8F90),
|
||||
taskMetaSubtle: const Color(0xFF6B6B6C),
|
||||
taskErrorMeta: const Color(0xFFCF938C),
|
||||
searchHint: const Color(0xFF52525B),
|
||||
headerDivider: const Color(0x1AFFFFFF),
|
||||
captionButtonHover: const Color(0x0DFFFFFF),
|
||||
captionButtonCloseHover: const Color(0xFFE81123),
|
||||
);
|
||||
|
||||
static AppPalette lightFor(AppThemeColor themeColor) {
|
||||
if (themeColor == AppThemeColor.green) return light;
|
||||
return _withThemeColor(light, color: themeColor.light, foreground: themeColor.lightForeground, dark: false);
|
||||
}
|
||||
|
||||
static AppPalette darkFor(AppThemeColor themeColor) {
|
||||
if (themeColor == AppThemeColor.green) return dark;
|
||||
return _withThemeColor(dark, color: themeColor.dark, foreground: themeColor.darkForeground, dark: true);
|
||||
}
|
||||
|
||||
static AppPalette _withThemeColor(
|
||||
AppPalette palette, {
|
||||
required Color color,
|
||||
required Color foreground,
|
||||
required bool dark,
|
||||
}) {
|
||||
return palette.copyWith(
|
||||
brand: color,
|
||||
brandForeground: foreground,
|
||||
brandSoft: color.withValues(alpha: dark ? 0.10 : 0.08),
|
||||
brandTrack: color.withValues(alpha: dark ? 0.17 : 0.15),
|
||||
brandProgress: color,
|
||||
filterActiveBg: color.withValues(alpha: dark ? 0.24 : 0.20),
|
||||
taskCardProgressFill: color,
|
||||
);
|
||||
}
|
||||
|
||||
final Color bg;
|
||||
final Color railBg;
|
||||
final Color sideBg;
|
||||
final Color cardBg;
|
||||
final Color cardHoverBg;
|
||||
final Color surfaceSoft;
|
||||
final Color inputBg;
|
||||
final Color footerBg;
|
||||
final Color border;
|
||||
final Color textPrimary;
|
||||
final Color textSecondary;
|
||||
final Color textMuted;
|
||||
final Color primaryActionBg;
|
||||
final Color primaryActionForeground;
|
||||
final Color primaryActionHoverBg;
|
||||
final Color brand;
|
||||
final Color brandForeground;
|
||||
final Color brandSoft;
|
||||
final Color brandTrack;
|
||||
final Color brandProgress;
|
||||
final Color accent;
|
||||
final Color accentOn;
|
||||
final Color error;
|
||||
final Color success;
|
||||
final Color toggleBg;
|
||||
final Color toggleIcon;
|
||||
final Color itemActiveBg;
|
||||
final Color filterActiveBg;
|
||||
final Color progressTrack;
|
||||
final Color taskCardSelectedBorder;
|
||||
final Color taskCardHoverBg;
|
||||
final Color taskCardAction;
|
||||
final Color taskCardProgressFill;
|
||||
final Color taskCardIconBg;
|
||||
final Color taskCardFailedIconBg;
|
||||
final Color taskMeta;
|
||||
final Color taskMetaSubtle;
|
||||
final Color taskErrorMeta;
|
||||
final Color searchHint;
|
||||
final Color headerDivider;
|
||||
final Color captionButtonHover;
|
||||
final Color captionButtonCloseHover;
|
||||
|
||||
static AppPalette of(BuildContext context) {
|
||||
final extension = Theme.of(context).extension<AppPalette>();
|
||||
if (extension != null) {
|
||||
return extension;
|
||||
}
|
||||
return shad.Theme.of(context).brightness == Brightness.light ? light : dark;
|
||||
}
|
||||
|
||||
@override
|
||||
AppPalette copyWith({
|
||||
Color? bg,
|
||||
Color? railBg,
|
||||
Color? sideBg,
|
||||
Color? cardBg,
|
||||
Color? cardHoverBg,
|
||||
Color? surfaceSoft,
|
||||
Color? inputBg,
|
||||
Color? footerBg,
|
||||
Color? border,
|
||||
Color? textPrimary,
|
||||
Color? textSecondary,
|
||||
Color? textMuted,
|
||||
Color? primaryActionBg,
|
||||
Color? primaryActionForeground,
|
||||
Color? primaryActionHoverBg,
|
||||
Color? brand,
|
||||
Color? brandForeground,
|
||||
Color? brandSoft,
|
||||
Color? brandTrack,
|
||||
Color? brandProgress,
|
||||
Color? accent,
|
||||
Color? accentOn,
|
||||
Color? error,
|
||||
Color? success,
|
||||
Color? toggleBg,
|
||||
Color? toggleIcon,
|
||||
Color? itemActiveBg,
|
||||
Color? filterActiveBg,
|
||||
Color? progressTrack,
|
||||
Color? taskCardSelectedBorder,
|
||||
Color? taskCardHoverBg,
|
||||
Color? taskCardAction,
|
||||
Color? taskCardProgressFill,
|
||||
Color? taskCardIconBg,
|
||||
Color? taskCardFailedIconBg,
|
||||
Color? taskMeta,
|
||||
Color? taskMetaSubtle,
|
||||
Color? taskErrorMeta,
|
||||
Color? searchHint,
|
||||
Color? headerDivider,
|
||||
Color? captionButtonHover,
|
||||
Color? captionButtonCloseHover,
|
||||
}) {
|
||||
return AppPalette(
|
||||
bg: bg ?? this.bg,
|
||||
railBg: railBg ?? this.railBg,
|
||||
sideBg: sideBg ?? this.sideBg,
|
||||
cardBg: cardBg ?? this.cardBg,
|
||||
cardHoverBg: cardHoverBg ?? this.cardHoverBg,
|
||||
surfaceSoft: surfaceSoft ?? this.surfaceSoft,
|
||||
inputBg: inputBg ?? this.inputBg,
|
||||
footerBg: footerBg ?? this.footerBg,
|
||||
border: border ?? this.border,
|
||||
textPrimary: textPrimary ?? this.textPrimary,
|
||||
textSecondary: textSecondary ?? this.textSecondary,
|
||||
textMuted: textMuted ?? this.textMuted,
|
||||
primaryActionBg: primaryActionBg ?? this.primaryActionBg,
|
||||
primaryActionForeground: primaryActionForeground ?? this.primaryActionForeground,
|
||||
primaryActionHoverBg: primaryActionHoverBg ?? this.primaryActionHoverBg,
|
||||
brand: brand ?? this.brand,
|
||||
brandForeground: brandForeground ?? this.brandForeground,
|
||||
brandSoft: brandSoft ?? this.brandSoft,
|
||||
brandTrack: brandTrack ?? this.brandTrack,
|
||||
brandProgress: brandProgress ?? this.brandProgress,
|
||||
accent: accent ?? this.accent,
|
||||
accentOn: accentOn ?? this.accentOn,
|
||||
error: error ?? this.error,
|
||||
success: success ?? this.success,
|
||||
toggleBg: toggleBg ?? this.toggleBg,
|
||||
toggleIcon: toggleIcon ?? this.toggleIcon,
|
||||
itemActiveBg: itemActiveBg ?? this.itemActiveBg,
|
||||
filterActiveBg: filterActiveBg ?? this.filterActiveBg,
|
||||
progressTrack: progressTrack ?? this.progressTrack,
|
||||
taskCardSelectedBorder: taskCardSelectedBorder ?? this.taskCardSelectedBorder,
|
||||
taskCardHoverBg: taskCardHoverBg ?? this.taskCardHoverBg,
|
||||
taskCardAction: taskCardAction ?? this.taskCardAction,
|
||||
taskCardProgressFill: taskCardProgressFill ?? this.taskCardProgressFill,
|
||||
taskCardIconBg: taskCardIconBg ?? this.taskCardIconBg,
|
||||
taskCardFailedIconBg: taskCardFailedIconBg ?? this.taskCardFailedIconBg,
|
||||
taskMeta: taskMeta ?? this.taskMeta,
|
||||
taskMetaSubtle: taskMetaSubtle ?? this.taskMetaSubtle,
|
||||
taskErrorMeta: taskErrorMeta ?? this.taskErrorMeta,
|
||||
searchHint: searchHint ?? this.searchHint,
|
||||
headerDivider: headerDivider ?? this.headerDivider,
|
||||
captionButtonHover: captionButtonHover ?? this.captionButtonHover,
|
||||
captionButtonCloseHover: captionButtonCloseHover ?? this.captionButtonCloseHover,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AppPalette lerp(ThemeExtension<AppPalette>? other, double t) {
|
||||
if (other is! AppPalette) {
|
||||
return this;
|
||||
}
|
||||
return AppPalette(
|
||||
bg: Color.lerp(bg, other.bg, t)!,
|
||||
railBg: Color.lerp(railBg, other.railBg, t)!,
|
||||
sideBg: Color.lerp(sideBg, other.sideBg, t)!,
|
||||
cardBg: Color.lerp(cardBg, other.cardBg, t)!,
|
||||
cardHoverBg: Color.lerp(cardHoverBg, other.cardHoverBg, t)!,
|
||||
surfaceSoft: Color.lerp(surfaceSoft, other.surfaceSoft, t)!,
|
||||
inputBg: Color.lerp(inputBg, other.inputBg, t)!,
|
||||
footerBg: Color.lerp(footerBg, other.footerBg, t)!,
|
||||
border: Color.lerp(border, other.border, t)!,
|
||||
textPrimary: Color.lerp(textPrimary, other.textPrimary, t)!,
|
||||
textSecondary: Color.lerp(textSecondary, other.textSecondary, t)!,
|
||||
textMuted: Color.lerp(textMuted, other.textMuted, t)!,
|
||||
primaryActionBg: Color.lerp(primaryActionBg, other.primaryActionBg, t)!,
|
||||
primaryActionForeground: Color.lerp(primaryActionForeground, other.primaryActionForeground, t)!,
|
||||
primaryActionHoverBg: Color.lerp(primaryActionHoverBg, other.primaryActionHoverBg, t)!,
|
||||
brand: Color.lerp(brand, other.brand, t)!,
|
||||
brandForeground: Color.lerp(brandForeground, other.brandForeground, t)!,
|
||||
brandSoft: Color.lerp(brandSoft, other.brandSoft, t)!,
|
||||
brandTrack: Color.lerp(brandTrack, other.brandTrack, t)!,
|
||||
brandProgress: Color.lerp(brandProgress, other.brandProgress, t)!,
|
||||
accent: Color.lerp(accent, other.accent, t)!,
|
||||
accentOn: Color.lerp(accentOn, other.accentOn, t)!,
|
||||
error: Color.lerp(error, other.error, t)!,
|
||||
success: Color.lerp(success, other.success, t)!,
|
||||
toggleBg: Color.lerp(toggleBg, other.toggleBg, t)!,
|
||||
toggleIcon: Color.lerp(toggleIcon, other.toggleIcon, t)!,
|
||||
itemActiveBg: Color.lerp(itemActiveBg, other.itemActiveBg, t)!,
|
||||
filterActiveBg: Color.lerp(filterActiveBg, other.filterActiveBg, t)!,
|
||||
progressTrack: Color.lerp(progressTrack, other.progressTrack, t)!,
|
||||
taskCardSelectedBorder: Color.lerp(taskCardSelectedBorder, other.taskCardSelectedBorder, t)!,
|
||||
taskCardHoverBg: Color.lerp(taskCardHoverBg, other.taskCardHoverBg, t)!,
|
||||
taskCardAction: Color.lerp(taskCardAction, other.taskCardAction, t)!,
|
||||
taskCardProgressFill: Color.lerp(taskCardProgressFill, other.taskCardProgressFill, t)!,
|
||||
taskCardIconBg: Color.lerp(taskCardIconBg, other.taskCardIconBg, t)!,
|
||||
taskCardFailedIconBg: Color.lerp(taskCardFailedIconBg, other.taskCardFailedIconBg, t)!,
|
||||
taskMeta: Color.lerp(taskMeta, other.taskMeta, t)!,
|
||||
taskMetaSubtle: Color.lerp(taskMetaSubtle, other.taskMetaSubtle, t)!,
|
||||
taskErrorMeta: Color.lerp(taskErrorMeta, other.taskErrorMeta, t)!,
|
||||
searchHint: Color.lerp(searchHint, other.searchHint, t)!,
|
||||
headerDivider: Color.lerp(headerDivider, other.headerDivider, t)!,
|
||||
captionButtonHover: Color.lerp(captionButtonHover, other.captionButtonHover, t)!,
|
||||
captionButtonCloseHover: Color.lerp(captionButtonCloseHover, other.captionButtonCloseHover, t)!,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' as material;
|
||||
import 'package:flutter/painting.dart' show TextStyle;
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import 'app_palette.dart';
|
||||
import 'app_theme_color.dart';
|
||||
|
||||
class AppTheme {
|
||||
const AppTheme._();
|
||||
|
||||
// Flutter's automatic CJK fallback can select faces with mismatched weights
|
||||
// on Windows. Keep Geist for supported glyphs, but make the native Windows
|
||||
// UI font the deterministic fallback for Chinese text.
|
||||
static const _windowsFontFamilyFallback = <String>['Microsoft YaHei UI'];
|
||||
|
||||
static bool get _usesWindowsFontFallback => !kIsWeb && defaultTargetPlatform == TargetPlatform.windows;
|
||||
|
||||
static shad.Typography _typography() {
|
||||
if (defaultTargetPlatform == TargetPlatform.android) return _androidTypography;
|
||||
|
||||
const typography = shad.Typography.geist();
|
||||
if (!_usesWindowsFontFallback) return typography;
|
||||
|
||||
return typography.copyWith(
|
||||
// Do not pass `package` here: Flutter prefixes every fallback family
|
||||
// with the package name when it is set, including system font names.
|
||||
sans: () => const TextStyle(
|
||||
fontFamily: 'packages/shadcn_flutter/GeistSans',
|
||||
fontFamilyFallback: _windowsFontFamilyFallback,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static shad.ThemeData light([AppThemeColor themeColor = AppThemeColor.green]) {
|
||||
return _buildTheme(palette: AppPalette.lightFor(themeColor), brightness: Brightness.light);
|
||||
}
|
||||
|
||||
static shad.ThemeData dark([AppThemeColor themeColor = AppThemeColor.green]) {
|
||||
return _buildTheme(palette: AppPalette.darkFor(themeColor), brightness: Brightness.dark);
|
||||
}
|
||||
|
||||
static shad.ThemeData _buildTheme({required AppPalette palette, required Brightness brightness}) {
|
||||
return shad.ThemeData(
|
||||
colorScheme: shad.ColorScheme.fromColors(
|
||||
brightness: brightness,
|
||||
colors: {
|
||||
'background': palette.bg,
|
||||
'foreground': palette.textPrimary,
|
||||
'card': palette.cardBg,
|
||||
'cardForeground': palette.textPrimary,
|
||||
'popover': palette.sideBg,
|
||||
'popoverForeground': palette.textPrimary,
|
||||
'primary': palette.brand,
|
||||
'primaryForeground': palette.brandForeground,
|
||||
'secondary': palette.surfaceSoft,
|
||||
'secondaryForeground': palette.textPrimary,
|
||||
'muted': palette.surfaceSoft,
|
||||
'mutedForeground': palette.textSecondary,
|
||||
'accent': palette.inputBg,
|
||||
'accentForeground': palette.textPrimary,
|
||||
'destructive': palette.error,
|
||||
'destructiveForeground': palette.bg,
|
||||
'border': palette.border,
|
||||
'input': palette.border,
|
||||
'ring': palette.brand,
|
||||
'chart1': palette.brand,
|
||||
'chart2': palette.textSecondary,
|
||||
'chart3': palette.textMuted,
|
||||
'chart4': palette.surfaceSoft,
|
||||
'chart5': palette.cardHoverBg,
|
||||
},
|
||||
),
|
||||
typography: _typography(),
|
||||
radius: 0.5,
|
||||
scaling: 1,
|
||||
surfaceBlur: 0,
|
||||
surfaceOpacity: 1,
|
||||
platform: defaultTargetPlatform,
|
||||
);
|
||||
}
|
||||
|
||||
static const shad.Typography _androidTypography = shad.Typography.geist(
|
||||
sans: material.TextStyle(),
|
||||
mono: material.TextStyle(fontFamily: 'monospace'),
|
||||
inlineCode: material.TextStyle(fontFamily: 'monospace', fontSize: 14, fontWeight: material.FontWeight.w600),
|
||||
);
|
||||
|
||||
static material.ThemeData materialLight([AppThemeColor themeColor = AppThemeColor.green]) {
|
||||
return _buildMaterialTheme(palette: AppPalette.lightFor(themeColor), brightness: Brightness.light);
|
||||
}
|
||||
|
||||
static material.ThemeData materialDark([AppThemeColor themeColor = AppThemeColor.green]) {
|
||||
return _buildMaterialTheme(palette: AppPalette.darkFor(themeColor), brightness: Brightness.dark);
|
||||
}
|
||||
|
||||
static material.ThemeData _buildMaterialTheme({required AppPalette palette, required Brightness brightness}) {
|
||||
final theme = material.ThemeData.from(
|
||||
colorScheme: material.ColorScheme.fromSeed(
|
||||
seedColor: palette.brand,
|
||||
brightness: brightness,
|
||||
surface: palette.bg,
|
||||
primary: palette.brand,
|
||||
),
|
||||
useMaterial3: true,
|
||||
);
|
||||
return theme.copyWith(
|
||||
extensions: <material.ThemeExtension<dynamic>>[palette],
|
||||
textTheme: _usesWindowsFontFallback
|
||||
? theme.textTheme.apply(fontFamilyFallback: _windowsFontFamilyFallback)
|
||||
: theme.textTheme,
|
||||
primaryTextTheme: _usesWindowsFontFallback
|
||||
? theme.primaryTextTheme.apply(fontFamilyFallback: _windowsFontFamilyFallback)
|
||||
: theme.primaryTextTheme,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
enum AppThemeColor {
|
||||
green(
|
||||
key: 'green',
|
||||
light: Color(0xFF79C476),
|
||||
dark: Color(0xFFA7F5A2),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF07310B),
|
||||
),
|
||||
red(
|
||||
key: 'red',
|
||||
light: Color(0xFFE5484D),
|
||||
dark: Color(0xFFFF8A8E),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF3B0507),
|
||||
),
|
||||
rose(
|
||||
key: 'rose',
|
||||
light: Color(0xFFE93D82),
|
||||
dark: Color(0xFFFF8AB7),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF3B071B),
|
||||
),
|
||||
orange(
|
||||
key: 'orange',
|
||||
light: Color(0xFFF76B15),
|
||||
dark: Color(0xFFFFA45B),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF3A1600),
|
||||
),
|
||||
cyan(
|
||||
key: 'cyan',
|
||||
light: Color(0xFF0CA678),
|
||||
dark: Color(0xFF5EE0B5),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF003829),
|
||||
),
|
||||
blue(
|
||||
key: 'blue',
|
||||
light: Color(0xFF2563EB),
|
||||
dark: Color(0xFF73A7FF),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF061B3F),
|
||||
),
|
||||
amber(
|
||||
key: 'amber',
|
||||
light: Color(0xFFD99A00),
|
||||
dark: Color(0xFFFFD166),
|
||||
lightForeground: Color(0xFF211800),
|
||||
darkForeground: Color(0xFF302300),
|
||||
),
|
||||
purple(
|
||||
key: 'purple',
|
||||
light: Color(0xFF8B5CF6),
|
||||
dark: Color(0xFFB794F6),
|
||||
lightForeground: Color(0xFFFFFFFF),
|
||||
darkForeground: Color(0xFF261052),
|
||||
);
|
||||
|
||||
const AppThemeColor({
|
||||
required this.key,
|
||||
required this.light,
|
||||
required this.dark,
|
||||
required this.lightForeground,
|
||||
required this.darkForeground,
|
||||
});
|
||||
|
||||
final String key;
|
||||
final Color light;
|
||||
final Color dark;
|
||||
final Color lightForeground;
|
||||
final Color darkForeground;
|
||||
|
||||
static AppThemeColor fromKey(String? key) {
|
||||
return values.where((color) => color.key == key).firstOrNull ?? AppThemeColor.green;
|
||||
}
|
||||
}
|
||||
|
||||
class AppThemePreviewColors {
|
||||
const AppThemePreviewColors._();
|
||||
|
||||
static const lightBackground = Color(0xFFF7F8F8);
|
||||
static const lightSide = Color(0xFFE5E8E7);
|
||||
static const lightLine = Color(0xFFB8BEBC);
|
||||
static const darkBackground = Color(0xFF111318);
|
||||
static const darkSide = Color(0xFF20242C);
|
||||
static const darkLine = Color(0xFF676D78);
|
||||
static const systemSide = Color(0x55878E8C);
|
||||
static const systemLine = Color(0xFF7B8280);
|
||||
static const transparent = Color(0x00000000);
|
||||
}
|
||||
Reference in new issue
Block a user