feat: add shadow tokens (#7726)

This commit is contained in:
Richard Shiue 2025-04-11 11:14:28 +08:00
parent d8401e09c9
commit 068f93c258
6 changed files with 60 additions and 45 deletions

View File

@ -445,7 +445,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(appTheme.borderRadius.l), borderRadius: BorderRadius.circular(appTheme.borderRadius.l),
color: appTheme.surfaceColorScheme.primary, color: appTheme.surfaceColorScheme.primary,
boxShadow: [appTheme.shadow.small], boxShadow: appTheme.shadow.small,
), ),
toolbarBuilder: (_, child, onDismiss, isMetricsChanged) => toolbarBuilder: (_, child, onDismiss, isMetricsChanged) =>
BlocProvider.value( BlocProvider.value(

View File

@ -315,6 +315,6 @@ ShapeDecoration buildToolbarLinkDecoration(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius), borderRadius: BorderRadius.circular(radius),
), ),
shadows: [theme.shadow.small], shadows: theme.shadow.small,
); );
} }

View File

@ -148,7 +148,7 @@ class _PasteAsMenuState extends State<PasteAsMenu> {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
color: theme.surfaceColorScheme.primary, color: theme.surfaceColorScheme.primary,
boxShadow: [theme.shadow.medium], boxShadow: theme.shadow.medium,
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -93,35 +93,6 @@ class AppFlowyThemeBuilder {
}; };
} }
AppFlowyShadow buildShadow(Brightness brightness) {
return switch (brightness) {
Brightness.light => AppFlowyShadow(
small: const BoxShadow(
offset: Offset(0.0, 2.0),
blurRadius: 16.0,
color: Color(0x1F000000),
),
medium: const BoxShadow(
offset: Offset(0.0, 4.0),
blurRadius: 32.0,
color: Color(0x1F000000),
),
),
Brightness.dark => AppFlowyShadow(
small: BoxShadow(
offset: Offset(0.0, 2.0),
blurRadius: 16.0,
color: Color(0x7A000000),
),
medium: BoxShadow(
offset: Offset(0.0, 4.0),
blurRadius: 32.0,
color: Color(0x7A000000),
),
),
};
}
AppFlowyBorderColorScheme buildBorderColorScheme( AppFlowyBorderColorScheme buildBorderColorScheme(
AppFlowyBaseColorScheme colorScheme, AppFlowyBaseColorScheme colorScheme,
Brightness brightness, Brightness brightness,
@ -351,4 +322,43 @@ class AppFlowyThemeBuilder {
xxl: AppFlowySpacingConstant.spacing600, xxl: AppFlowySpacingConstant.spacing600,
); );
} }
AppFlowyShadow buildShadow(
Brightness brightness,
) {
return switch (brightness) {
Brightness.light => AppFlowyShadow(
small: [
BoxShadow(
offset: Offset(0, 2),
blurRadius: 16,
color: Color(0x1F000000),
),
],
medium: [
BoxShadow(
offset: Offset(0, 4),
blurRadius: 32,
color: Color(0x1F000000),
),
],
),
Brightness.dark => AppFlowyShadow(
small: [
BoxShadow(
offset: Offset(0, 2),
blurRadius: 16,
color: Color(0x7A000000),
),
],
medium: [
BoxShadow(
offset: Offset(0, 4),
blurRadius: 32,
color: Color(0x7A000000),
),
],
),
};
}
} }

View File

