1304 lines
46 KiB
Dart
1304 lines
46 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
|
|
import 'menu_metrics.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Workspace semantic colors and Codex desktop typography.
|
|
abstract final class AppTheme {
|
|
static ThemeData get penLight => _build(AppColors.penLight);
|
|
static ThemeData get penDark => _build(AppColors.penDark);
|
|
|
|
/// Media canvas controls keep a dark palette in either workspace appearance.
|
|
static ThemeData get previewCanvasTheme => penDark;
|
|
|
|
/// Fullscreen also places Material children on the black preview surface.
|
|
static ThemeData get previewFullscreenTheme {
|
|
final theme = previewCanvasTheme;
|
|
return theme.copyWith(
|
|
colorScheme: theme.colorScheme.copyWith(
|
|
surface: theme.extension<AppSurfaces>()!.previewBackground,
|
|
),
|
|
);
|
|
}
|
|
|
|
static Color itemHoverColor(BuildContext context, {required bool selected}) {
|
|
final theme = Theme.of(context);
|
|
return theme.colorScheme.onSurface.withValues(
|
|
alpha: selected
|
|
? .05
|
|
: theme.brightness == Brightness.dark
|
|
? .078
|
|
: .058,
|
|
);
|
|
}
|
|
|
|
static Color comboboxBackground(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return theme.brightness == Brightness.dark
|
|
? theme.colorScheme.surfaceContainerHighest.withValues(alpha: .3)
|
|
: Colors.transparent;
|
|
}
|
|
|
|
static Color tabBorderColor(
|
|
BuildContext context, {
|
|
required bool selected,
|
|
required bool headerStyle,
|
|
}) {
|
|
final theme = Theme.of(context);
|
|
return selected && (headerStyle || theme.brightness == Brightness.dark)
|
|
? theme.colorScheme.outlineVariant
|
|
: Colors.transparent;
|
|
}
|
|
|
|
static Color dropOverlayBackground(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return theme.colorScheme.scrim.withValues(
|
|
alpha: theme.brightness == Brightness.dark ? .62 : .38,
|
|
);
|
|
}
|
|
|
|
static TextStyle resourceProgressTextStyle(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return theme.textTheme.bodyMedium!.copyWith(
|
|
color: theme.brightness == Brightness.dark
|
|
? theme.colorScheme.onSurface.withValues(alpha: .55)
|
|
: theme.colorScheme.onSurfaceVariant,
|
|
);
|
|
}
|
|
|
|
static Color settingsSidebarBackground(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return theme.brightness == Brightness.dark
|
|
? AppColors.penDark.settingsSidebar
|
|
: theme.colorScheme.surfaceContainer;
|
|
}
|
|
|
|
static Color switchTrackColor(BuildContext context, Set<WidgetState> states) {
|
|
final theme = Theme.of(context);
|
|
final configured = theme.switchTheme.trackColor?.resolve(states);
|
|
if (configured != null) return configured;
|
|
if (states.contains(WidgetState.selected)) return theme.colorScheme.primary;
|
|
final input = theme.inputDecorationTheme.enabledBorder!.borderSide.color;
|
|
return input.withValues(
|
|
alpha: input.a * (theme.brightness == Brightness.dark ? .8 : 1),
|
|
);
|
|
}
|
|
|
|
static Color switchThumbColor(BuildContext context, Set<WidgetState> states) {
|
|
final theme = Theme.of(context);
|
|
final configured = theme.switchTheme.thumbColor?.resolve(states);
|
|
if (configured != null) return configured;
|
|
if (theme.brightness == Brightness.dark) {
|
|
return states.contains(WidgetState.selected)
|
|
? theme.colorScheme.onPrimary
|
|
: theme.colorScheme.onSurface;
|
|
}
|
|
return theme.colorScheme.surface;
|
|
}
|
|
|
|
static String systemFontFamily(TargetPlatform platform) => switch (platform) {
|
|
TargetPlatform.macOS || TargetPlatform.iOS => '.AppleSystemUIFont',
|
|
TargetPlatform.windows => 'Segoe UI',
|
|
_ => 'sans-serif',
|
|
};
|
|
|
|
static List<String> systemFontFamilyFallback(TargetPlatform platform) =>
|
|
switch (platform) {
|
|
TargetPlatform.windows => const [
|
|
'Microsoft YaHei UI',
|
|
'Microsoft YaHei',
|
|
'Noto Sans CJK SC',
|
|
'sans-serif',
|
|
],
|
|
_ => const ['PingFang SC', 'Noto Sans CJK SC', 'sans-serif'],
|
|
};
|
|
|
|
static Color popoverBackground(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return theme.extension<AppSurfaces>()?.popoverBackground ??
|
|
theme.colorScheme.surfaceContainerHigh;
|
|
}
|
|
|
|
/// The visible sidebar/content boundary in the opaque Codex window.
|
|
static Color sidebarDividerColor(BuildContext context) =>
|
|
Theme.of(context).dividerColor;
|
|
|
|
/// Side panels keep their Material children on the same surface.
|
|
static ThemeData panelTheme(ThemeData theme) {
|
|
final background = theme.colorScheme.surfaceContainerLow;
|
|
return theme.copyWith(
|
|
canvasColor: background,
|
|
colorScheme: theme.colorScheme.copyWith(surface: background),
|
|
);
|
|
}
|
|
|
|
static ThemeData timelinePanelTheme(ThemeData theme) {
|
|
final divider = theme.dividerColor;
|
|
return theme.copyWith(
|
|
dividerColor: divider,
|
|
dividerTheme: DividerThemeData(color: divider, thickness: 1, space: 1),
|
|
);
|
|
}
|
|
|
|
/// Inspector controls share the desktop UI type scale.
|
|
static ThemeData propertiesPanelTheme(ThemeData theme) {
|
|
final colors = theme.colorScheme;
|
|
final panelText = theme.textTheme;
|
|
final panelColors = colors.copyWith(surface: colors.surfaceContainerLow);
|
|
final composerBackground = theme
|
|
.extension<AppSurfaces>()!
|
|
.composerBackground;
|
|
final hintColor = theme.brightness == Brightness.dark
|
|
? colors.onSurface.withValues(alpha: .249)
|
|
: colors.onSurfaceVariant.withValues(alpha: .5);
|
|
const inputShape = OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(AppRadius.large)),
|
|
borderSide: BorderSide.none,
|
|
);
|
|
return theme.copyWith(
|
|
canvasColor: colors.surfaceContainerLow,
|
|
colorScheme: panelColors,
|
|
textTheme: panelText,
|
|
primaryTextTheme: panelText,
|
|
inputDecorationTheme: theme.inputDecorationTheme.copyWith(
|
|
constraints: const BoxConstraints(
|
|
minHeight: AppControlSize.propertyControl,
|
|
),
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.controlHorizontal,
|
|
vertical: AppSpacing.tiny,
|
|
),
|
|
fillColor: composerBackground,
|
|
hintStyle: panelText.bodyMedium?.copyWith(color: hintColor),
|
|
border: inputShape,
|
|
enabledBorder: inputShape,
|
|
disabledBorder: inputShape,
|
|
focusedBorder: inputShape,
|
|
errorBorder: inputShape,
|
|
focusedErrorBorder: inputShape,
|
|
),
|
|
iconButtonTheme: IconButtonThemeData(
|
|
style: theme.iconButtonTheme.style?.copyWith(
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size.square(AppControlSize.propertyControl),
|
|
),
|
|
maximumSize: const WidgetStatePropertyAll(
|
|
Size.square(AppControlSize.propertyControl),
|
|
),
|
|
fixedSize: const WidgetStatePropertyAll(
|
|
Size.square(AppControlSize.propertyControl),
|
|
),
|
|
),
|
|
),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: theme.textButtonTheme.style?.copyWith(
|
|
textStyle: WidgetStatePropertyAll(panelText.labelLarge),
|
|
),
|
|
),
|
|
filledButtonTheme: FilledButtonThemeData(
|
|
style: theme.filledButtonTheme.style?.copyWith(
|
|
textStyle: WidgetStatePropertyAll(panelText.labelLarge),
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: theme.outlinedButtonTheme.style?.copyWith(
|
|
textStyle: WidgetStatePropertyAll(panelText.labelLarge),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static TextStyle toolbarTextStyle(BuildContext context) =>
|
|
Theme.of(context).textTheme.bodyMedium!
|
|
.copyWith(fontSize: 13, height: 18 / 13);
|
|
|
|
/// Codex desktop's compact heading-sm: 13px, 1.4 line height, medium ink.
|
|
static TextStyle propertySectionTitleStyle(BuildContext context) =>
|
|
Theme.of(context).textTheme.labelLarge!.copyWith(
|
|
height: 1.4,
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
);
|
|
|
|
static ButtonStyle toolbarButtonStyle(BuildContext context) => ButtonStyle(
|
|
textStyle: WidgetStatePropertyAll(toolbarTextStyle(context)),
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size(0, AppControlSize.headerButton),
|
|
),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.symmetric(horizontal: AppSpacing.small),
|
|
),
|
|
);
|
|
|
|
static ThemeData dialogContentTheme(ThemeData theme) {
|
|
const buttonSize = WidgetStatePropertyAll(Size(0, 32));
|
|
const buttonPadding = WidgetStatePropertyAll(
|
|
EdgeInsets.symmetric(horizontal: 16, vertical: AppSpacing.gap),
|
|
);
|
|
final buttonText = WidgetStatePropertyAll(
|
|
theme.textTheme.labelLarge?.copyWith(fontSize: 14, height: 20 / 14),
|
|
);
|
|
final dark = theme.brightness == Brightness.dark;
|
|
final inputBorder = OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(AppRadius.large),
|
|
borderSide: BorderSide(
|
|
color: dark
|
|
? AppColors.penDark.dialogBorder
|
|
: theme.colorScheme.outlineVariant,
|
|
),
|
|
);
|
|
return theme.copyWith(
|
|
textTheme: theme.textTheme.copyWith(
|
|
bodyMedium: theme.textTheme.bodyMedium?.copyWith(
|
|
fontSize: 14,
|
|
height: 20 / 14,
|
|
),
|
|
),
|
|
inputDecorationTheme: theme.inputDecorationTheme.copyWith(
|
|
constraints: const BoxConstraints(minHeight: 36),
|
|
fillColor: dark
|
|
? AppColors.penDark.dialogInputBackground
|
|
: theme.colorScheme.surface,
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 10,
|
|
vertical: AppSpacing.small,
|
|
),
|
|
border: inputBorder,
|
|
enabledBorder: inputBorder,
|
|
focusedBorder: inputBorder.copyWith(
|
|
borderSide: BorderSide(
|
|
color: dark
|
|
? AppColors.penDark.dialogFocusBorder
|
|
: theme.colorScheme.outline,
|
|
),
|
|
),
|
|
),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: theme.textButtonTheme.style?.copyWith(
|
|
minimumSize: buttonSize,
|
|
padding: buttonPadding,
|
|
textStyle: buttonText,
|
|
),
|
|
),
|
|
filledButtonTheme: FilledButtonThemeData(
|
|
style: theme.filledButtonTheme.style?.copyWith(
|
|
minimumSize: buttonSize,
|
|
padding: buttonPadding,
|
|
textStyle: buttonText,
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: theme.outlinedButtonTheme.style?.copyWith(
|
|
minimumSize: buttonSize,
|
|
padding: buttonPadding,
|
|
textStyle: buttonText,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static ThemeData settingsContentTheme(ThemeData theme) {
|
|
final base = dialogContentTheme(theme);
|
|
final dark = base.brightness == Brightness.dark;
|
|
final colors = base.colorScheme;
|
|
final text = base.textTheme;
|
|
final border = dark
|
|
? AppColors.penDark.settingsBorder
|
|
: colors.outlineVariant;
|
|
final body = text.bodyMedium!.copyWith(
|
|
fontSize: 13,
|
|
height: 18 / 13,
|
|
letterSpacing: 0,
|
|
fontWeight: FontWeight.w400,
|
|
fontVariations: const [FontVariation('wght', 400)],
|
|
);
|
|
ButtonStyle? control(ButtonStyle? style) => style?.copyWith(
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size(0, AppSettingsMetrics.controlHeight),
|
|
),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
|
),
|
|
textStyle: WidgetStatePropertyAll(body),
|
|
iconSize: const WidgetStatePropertyAll(16),
|
|
shape: const WidgetStatePropertyAll(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
),
|
|
),
|
|
);
|
|
return base.copyWith(
|
|
colorScheme: colors.copyWith(
|
|
surface: dark ? AppColors.penDark.background : colors.surface,
|
|
surfaceContainer: dark
|
|
? AppColors.penDark.settingsContainer
|
|
: colors.surfaceContainer,
|
|
outlineVariant: border,
|
|
),
|
|
dividerTheme: base.dividerTheme.copyWith(color: border, thickness: 1),
|
|
textTheme: text.copyWith(
|
|
bodyMedium: body,
|
|
labelLarge: body,
|
|
labelMedium: body,
|
|
bodySmall: text.bodySmall?.copyWith(fontSize: 12, height: 16 / 12),
|
|
titleLarge: text.headlineSmall?.copyWith(
|
|
fontSize: 28,
|
|
height: 36 / 28,
|
|
fontWeight: FontWeight.w600,
|
|
fontVariations: const [FontVariation('wght', 600)],
|
|
),
|
|
),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: control(base.textButtonTheme.style),
|
|
),
|
|
filledButtonTheme: FilledButtonThemeData(
|
|
style: control(base.filledButtonTheme.style)?.copyWith(
|
|
backgroundColor: WidgetStateProperty.resolveWith(
|
|
(states) => colors.onSurface.withValues(
|
|
alpha: states.contains(WidgetState.disabled) ? .3 : 1,
|
|
),
|
|
),
|
|
foregroundColor: WidgetStatePropertyAll(colors.surface),
|
|
side: const WidgetStatePropertyAll(BorderSide.none),
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: control(base.outlinedButtonTheme.style)?.copyWith(
|
|
backgroundColor: WidgetStatePropertyAll(
|
|
dark ? AppColors.penDark.settingsControlBackground : colors.surface,
|
|
),
|
|
side: WidgetStatePropertyAll(BorderSide(color: border)),
|
|
),
|
|
),
|
|
switchTheme: base.switchTheme.copyWith(
|
|
trackColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.selected)
|
|
? AppColors.settingsSwitchAccent
|
|
: (dark ? AppColors.penDark : AppColors.penLight)
|
|
.settingsSwitchTrack,
|
|
),
|
|
thumbColor: const WidgetStatePropertyAll(Colors.white),
|
|
),
|
|
);
|
|
}
|
|
|
|
static ThemeData dialogActionTheme(ThemeData theme) {
|
|
final colors = theme.colorScheme;
|
|
final dark = theme.brightness == Brightness.dark;
|
|
return theme.copyWith(
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: theme.textButtonTheme.style?.copyWith(
|
|
backgroundColor: WidgetStatePropertyAll(
|
|
(dark ? AppColors.penDark : AppColors.penLight)
|
|
.dialogActionBackground,
|
|
),
|
|
side: WidgetStatePropertyAll(
|
|
BorderSide(
|
|
color: dark
|
|
? AppColors.penDark.dialogBorder
|
|
: colors.outlineVariant,
|
|
),
|
|
),
|
|
foregroundColor: WidgetStatePropertyAll(colors.onSurface),
|
|
),
|
|
),
|
|
filledButtonTheme: FilledButtonThemeData(
|
|
style: theme.filledButtonTheme.style?.copyWith(
|
|
backgroundColor: WidgetStatePropertyAll(colors.onSurface),
|
|
foregroundColor: WidgetStatePropertyAll(colors.surface),
|
|
side: const WidgetStatePropertyAll(BorderSide.none),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static ButtonStyle panelTabStyle(
|
|
BuildContext context, {
|
|
required bool selected,
|
|
}) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
final ink = colors.onSurface;
|
|
return ButtonStyle(
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size(0, AppControlSize.headerButton),
|
|
),
|
|
maximumSize: const WidgetStatePropertyAll(
|
|
Size(double.infinity, AppControlSize.headerButton),
|
|
),
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
textStyle: WidgetStatePropertyAll(toolbarTextStyle(context)),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.symmetric(horizontal: AppSpacing.small),
|
|
),
|
|
shape: WidgetStatePropertyAll(
|
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
|
),
|
|
foregroundColor: WidgetStatePropertyAll(
|
|
selected
|
|
? ink
|
|
: Theme.of(context).brightness == Brightness.dark
|
|
? ink.withValues(alpha: .498)
|
|
: colors.onSurfaceVariant,
|
|
),
|
|
backgroundColor: WidgetStatePropertyAll(
|
|
selected ? ink.withValues(alpha: .05) : Colors.transparent,
|
|
),
|
|
overlayColor: WidgetStateProperty.resolveWith((states) {
|
|
if (states.contains(WidgetState.hovered) ||
|
|
states.contains(WidgetState.focused) ||
|
|
states.contains(WidgetState.pressed)) {
|
|
return selected
|
|
? ink.withValues(alpha: .05)
|
|
: ink.withValues(alpha: .078);
|
|
}
|
|
return Colors.transparent;
|
|
}),
|
|
);
|
|
}
|
|
|
|
static ButtonStyle iconButtonStyle(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return _iconButtonStyle(theme.colorScheme.onSurface, theme.brightness);
|
|
}
|
|
|
|
static ButtonStyle _iconButtonStyle(Color ink, Brightness brightness) {
|
|
final dark = brightness == Brightness.dark;
|
|
final inactive = ink.withValues(alpha: dark ? .498 : .51);
|
|
final hover = ink.withValues(alpha: dark ? .078 : .058);
|
|
return ButtonStyle(
|
|
foregroundColor: WidgetStateProperty.resolveWith((states) {
|
|
final color = states.contains(WidgetState.selected) ? ink : inactive;
|
|
return states.contains(WidgetState.disabled)
|
|
? color.withValues(alpha: color.a * .5)
|
|
: color;
|
|
}),
|
|
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
|
if (!states.contains(WidgetState.selected)) return Colors.transparent;
|
|
final interacting =
|
|
!states.contains(WidgetState.disabled) &&
|
|
(states.contains(WidgetState.hovered) ||
|
|
states.contains(WidgetState.focused) ||
|
|
states.contains(WidgetState.pressed));
|
|
return ink.withValues(alpha: interacting ? .10 : .05);
|
|
}),
|
|
overlayColor: WidgetStateProperty.resolveWith((states) {
|
|
// Selected buttons resolve their entire background above, without an
|
|
// extra overlay: Codex secondary uses bg-text/5 and hover:bg-text/10.
|
|
if (states.contains(WidgetState.disabled) ||
|
|
states.contains(WidgetState.selected)) {
|
|
return Colors.transparent;
|
|
}
|
|
if (states.contains(WidgetState.hovered) ||
|
|
states.contains(WidgetState.focused) ||
|
|
states.contains(WidgetState.pressed)) {
|
|
return hover;
|
|
}
|
|
return Colors.transparent;
|
|
}),
|
|
);
|
|
}
|
|
|
|
static ButtonStyle primaryIconButtonStyle(BuildContext context) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
return ButtonStyle(
|
|
backgroundColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.disabled)
|
|
? colors.onSurface.withValues(alpha: 0.12)
|
|
: colors.primary,
|
|
),
|
|
foregroundColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.disabled)
|
|
? colors.onSurface.withValues(alpha: 0.38)
|
|
: colors.onPrimary,
|
|
),
|
|
);
|
|
}
|
|
|
|
static BoxDecoration userMessageDecoration(BuildContext context) =>
|
|
BoxDecoration(
|
|
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: .08),
|
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
|
);
|
|
|
|
static TextStyle chatMessageTextStyle(BuildContext context) =>
|
|
Theme.of(context).textTheme.bodyMedium!.copyWith(
|
|
fontSize: 14,
|
|
height: 1.5,
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
);
|
|
|
|
static TextStyle chatMetaTextStyle(BuildContext context) =>
|
|
Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
fontSize: 13,
|
|
height: 18 / 13,
|
|
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: .5),
|
|
);
|
|
|
|
static TextStyle inputTextStyle(BuildContext context) =>
|
|
Theme.of(context).textTheme.bodyMedium!;
|
|
|
|
static TextStyle composerTextStyle(BuildContext context) =>
|
|
AppSidebarTypography.style(
|
|
context,
|
|
fontSize: 13,
|
|
height: 20 / 13,
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
).copyWith(leadingDistribution: TextLeadingDistribution.even);
|
|
|
|
static Color composerReferenceColor(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return Color.lerp(
|
|
theme.colorScheme.outline,
|
|
theme.colorScheme.onSurface,
|
|
theme.brightness == Brightness.dark ? .35 : .15,
|
|
)!;
|
|
}
|
|
|
|
/// Composer action bar composites the dark elevated-secondary alpha surface.
|
|
static Color composerUtilityBackground(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return theme.brightness == Brightness.dark
|
|
? Color.alphaBlend(
|
|
AppColors.penDark.composerUtilityOverlay,
|
|
theme.colorScheme.surface,
|
|
)
|
|
: theme.colorScheme.surfaceContainerLow;
|
|
}
|
|
|
|
static TextStyle composerHintStyle(BuildContext context) {
|
|
final tertiary = AppSidebarColors.of(context).tertiary;
|
|
return composerTextStyle(context)
|
|
.copyWith(color: tertiary.withValues(alpha: tertiary.a * 0.5));
|
|
}
|
|
|
|
/// Match the glyph size, rather than the editable line's leading.
|
|
static double inputCursorHeight(BuildContext context) =>
|
|
MediaQuery.textScalerOf(context).scale(inputTextStyle(context).fontSize!);
|
|
|
|
static double composerCursorHeight(BuildContext context) =>
|
|
MediaQuery.textScalerOf(context)
|
|
.scale(composerTextStyle(context).fontSize!);
|
|
|
|
static const composerInputDecoration = InputDecoration(
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
disabledBorder: InputBorder.none,
|
|
filled: false,
|
|
contentPadding: EdgeInsets.only(left: 12, top: 12, right: 8),
|
|
);
|
|
|
|
static ThemeData _build(AppColors palette) {
|
|
final brightness = palette.brightness;
|
|
final colors = ColorScheme(
|
|
brightness: brightness,
|
|
primary: palette.primary,
|
|
onPrimary: palette.primaryForeground,
|
|
primaryContainer: palette.accent,
|
|
onPrimaryContainer: palette.foreground,
|
|
primaryFixed: palette.primary,
|
|
primaryFixedDim: palette.mutedForeground,
|
|
onPrimaryFixed: palette.card,
|
|
onPrimaryFixedVariant: palette.accent,
|
|
secondary: palette.foreground,
|
|
onSecondary: palette.primaryForeground,
|
|
secondaryContainer: palette.accent,
|
|
onSecondaryContainer: palette.foreground,
|
|
secondaryFixed: palette.primary,
|
|
secondaryFixedDim: palette.mutedForeground,
|
|
onSecondaryFixed: palette.card,
|
|
onSecondaryFixedVariant: palette.accent,
|
|
tertiary: palette.foreground,
|
|
onTertiary: palette.primaryForeground,
|
|
tertiaryContainer: palette.accent,
|
|
onTertiaryContainer: palette.foreground,
|
|
tertiaryFixed: palette.primary,
|
|
tertiaryFixedDim: palette.mutedForeground,
|
|
onTertiaryFixed: palette.card,
|
|
onTertiaryFixedVariant: palette.accent,
|
|
surface: palette.background,
|
|
onSurface: palette.foreground,
|
|
onSurfaceVariant: palette.mutedForeground,
|
|
surfaceDim: palette.background,
|
|
surfaceBright: palette.accent,
|
|
surfaceContainerLowest: palette.background,
|
|
surfaceContainerLow: palette.sidebar,
|
|
surfaceContainer: palette.card,
|
|
surfaceContainerHigh: palette.accent,
|
|
surfaceContainerHighest: palette.accent,
|
|
surfaceTint: Colors.transparent,
|
|
outline: palette.ring,
|
|
outlineVariant: palette.border,
|
|
inverseSurface: palette.foreground,
|
|
onInverseSurface: palette.card,
|
|
inversePrimary: palette.accent,
|
|
error: palette.destructive,
|
|
onError: palette.background,
|
|
errorContainer: palette.destructiveBackground,
|
|
onErrorContainer: palette.destructive,
|
|
shadow: Colors.black,
|
|
scrim: Colors.black,
|
|
);
|
|
final text = _typography(palette);
|
|
final controlShape = const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(AppRadius.menuItem)),
|
|
);
|
|
final cardShape = RoundedRectangleBorder(
|
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
|
side: BorderSide(color: palette.border),
|
|
);
|
|
const dialogShape = RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(AppRadius.dialog)),
|
|
);
|
|
final inputBorder = OutlineInputBorder(
|
|
borderRadius: const BorderRadius.all(Radius.circular(AppRadius.large)),
|
|
borderSide: BorderSide(color: palette.input),
|
|
);
|
|
final buttonStyle = ButtonStyle(
|
|
shape: WidgetStatePropertyAll(controlShape),
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size(0, AppControlSize.standard),
|
|
),
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
textStyle: WidgetStatePropertyAll(text.labelLarge),
|
|
iconSize: const WidgetStatePropertyAll(AppIconSize.standard),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.controlHorizontal,
|
|
vertical: AppSpacing.tiny,
|
|
),
|
|
),
|
|
overlayColor: WidgetStateProperty.resolveWith((states) {
|
|
if (states.contains(WidgetState.focused)) {
|
|
return palette.ring.withValues(alpha: 0.3);
|
|
}
|
|
if (states.contains(WidgetState.hovered) ||
|
|
states.contains(WidgetState.pressed)) {
|
|
return palette.foreground.withValues(alpha: 0.05);
|
|
}
|
|
return null;
|
|
}),
|
|
);
|
|
final foreground = WidgetStateProperty.resolveWith<Color>(
|
|
(states) => states.contains(WidgetState.disabled)
|
|
? palette.foreground.withValues(alpha: 0.5)
|
|
: palette.foreground,
|
|
);
|
|
return ThemeData(
|
|
brightness: brightness,
|
|
useMaterial3: true,
|
|
colorScheme: colors,
|
|
fontFamily: systemFontFamily(defaultTargetPlatform),
|
|
fontFamilyFallback: systemFontFamilyFallback(defaultTargetPlatform),
|
|
textTheme: text,
|
|
primaryTextTheme: text,
|
|
scaffoldBackgroundColor: palette.background,
|
|
canvasColor: palette.background,
|
|
disabledColor: palette.foreground.withValues(alpha: 0.5),
|
|
hoverColor: palette.accent,
|
|
focusColor: palette.ring.withValues(alpha: 0.3),
|
|
splashFactory: NoSplash.splashFactory,
|
|
dividerColor: palette.divider,
|
|
visualDensity: VisualDensity.standard,
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
appBarTheme: AppBarThemeData(
|
|
backgroundColor: palette.background,
|
|
foregroundColor: palette.foreground,
|
|
surfaceTintColor: Colors.transparent,
|
|
elevation: 0,
|
|
titleTextStyle: text.titleLarge,
|
|
toolbarHeight: AppControlSize.panelHeader,
|
|
),
|
|
dividerTheme: DividerThemeData(
|
|
color: palette.divider,
|
|
thickness: brightness == Brightness.dark ? 0.5 : 1,
|
|
space: 1,
|
|
),
|
|
iconTheme: IconThemeData(
|
|
color: palette.mutedForeground,
|
|
size: AppIconSize.standard,
|
|
),
|
|
iconButtonTheme: IconButtonThemeData(
|
|
style: _iconButtonStyle(palette.foreground, brightness)
|
|
.merge(buttonStyle)
|
|
.copyWith(
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size.square(AppControlSize.compact),
|
|
),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.all(AppSpacing.tiny),
|
|
),
|
|
),
|
|
),
|
|
cardTheme: CardThemeData(
|
|
color: palette.card,
|
|
surfaceTintColor: Colors.transparent,
|
|
elevation: 0,
|
|
margin: EdgeInsets.zero,
|
|
shape: cardShape,
|
|
clipBehavior: Clip.antiAlias,
|
|
),
|
|
dialogTheme: DialogThemeData(
|
|
backgroundColor: palette.popover,
|
|
surfaceTintColor: Colors.transparent,
|
|
shape: dialogShape,
|
|
titleTextStyle: text.headlineSmall?.copyWith(
|
|
fontWeight: FontWeight.w600,
|
|
fontVariations: const [FontVariation('wght', 600)],
|
|
),
|
|
contentTextStyle: text.bodyMedium?.copyWith(
|
|
fontSize: 14,
|
|
height: 20 / 14,
|
|
),
|
|
actionsPadding: const EdgeInsets.all(AppSpacing.large),
|
|
barrierColor: Colors.black.withValues(alpha: 0.5),
|
|
),
|
|
inputDecorationTheme: InputDecorationThemeData(
|
|
constraints: const BoxConstraints(minHeight: AppControlSize.input),
|
|
isDense: true,
|
|
filled: true,
|
|
fillColor: palette.inputFill,
|
|
border: inputBorder,
|
|
enabledBorder: inputBorder,
|
|
disabledBorder: inputBorder,
|
|
focusedBorder: inputBorder.copyWith(
|
|
borderSide: BorderSide(color: palette.ring, width: 2),
|
|
),
|
|
errorBorder: inputBorder.copyWith(
|
|
borderSide: BorderSide(color: palette.destructive),
|
|
),
|
|
focusedErrorBorder: inputBorder.copyWith(
|
|
borderSide: BorderSide(color: palette.destructive, width: 2),
|
|
),
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.controlHorizontal,
|
|
vertical: AppSpacing.inputVertical,
|
|
),
|
|
hintStyle: text.bodyMedium?.copyWith(color: palette.mutedForeground),
|
|
labelStyle: text.bodyMedium?.copyWith(color: palette.mutedForeground),
|
|
errorStyle: text.bodySmall?.copyWith(color: palette.destructive),
|
|
),
|
|
textSelectionTheme: TextSelectionThemeData(
|
|
cursorColor: palette.foreground,
|
|
selectionColor: palette.ring.withValues(alpha: 0.5),
|
|
selectionHandleColor: palette.foreground,
|
|
),
|
|
filledButtonTheme: FilledButtonThemeData(
|
|
style: buttonStyle.copyWith(
|
|
backgroundColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.disabled)
|
|
? palette.buttonBackground.withValues(alpha: 0.5)
|
|
: palette.buttonBackground,
|
|
),
|
|
foregroundColor: WidgetStatePropertyAll(palette.foreground),
|
|
side: WidgetStatePropertyAll(BorderSide(color: palette.buttonBorder)),
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: buttonStyle.copyWith(
|
|
side: WidgetStatePropertyAll(BorderSide(color: palette.buttonBorder)),
|
|
foregroundColor: foreground,
|
|
),
|
|
),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: buttonStyle.copyWith(foregroundColor: foreground),
|
|
),
|
|
popupMenuTheme: PopupMenuThemeData(
|
|
textStyle: text.bodyMedium,
|
|
color: palette.popover,
|
|
surfaceTintColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppMenuMetrics.radius),
|
|
side: BorderSide(
|
|
color: palette.border,
|
|
width: AppMenuMetrics.borderWidth,
|
|
),
|
|
),
|
|
menuPadding: const EdgeInsets.all(AppMenuMetrics.gutter),
|
|
),
|
|
menuTheme: MenuThemeData(
|
|
style: MenuStyle(
|
|
backgroundColor: WidgetStatePropertyAll(palette.popover),
|
|
surfaceTintColor: const WidgetStatePropertyAll(Colors.transparent),
|
|
side: WidgetStatePropertyAll(
|
|
BorderSide(
|
|
color: palette.border,
|
|
width: AppMenuMetrics.borderWidth,
|
|
),
|
|
),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.all(AppMenuMetrics.gutter),
|
|
),
|
|
shape: const WidgetStatePropertyAll(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(AppMenuMetrics.radius),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
menuButtonTheme: MenuButtonThemeData(
|
|
style: buttonStyle.copyWith(
|
|
textStyle: WidgetStatePropertyAll(
|
|
text.bodyMedium?.copyWith(
|
|
height: AppMenuMetrics.lineHeight / AppMenuMetrics.fontSize,
|
|
),
|
|
),
|
|
minimumSize: const WidgetStatePropertyAll(
|
|
Size(0, AppMenuMetrics.rowHeight),
|
|
),
|
|
iconSize: const WidgetStatePropertyAll(AppMenuMetrics.iconSize),
|
|
padding: const WidgetStatePropertyAll(
|
|
EdgeInsets.symmetric(
|
|
horizontal: AppMenuMetrics.iconGap,
|
|
vertical: 5,
|
|
),
|
|
),
|
|
shape: const WidgetStatePropertyAll(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(AppMenuMetrics.itemRadius),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
listTileTheme: ListTileThemeData(
|
|
minTileHeight: AppControlSize.standard,
|
|
minVerticalPadding: AppSpacing.tiny,
|
|
horizontalTitleGap: AppSpacing.small,
|
|
minLeadingWidth: AppIconSize.standard,
|
|
iconColor: palette.mutedForeground,
|
|
textColor: palette.foreground,
|
|
selectedColor: palette.foreground,
|
|
selectedTileColor: palette.accent,
|
|
titleTextStyle: text.bodyMedium,
|
|
subtitleTextStyle: text.bodySmall,
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.compact,
|
|
),
|
|
),
|
|
snackBarTheme: SnackBarThemeData(
|
|
backgroundColor: palette.card,
|
|
contentTextStyle: text.bodyMedium,
|
|
behavior: SnackBarBehavior.floating,
|
|
shape: cardShape,
|
|
),
|
|
tooltipTheme: TooltipThemeData(
|
|
textStyle: text.bodySmall?.copyWith(color: palette.card),
|
|
decoration: ShapeDecoration(
|
|
color: palette.foreground,
|
|
shape: controlShape,
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.small,
|
|
vertical: AppSpacing.tiny,
|
|
),
|
|
),
|
|
progressIndicatorTheme: ProgressIndicatorThemeData(
|
|
color: palette.primary,
|
|
linearMinHeight: 2,
|
|
),
|
|
checkboxTheme: CheckboxThemeData(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppRadius.small),
|
|
),
|
|
side: BorderSide(color: palette.input),
|
|
fillColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.selected)
|
|
? palette.primary
|
|
: palette.inputFill,
|
|
),
|
|
checkColor: WidgetStatePropertyAll(palette.primaryForeground),
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
),
|
|
switchTheme: SwitchThemeData(
|
|
trackOutlineColor: const WidgetStatePropertyAll(Colors.transparent),
|
|
trackColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.selected)
|
|
? palette.primary
|
|
: palette.input,
|
|
),
|
|
thumbColor: WidgetStateProperty.resolveWith(
|
|
(states) => states.contains(WidgetState.selected)
|
|
? palette.primaryForeground
|
|
: palette.foreground,
|
|
),
|
|
),
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
thickness: const WidgetStatePropertyAll(6),
|
|
radius: const Radius.circular(3),
|
|
thumbColor: WidgetStateProperty.resolveWith((states) {
|
|
final interacting =
|
|
states.contains(WidgetState.hovered) ||
|
|
states.contains(WidgetState.dragged) ||
|
|
states.contains(WidgetState.pressed);
|
|
return palette.foreground.withValues(
|
|
alpha: brightness == Brightness.dark
|
|
? (interacting ? .156 : .084)
|
|
: (interacting ? .126 : .084),
|
|
);
|
|
}),
|
|
trackColor: const WidgetStatePropertyAll(Colors.transparent),
|
|
trackBorderColor: const WidgetStatePropertyAll(Colors.transparent),
|
|
),
|
|
extensions: [
|
|
AppSurfaces(
|
|
previewBackground: Colors.black,
|
|
composerBackground: palette.composer,
|
|
popoverBackground: palette.popover,
|
|
errorText: text.bodyMedium!.copyWith(color: palette.destructive),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
static TextTheme _typography(AppColors palette) {
|
|
TextStyle style(
|
|
double size,
|
|
double lineHeight, {
|
|
FontWeight weight = FontWeight.w400,
|
|
Color? color,
|
|
}) => TextStyle(
|
|
inherit: false,
|
|
fontFamily: systemFontFamily(defaultTargetPlatform),
|
|
fontFamilyFallback: systemFontFamilyFallback(defaultTargetPlatform),
|
|
textBaseline: TextBaseline.alphabetic,
|
|
fontSize: size,
|
|
height: lineHeight / size,
|
|
fontWeight: weight,
|
|
letterSpacing: 0,
|
|
color: color ?? palette.foreground,
|
|
);
|
|
return TextTheme(
|
|
displayLarge: style(48, 56, weight: FontWeight.w600),
|
|
displayMedium: style(36, 44, weight: FontWeight.w600),
|
|
displaySmall: style(30, 38, weight: FontWeight.w600),
|
|
headlineLarge: style(28, 36, weight: FontWeight.w600),
|
|
headlineMedium: style(24, 32, weight: FontWeight.w600),
|
|
headlineSmall: style(20, 28, weight: FontWeight.w600),
|
|
titleLarge: style(18, 24, weight: FontWeight.w600),
|
|
titleMedium: style(14, 21, weight: FontWeight.w500),
|
|
titleSmall: style(14, 20, weight: FontWeight.w500),
|
|
bodyLarge: style(16, 24),
|
|
bodyMedium: style(13, 20),
|
|
bodySmall: style(12, 18, color: palette.mutedForeground),
|
|
labelLarge: style(13, 20, weight: FontWeight.w500),
|
|
labelMedium: style(12, 18, weight: FontWeight.w500),
|
|
labelSmall: style(12, 18, color: palette.mutedForeground),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Pen colors with editor-specific workspace and side-panel surfaces.
|
|
enum AppColors {
|
|
penLight,
|
|
penDark;
|
|
|
|
bool get _dark => this == penDark;
|
|
Brightness get brightness => _dark ? Brightness.dark : Brightness.light;
|
|
|
|
Color get background => switch (this) {
|
|
penLight => const Color(0xFFF6F6F6),
|
|
penDark => const Color(0xFF111111),
|
|
};
|
|
Color get foreground => switch (this) {
|
|
penDark => const Color(0xFFFCFCFC),
|
|
penLight => const Color(0xFF020202),
|
|
};
|
|
Color get card => switch (this) {
|
|
penLight => const Color(0xFFFAFAFA),
|
|
penDark => const Color(0xFF27272A),
|
|
};
|
|
Color get popover => _dark ? const Color(0xFF242424) : card;
|
|
Color get sidebar => switch (this) {
|
|
penLight => const Color(0xFFFAFAFA),
|
|
// Project sidebar sampled from Codex's opaque-window screenshot (2026-09-28).
|
|
penDark => const Color(0xFF151515),
|
|
};
|
|
Color get primary => switch (this) {
|
|
penLight => const Color(0xFF18181B),
|
|
penDark => const Color(0xFFF4F4F5),
|
|
};
|
|
Color get primaryForeground => switch (this) {
|
|
penLight => const Color(0xFFFAFAFA),
|
|
penDark => const Color(0xFF18181B),
|
|
};
|
|
Color get accent => switch (this) {
|
|
penDark => const Color(0xFF3F3F46),
|
|
penLight => const Color(0xFFECECEE),
|
|
};
|
|
Color get mutedForeground => switch (this) {
|
|
penLight => const Color(0xFF71717A),
|
|
penDark => const Color(0xFFFCFCFC).withValues(alpha: 0.71),
|
|
};
|
|
Color get ring => const Color(0xFF3B82F6);
|
|
Color get border => switch (this) {
|
|
penLight => const Color(0xFFE4E4E7),
|
|
penDark => const Color(0xFFFCFCFC).withValues(alpha: 0.084),
|
|
};
|
|
Color get divider => _dark ? const Color(0xFF303030) : border;
|
|
Color get input => switch (this) {
|
|
penLight => const Color(0x0A020202),
|
|
penDark => const Color(0x1AC8C8C8),
|
|
};
|
|
Color get inputFill => switch (this) {
|
|
penLight => const Color(0x0A020202),
|
|
penDark => const Color(0x1AC8C8C8),
|
|
};
|
|
Color get buttonBackground => switch (this) {
|
|
penLight => const Color(0xFFFAFAFA),
|
|
penDark => const Color(0xFF18181B),
|
|
};
|
|
Color get buttonBorder => switch (this) {
|
|
penLight => const Color(0xFFE4E4E7),
|
|
penDark => const Color(0xFF38383C),
|
|
};
|
|
Color get destructive =>
|
|
_dark ? const Color(0xFFFF6467) : const Color(0xFFE7000B);
|
|
Color get destructiveBackground =>
|
|
destructive.withValues(alpha: _dark ? 0.2 : 0.1);
|
|
|
|
Color get visualClip => _dark ? const Color(0xFF2F2F2F) : accent;
|
|
Color get composer => _dark ? const Color(0xFF2F2F2F) : background;
|
|
Color get composerUtilityOverlay =>
|
|
_dark ? foreground.withValues(alpha: .032) : Colors.transparent;
|
|
Color get dialogBorder => _dark ? const Color(0xFF3C3C3C) : border;
|
|
Color get dialogInputBackground =>
|
|
_dark ? const Color(0xFF262626) : background;
|
|
Color get dialogFocusBorder => _dark ? const Color(0xFF6084AF) : ring;
|
|
Color get dialogActionBackground =>
|
|
_dark ? const Color(0xFF2B2B2B) : const Color(0xFFF0F0F0);
|
|
Color get settingsSidebar => _dark ? const Color(0xFF141414) : card;
|
|
Color get settingsContainer => _dark ? const Color(0xFF1C1C1C) : card;
|
|
Color get settingsBorder => _dark ? const Color(0xFF2E2E2E) : border;
|
|
Color get settingsControlBackground =>
|
|
_dark ? const Color(0xFF262626) : background;
|
|
Color get settingsSwitchTrack =>
|
|
_dark ? const Color(0xFF333333) : const Color(0xFFD0D0D0);
|
|
static const settingsSwitchAccent = Color(0xFF007AFF);
|
|
|
|
AppSidebarColors resolveSidebarColors(
|
|
ColorScheme colors, {
|
|
required Color disabledColor,
|
|
}) {
|
|
if (_dark) {
|
|
final ink = foreground;
|
|
return AppSidebarColors(
|
|
primary: ink.withValues(alpha: .85),
|
|
secondary: ink.withValues(alpha: .71),
|
|
tertiary: ink.withValues(alpha: .498),
|
|
disabled: ink.withValues(alpha: .85 * .6),
|
|
hover: ink.withValues(alpha: .078),
|
|
section: ink.withValues(alpha: .498 * .75),
|
|
);
|
|
}
|
|
return AppSidebarColors(
|
|
primary: colors.onSurface,
|
|
secondary: colors.onSurfaceVariant,
|
|
tertiary: colors.onSurfaceVariant,
|
|
disabled: disabledColor,
|
|
hover: colors.onSurface.withValues(alpha: .0535),
|
|
section: colors.onSurfaceVariant.withValues(alpha: .75),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Styles with product semantics that Material's built-in themes do not expose.
|
|
@immutable
|
|
class AppSurfaces extends ThemeExtension<AppSurfaces> {
|
|
const AppSurfaces({
|
|
required this.previewBackground,
|
|
required this.composerBackground,
|
|
required this.popoverBackground,
|
|
required this.errorText,
|
|
});
|
|
final Color previewBackground;
|
|
final Color composerBackground;
|
|
final Color popoverBackground;
|
|
final TextStyle errorText;
|
|
|
|
static AppSurfaces of(BuildContext context) =>
|
|
Theme.of(context).extension<AppSurfaces>()!;
|
|
|
|
@override
|
|
AppSurfaces copyWith({
|
|
Color? previewBackground,
|
|
Color? composerBackground,
|
|
Color? popoverBackground,
|
|
TextStyle? errorText,
|
|
}) => AppSurfaces(
|
|
previewBackground: previewBackground ?? this.previewBackground,
|
|
composerBackground: composerBackground ?? this.composerBackground,
|
|
popoverBackground: popoverBackground ?? this.popoverBackground,
|
|
errorText: errorText ?? this.errorText,
|
|
);
|
|
|
|
@override
|
|
AppSurfaces lerp(covariant AppSurfaces? other, double t) {
|
|
if (other == null) return this;
|
|
return AppSurfaces(
|
|
previewBackground: Color.lerp(
|
|
previewBackground,
|
|
other.previewBackground,
|
|
t,
|
|
)!,
|
|
composerBackground: Color.lerp(
|
|
composerBackground,
|
|
other.composerBackground,
|
|
t,
|
|
)!,
|
|
popoverBackground: Color.lerp(
|
|
popoverBackground,
|
|
other.popoverBackground,
|
|
t,
|
|
)!,
|
|
errorText: TextStyle.lerp(errorText, other.errorText, t)!,
|
|
);
|
|
}
|
|
}
|
|
|
|
abstract final class AppSidebarMetrics {
|
|
static const rowHeight = 30.0;
|
|
static const modeHeight = 32.0;
|
|
static const outerPadding = 8.0;
|
|
static const cellPadding = 8.0;
|
|
static const iconSize = 16.0;
|
|
static const iconGap = 0.0;
|
|
// hZ: row-sized icon slot, -3px margins, and 4px padding on each side.
|
|
static const iconSlotWidth = rowHeight + 2;
|
|
static const actionSize = 24.0;
|
|
static const radius = 10.0;
|
|
static const fontSize = 14.0;
|
|
static const conversationFontSize = 14.0;
|
|
static const conversationLineHeight = 20 / conversationFontSize;
|
|
static const lineHeight = 1.5;
|
|
static const sectionFontSize = 14.0;
|
|
static const sectionHeight = 25.0;
|
|
static const sectionGap = 4.0;
|
|
static const rowGap = 1.0;
|
|
static const projectGap = 1.0;
|
|
static const hintFontSize = 12.0;
|
|
static const titleFontSize = 18.0;
|
|
static const titleLineHeight = 24 / titleFontSize;
|
|
static const textInset = iconSlotWidth;
|
|
static const rowPadding = EdgeInsets.symmetric(horizontal: outerPadding);
|
|
}
|
|
|
|
/// Sidebar typography retains its own size and foreground hierarchy.
|
|
abstract final class AppSidebarTypography {
|
|
static TextStyle style(
|
|
BuildContext context, {
|
|
double fontSize = AppSidebarMetrics.fontSize,
|
|
double height = AppSidebarMetrics.lineHeight,
|
|
FontWeight weight = FontWeight.w400,
|
|
Color? color,
|
|
}) => TextStyle(
|
|
fontFamily: AppTheme.systemFontFamily(Theme.of(context).platform),
|
|
fontFamilyFallback: AppTheme.systemFontFamilyFallback(
|
|
Theme.of(context).platform,
|
|
),
|
|
fontSize: fontSize,
|
|
height: height,
|
|
fontWeight: weight,
|
|
color: color ?? AppSidebarColors.of(context).primary,
|
|
);
|
|
}
|
|
|
|
/// Text hierarchy for project navigation, independent of editor text colors.
|
|
@immutable
|
|
class AppSidebarColors {
|
|
const AppSidebarColors({
|
|
required this.primary,
|
|
required this.secondary,
|
|
required this.tertiary,
|
|
required this.disabled,
|
|
required this.hover,
|
|
required this.section,
|
|
});
|
|
|
|
final Color primary;
|
|
final Color secondary;
|
|
final Color tertiary;
|
|
final Color disabled;
|
|
final Color hover;
|
|
final Color section;
|
|
|
|
static AppSidebarColors of(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final palette = theme.brightness == Brightness.dark
|
|
? AppColors.penDark
|
|
: AppColors.penLight;
|
|
return palette.resolveSidebarColors(
|
|
theme.colorScheme,
|
|
disabledColor: theme.disabledColor,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Shared spacing for compact controls and unframed editor panels.
|
|
abstract final class AppSpacing {
|
|
static const hairline = 2.0;
|
|
static const tiny = 4.0;
|
|
static const gap = 6.0;
|
|
static const small = 8.0;
|
|
static const itemVertical = 10.0;
|
|
static const controlHorizontal = 8.0;
|
|
static const panelContentHorizontal = gap + controlHorizontal;
|
|
static const inputVertical = 3.0;
|
|
static const compact = 12.0;
|
|
static const medium = 16.0;
|
|
static const large = 20.0;
|
|
static const extraLarge = 24.0;
|
|
static const dialogHorizontal = 32.0;
|
|
static const page = 16.0;
|
|
static const emptyState = 64.0;
|
|
static const panelSection = EdgeInsets.symmetric(
|
|
horizontal: panelContentHorizontal,
|
|
vertical: small,
|
|
);
|
|
}
|
|
|
|
/// Compact desktop controls with slightly softer dialog and card corners.
|
|
abstract final class AppRadius {
|
|
static const extraSmall = 3.0;
|
|
static const large = 6.0;
|
|
static const small = 4.0;
|
|
static const medium = 5.0;
|
|
static const menuItem = 8.0;
|
|
static const extraLarge = 10.0;
|
|
static const dialog = 20.0;
|
|
static const pill = 999.0;
|
|
}
|
|
|
|
abstract final class AppSettingsMetrics {
|
|
static const contentPadding = EdgeInsets.all(AppSpacing.large);
|
|
static const rowVerticalPadding = AppSpacing.compact;
|
|
static const controlHeight = 28.0;
|
|
static const inputHeight = 36.0;
|
|
static const controlWidth = 144.0;
|
|
static const contentWidth = 728.0;
|
|
static const cardRadius = 16.0;
|
|
}
|
|
|
|
abstract final class AppControlSize {
|
|
static const compact = 24.0;
|
|
static const small = 24.0;
|
|
static const standard = 24.0;
|
|
static const input = 24.0;
|
|
static const propertyControl = 28.0;
|
|
static const propertyItem = 32.0;
|
|
static const headerButton = 28.0;
|
|
static const panelHeader = 46.0;
|
|
static const panelToolbar = 40.0;
|
|
}
|
|
|
|
abstract final class AppIconSize {
|
|
static const header = 16.0;
|
|
static const small = 16.0;
|
|
static const standard = 16.0;
|
|
static const emptyState = 24.0;
|
|
static const project = 40.0;
|
|
}
|