@ -36,9 +36,9 @@ abstract class AppFlowyBaseTheme {
AppFlowySpacing get spacing; AppFlowySpacing get spacing;
AppFlowyBrandColorScheme get brandColorScheme;
AppFlowyShadow get shadow; AppFlowyShadow get shadow;
AppFlowyBrandColorScheme get brandColorScheme;
} }
class AppFlowyThemeData extends AppFlowyBaseTheme { class AppFlowyThemeData extends AppFlowyBaseTheme {
@ -70,10 +70,11 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
colorScheme, colorScheme,
Brightness.light, Brightness.light,
); );
final shadow = themeBuilder.buildShadow(Brightness.light);
final brandColorScheme = themeBuilder.buildBrandColorScheme(colorScheme); final brandColorScheme = themeBuilder.buildBrandColorScheme(colorScheme);
final borderRadius = themeBuilder.buildBorderRadius(colorScheme); final borderRadius = themeBuilder.buildBorderRadius(colorScheme);
final spacing = themeBuilder.buildSpacing(colorScheme); final spacing = themeBuilder.buildSpacing(colorScheme);
final shadow = themeBuilder.buildShadow(Brightness.light);
return AppFlowyThemeData( return AppFlowyThemeData(
colorScheme: colorScheme, colorScheme: colorScheme,
textColorScheme: textColorScheme, textColorScheme: textColorScheme,
@ -85,8 +86,8 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
surfaceColorScheme: surfaceColorScheme, surfaceColorScheme: surfaceColorScheme,
borderRadius: borderRadius, borderRadius: borderRadius,
spacing: spacing, spacing: spacing,
brandColorScheme: brandColorScheme,
shadow: shadow, shadow: shadow,
brandColorScheme: brandColorScheme,
); );
} }
@ -117,10 +118,11 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
colorScheme, colorScheme,
Brightness.dark, Brightness.dark,
); );
final shadow = themeBuilder.buildShadow(Brightness.dark);
final brandColorScheme = themeBuilder.buildBrandColorScheme(colorScheme); final brandColorScheme = themeBuilder.buildBrandColorScheme(colorScheme);
final borderRadius = themeBuilder.buildBorderRadius(colorScheme); final borderRadius = themeBuilder.buildBorderRadius(colorScheme);
final spacing = themeBuilder.buildSpacing(colorScheme); final spacing = themeBuilder.buildSpacing(colorScheme);
final shadow = themeBuilder.buildShadow(Brightness.dark);
return AppFlowyThemeData( return AppFlowyThemeData(
colorScheme: colorScheme, colorScheme: colorScheme,
textColorScheme: textColorScheme, textColorScheme: textColorScheme,
@ -132,8 +134,8 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
surfaceColorScheme: surfaceColorScheme, surfaceColorScheme: surfaceColorScheme,
borderRadius: borderRadius, borderRadius: borderRadius,
spacing: spacing, spacing: spacing,
brandColorScheme: brandColorScheme,
shadow: shadow, shadow: shadow,
brandColorScheme: brandColorScheme,
); );
} }
@ -146,10 +148,10 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
required this.surfaceColorScheme, required this.surfaceColorScheme,
required this.borderRadius, required this.borderRadius,
required this.spacing, required this.spacing,
required this.shadow,
required this.brandColorScheme, required this.brandColorScheme,
required this.iconColorTheme, required this.iconColorTheme,
required this.backgroundColorScheme, required this.backgroundColorScheme,
required this.shadow,
this.brightness = Brightness.light, this.brightness = Brightness.light,
}); });
@ -181,6 +183,9 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
@override @override
final AppFlowySpacing spacing; final AppFlowySpacing spacing;
@override
final AppFlowyShadow shadow;
@override @override
final AppFlowyBrandColorScheme brandColorScheme; final AppFlowyBrandColorScheme brandColorScheme;
@ -190,9 +195,6 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
@override @override
final AppFlowyBackgroundColorScheme backgroundColorScheme; final AppFlowyBackgroundColorScheme backgroundColorScheme;
@override
final AppFlowyShadow shadow;
static AppFlowyTextColorScheme buildTextColorScheme( static AppFlowyTextColorScheme buildTextColorScheme(
AppFlowyBaseColorScheme colorScheme, AppFlowyBaseColorScheme colorScheme,
Brightness brightness, Brightness brightness,

View File

@ -1,8 +1,11 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class AppFlowyShadow { class AppFlowyShadow {
AppFlowyShadow({required this.small, required this.medium}); AppFlowyShadow({
required this.small,
required this.medium,
});
final BoxShadow small; final List<BoxShadow> small;
final BoxShadow medium; final List<BoxShadow> medium;
} }