feat(ui): align desktop controls and inspector typography with Figma UI3

This commit is contained in:
lingjhf committed 2026-10-09 19:20:54 +08:00
1 parent abc1868550
commit bc3fdd6119
45 files changed
+1806 -227

No files matched your search

@@ -0,0 +1,92 @@
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION AND CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
@@ -63,6 +63,8 @@ abstract final class AppIcons {
static const IconData unlock = PhosphorIconsRegular.lockOpen;
static const IconData fullscreen = PhosphorIconsRegular.arrowsOut;
static const IconData exitFullscreen = PhosphorIconsRegular.arrowsIn;
static const IconData independentCorners = PhosphorIconsRegular.cornersOut;
static const IconData cornerRadius = PhosphorIconsRegular.rectangle;
static const IconData fitContent = PhosphorIconsRegular.cornersIn;
static const IconData menu = PhosphorIconsRegular.list;
static const IconData sidebar = PhosphorIconsRegular.sidebarSimple;
+202 -61
View File
@@ -174,8 +174,10 @@ abstract final class AppTheme {
: null,
textStyle: WidgetStatePropertyAll(
theme.textTheme.labelLarge?.copyWith(
fontSize: desktop ? 13 : 12,
height: 1.3,
fontSize: desktop ? AppInspectorMetrics.fontSize : 12,
height: desktop
? AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize
: 1.3,
fontWeight: desktop && selected ? FontWeight.w500 : FontWeight.w400,
fontVariations: desktop
? [FontVariation('wght', selected ? 500 : 400)]
@@ -188,14 +190,14 @@ abstract final class AppTheme {
foregroundColor: WidgetStatePropertyAll(
selected
? desktop
? colors.primary
? colors.onSurface
: colors.onSurface
: colors.onSurfaceVariant,
),
backgroundColor: WidgetStatePropertyAll(
selected
? desktop
? colors.primary.withValues(alpha: .12)
? colors.surfaceContainer
: colors.onSurface.withValues(alpha: .05)
: Colors.transparent,
),
@@ -255,6 +257,9 @@ abstract final class AppTheme {
static Color comboboxBackground(BuildContext context) {
final theme = Theme.of(context);
if (isCompactInspector(context)) {
return theme.inputDecorationTheme.fillColor!;
}
return theme.brightness == Brightness.dark
? theme.colorScheme.surfaceContainerHighest.withValues(alpha: .3)
: Colors.transparent;
@@ -374,34 +379,12 @@ abstract final class AppTheme {
/// Desktop inspectors use a denser scale than dialogs and settings.
static ThemeData propertiesPanelTheme(ThemeData theme) {
final desktop = theme.extension<DesktopControlDensity>() != null;
if (desktop) return _desktopPropertiesPanelTheme(theme);
final colors = theme.colorScheme;
final panelText = desktop
? theme.textTheme.copyWith(
bodyMedium: theme.textTheme.bodyMedium?.copyWith(
fontSize: 13,
height: 20 / 13,
leadingDistribution: TextLeadingDistribution.even,
),
bodySmall: theme.textTheme.bodySmall?.copyWith(
fontSize: 12,
height: 16 / 12,
leadingDistribution: TextLeadingDistribution.even,
),
)
: theme.textTheme;
final actionSize = desktop
? AppInspectorMetrics.action
: AppControlSize.propertyControl;
final panelText = theme.textTheme;
const actionSize = AppControlSize.propertyControl;
ButtonStyle? buttonStyle(ButtonStyle? style) => style?.copyWith(
textStyle: WidgetStatePropertyAll(panelText.labelLarge),
minimumSize: desktop
? const WidgetStatePropertyAll(Size(0, AppInspectorMetrics.input))
: style.minimumSize,
padding: desktop
? const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 8, vertical: 4),
)
: style.padding,
);
final panelColors = colors.copyWith(surface: colors.surfaceContainerLow);
final composerBackground = theme
@@ -415,19 +398,13 @@ abstract final class AppTheme {
borderSide: BorderSide.none,
);
return theme.copyWith(
extensions: [
...theme.extensions.values,
if (desktop) const InspectorControlDensity(),
],
canvasColor: colors.surfaceContainerLow,
colorScheme: panelColors,
textTheme: panelText,
primaryTextTheme: panelText,
inputDecorationTheme: theme.inputDecorationTheme.copyWith(
constraints: BoxConstraints(
minHeight: desktop
? AppInspectorMetrics.input
: AppControlSize.propertyControl,
constraints: const BoxConstraints(
minHeight: AppControlSize.propertyControl,
),
contentPadding: EdgeInsets.symmetric(
horizontal: AppSpacing.controlHorizontal,
@@ -468,14 +445,151 @@ abstract final class AppTheme {
);
}
static ThemeData _desktopPropertiesPanelTheme(ThemeData theme) {
// UI3 – Figma's UI Kit, Templates / design.sidebar.right.
// The workspace owns the panel background and accents.
final dark = theme.brightness == Brightness.dark;
final background = theme.colorScheme.surfaceContainerLow;
final inputBackground = dark
? const Color(0xFF383838)
: const Color(0xFFF5F5F5);
final ink = dark ? Colors.white : Colors.black.withValues(alpha: .9);
final secondaryInk = dark
? Colors.white.withValues(alpha: .7)
: Colors.black.withValues(alpha: .5);
final divider = dark ? const Color(0xFF444444) : const Color(0xFFE6E6E6);
final colors = theme.colorScheme.copyWith(
surface: background,
surfaceContainer: inputBackground,
surfaceContainerHighest: inputBackground,
onSurface: ink,
onSurfaceVariant: secondaryInk,
outlineVariant: divider,
);
final body = theme.textTheme.bodyMedium!.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontWeight: FontWeight.w400,
fontVariations: const [FontVariation('wght', 450)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
color: ink,
leadingDistribution: TextLeadingDistribution.even,
);
final strong = body.copyWith(
fontWeight: FontWeight.w600,
fontVariations: const [FontVariation('wght', 550)],
);
final text = theme.textTheme.copyWith(
bodyLarge: body,
bodyMedium: body,
bodySmall: body.copyWith(color: secondaryInk),
labelLarge: body,
labelMedium: body,
labelSmall: body.copyWith(color: secondaryInk),
titleSmall: strong.copyWith(
fontSize: 13,
height: 22 / 13,
letterSpacing: -.0325,
),
);
const shape = RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
);
const inputShape = OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
borderSide: BorderSide.none,
);
ButtonStyle? button(ButtonStyle? style) => style?.copyWith(
textStyle: WidgetStatePropertyAll(body),
minimumSize: const WidgetStatePropertyAll(
Size(0, AppInspectorMetrics.input),
),
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 8),
),
shape: const WidgetStatePropertyAll(shape),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.standard,
);
return theme.copyWith(
extensions: [...theme.extensions.values, const InspectorControlDensity()],
canvasColor: background,
colorScheme: colors,
textTheme: text,
primaryTextTheme: text,
dividerColor: divider,
dividerTheme: theme.dividerTheme.copyWith(
color: divider,
thickness: 1,
space: 1,
),
iconTheme: theme.iconTheme.copyWith(color: secondaryInk, size: 16),
inputDecorationTheme: theme.inputDecorationTheme.copyWith(
constraints: const BoxConstraints(minHeight: AppInspectorMetrics.input),
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
fillColor: inputBackground,
hintStyle: body.copyWith(color: secondaryInk),
border: inputShape,
enabledBorder: inputShape,
disabledBorder: inputShape,
focusedBorder: inputShape.copyWith(
borderSide: BorderSide(color: colors.primary),
),
errorBorder: inputShape.copyWith(
borderSide: BorderSide(color: colors.error),
),
focusedErrorBorder: inputShape.copyWith(
borderSide: BorderSide(color: colors.error),
),
),
iconButtonTheme: IconButtonThemeData(
style: theme.iconButtonTheme.style?.copyWith(
minimumSize: const WidgetStatePropertyAll(
Size.square(AppInspectorMetrics.action),
),
maximumSize: const WidgetStatePropertyAll(
Size.square(AppInspectorMetrics.action),
),
fixedSize: const WidgetStatePropertyAll(
Size.square(AppInspectorMetrics.action),
),
shape: const WidgetStatePropertyAll(shape),
foregroundColor: WidgetStateProperty.resolveWith(
(states) => states.contains(WidgetState.disabled)
? secondaryInk.withValues(alpha: .38)
: states.contains(WidgetState.selected)
? colors.primary
: secondaryInk,
),
),
),
textButtonTheme: TextButtonThemeData(
style: button(theme.textButtonTheme.style),
),
filledButtonTheme: FilledButtonThemeData(
style: button(theme.filledButtonTheme.style),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: button(theme.outlinedButtonTheme.style),
),
);
}
static bool isCompactInspector(BuildContext context) =>
Theme.of(context).extension<InspectorControlDensity>() != null;
static EdgeInsets propertySectionPadding(BuildContext context) =>
isDesktop(context)
? const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
vertical: AppInspectorMetrics.groupGap / 2,
? const EdgeInsets.fromLTRB(
AppInspectorMetrics.padding,
0,
AppInspectorMetrics.trailingPadding,
AppInspectorMetrics.groupGap,
)
: AppSpacing.panelSection;
@@ -489,8 +603,12 @@ abstract final class AppTheme {
static TextStyle propertyLabelStyle(BuildContext context) {
final theme = Theme.of(context);
return theme.textTheme.bodyMedium!.copyWith(
fontSize: isCompactInspector(context) ? 12 : null,
height: isCompactInspector(context) ? 16 / 12 : null,
fontSize: isCompactInspector(context)
? AppInspectorMetrics.fontSize
: null,
height: isCompactInspector(context)
? AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize
: null,
leadingDistribution: TextLeadingDistribution.even,
color: theme.colorScheme.onSurfaceVariant,
);
@@ -500,10 +618,12 @@ abstract final class AppTheme {
Theme.of(context).textTheme.bodyMedium!
.copyWith(fontSize: 13, height: 18 / 13);
/// Codex desktop's compact heading-sm: 13px, 1.4 line height, medium ink.
/// Inspector group titles share the UI3 input scale.
static TextStyle propertySectionTitleStyle(BuildContext context) =>
Theme.of(context).textTheme.labelLarge!.copyWith(
height: 1.4,
height: isCompactInspector(context)
? AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize
: 1.4,
color: Theme.of(context).colorScheme.onSurface,
);
@@ -734,30 +854,44 @@ abstract final class AppTheme {
}) {
final colors = Theme.of(context).colorScheme;
final ink = colors.onSurface;
final compact = isCompactInspector(context);
final height = compact
? AppInspectorMetrics.input
: AppControlSize.headerButton;
return ButtonStyle(
minimumSize: const WidgetStatePropertyAll(
Size(0, AppControlSize.headerButton),
),
maximumSize: const WidgetStatePropertyAll(
Size(double.infinity, AppControlSize.headerButton),
),
minimumSize: WidgetStatePropertyAll(Size(0, height)),
maximumSize: WidgetStatePropertyAll(Size(double.infinity, height)),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
textStyle: WidgetStatePropertyAll(toolbarTextStyle(context)),
textStyle: WidgetStatePropertyAll(
compact
? inputTextStyle(context).copyWith(
fontVariations: [FontVariation('wght', selected ? 550 : 450)],
)
: toolbarTextStyle(context),
),
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: AppSpacing.small),
),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
compact ? AppInspectorMetrics.radius : 8,
),
),
),
foregroundColor: WidgetStatePropertyAll(
selected
? ink
: compact
? colors.onSurfaceVariant
: Theme.of(context).brightness == Brightness.dark
? ink.withValues(alpha: .498)
: colors.onSurfaceVariant,
),
backgroundColor: WidgetStatePropertyAll(
selected ? ink.withValues(alpha: .05) : Colors.transparent,
selected
? (compact ? colors.surfaceContainer : ink.withValues(alpha: .05))
: Colors.transparent,
),
overlayColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.hovered) ||
@@ -1746,16 +1880,16 @@ abstract final class AppDesktopMetrics {
static const windowHeader = 44.0;
static const panelHeader = 36.0;
static const timelineTabs = 32.0;
static const timelineTabControl = 26.0;
static const timelineTabRadius = 7.0;
static const timelineToolbar = 36.0;
static const timelineTabControl = AppInspectorMetrics.input;
static const timelineTabRadius = AppInspectorMetrics.radius;
static const timelineToolbar = AppInspectorMetrics.row;
static const timelineRuler = 28.0;
static const playbackBar = 36.0;
static const playbackBar = AppInspectorMetrics.row;
static const iconButton = 28.0;
static const button = 32.0;
static const input = 36.0;
static const sidebarRow = 32.0;
static const panelPadding = 12.0;
static const panelPadding = AppInspectorMetrics.padding;
}
/// Window project tabs have their own geometry, separate from timeline tabs.
@@ -1770,11 +1904,18 @@ abstract final class AppProjectTabMetrics {
/// Geometry for desktop parameter editing, independent of general inputs.
abstract final class AppInspectorMetrics {
static const input = 28.0;
static const input = 24.0;
static const action = 24.0;
static const rowGap = 4.0;
static const row = 32.0;
static const sectionHeader = 40.0;
static const rowPadding = 4.0;
static const rowGap = 8.0;
static const groupGap = 12.0;
static const padding = 12.0;
static const padding = 16.0;
static const trailingPadding = 8.0;
static const radius = 5.0;
static const fontSize = 11.0;
static const lineHeight = 16.0;
}
class InspectorControlDensity extends ThemeExtension<InspectorControlDensity> {
@@ -124,6 +124,7 @@ class _AppComboboxState<T> extends State<AppCombobox<T>> {
builder: (context, constraints) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final compact = AppTheme.isCompactInspector(context);
final inputStyle = AppTheme.inputTextStyle(
context,
style: AppTheme.isDesktop(context)
@@ -181,21 +182,27 @@ class _AppComboboxState<T> extends State<AppCombobox<T>> {
AppDesktopMetrics.input
: AppControlSize.input,
),
padding: const EdgeInsetsDirectional.only(
start: AppSpacing.compact,
end: AppSpacing.tiny,
padding: EdgeInsetsDirectional.only(
start: compact ? AppSpacing.small : AppSpacing.compact,
end: compact ? 0 : AppSpacing.tiny,
),
decoration: BoxDecoration(
color: AppTheme.comboboxBackground(context),
borderRadius: BorderRadius.circular(AppRadius.large),
border: Border.all(color: colors.outlineVariant),
boxShadow: [
BoxShadow(
color: colors.shadow.withValues(alpha: .05),
offset: const Offset(0, 1),
blurRadius: 2,
),
],
borderRadius: BorderRadius.circular(
compact ? AppInspectorMetrics.radius : AppRadius.large,
),
border: compact
? null
: Border.all(color: colors.outlineVariant),
boxShadow: compact
? []
: [
BoxShadow(
color: colors.shadow.withValues(alpha: .05),
offset: const Offset(0, 1),
blurRadius: 2,
),
],
),
child: Row(
children: [
@@ -257,9 +264,9 @@ class _AppComboboxState<T> extends State<AppCombobox<T>> {
icon: Icon(
AppIcons.expandMore,
size: 16,
color: colors.onSurfaceVariant.withValues(
alpha: .5,
),
color: compact
? colors.onSurfaceVariant
: colors.onSurfaceVariant.withValues(alpha: .5),
),
),
],
@@ -32,19 +32,24 @@ class AppCommandToolbar extends StatelessWidget {
final List<AppToolbarCommand> trailing;
final Widget? status;
static const _buttonSize = AppInspectorMetrics.input;
static const _commandSlot = 32.0;
Widget _button(AppToolbarCommand command) => IconButton(
key: command.key,
tooltip: command.label,
onPressed: command.onPressed,
icon: Icon(command.icon, semanticLabel: command.semanticLabel, size: 16),
style: IconButton.styleFrom(
fixedSize: const Size.square(AppDesktopMetrics.iconButton),
minimumSize: const Size.square(AppDesktopMetrics.iconButton),
maximumSize: const Size.square(AppDesktopMetrics.iconButton),
fixedSize: const Size.square(_buttonSize),
minimumSize: const Size.square(_buttonSize),
maximumSize: const Size.square(_buttonSize),
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(AppRadius.small)),
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
),
),
);
@@ -53,13 +58,15 @@ class AppCommandToolbar extends StatelessWidget {
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final commands = groups.expand((group) => group).toList();
final reserved = trailing.length * 32 + (status == null ? 0 : 24);
final reserved =
trailing.length * _commandSlot + (status == null ? 0 : 24);
final groupSpace = (groups.length - 1).clamp(0, groups.length) * 16;
final allFit =
constraints.maxWidth >= commands.length * 32 + groupSpace + reserved;
constraints.maxWidth >=
commands.length * _commandSlot + groupSpace + reserved;
final visibleCount = allFit
? commands.length
: ((constraints.maxWidth - reserved - groupSpace - 36) / 32)
: ((constraints.maxWidth - reserved - groupSpace - 36) / _commandSlot)
.floor()
.clamp(0, commands.length);
final hidden = commands.skip(visibleCount).toList();
@@ -75,7 +82,7 @@ class AppCommandToolbar extends StatelessWidget {
for (final command in group)
if (index++ < visibleCount) ...[
_button(command),
const SizedBox(width: 4),
const SizedBox(width: 8),
],
],
if (hidden.isNotEmpty)
@@ -9,7 +9,7 @@ import 'app_command_toolbar.dart';
@Preview(
name: 'Timeline commands — light',
group: 'Desktop workspace',
size: Size(480, 36),
size: Size(480, 32),
)
Widget desktopTimelineToolbarLightPreview() =>
_toolbarPreview(Brightness.light);
@@ -17,12 +17,12 @@ Widget desktopTimelineToolbarLightPreview() =>
@Preview(
name: 'Timeline commands — dark',
group: 'Desktop workspace',
size: Size(480, 36),
size: Size(480, 32),
)
@Preview(
name: 'Narrow timeline commands',
group: 'Desktop workspace',
size: Size(180, 36),
size: Size(180, 32),
)
Widget desktopTimelineToolbarPreview() => _toolbarPreview(Brightness.dark);
@@ -36,7 +36,7 @@ Widget _toolbarPreview(Brightness brightness) => MaterialApp(
Widget desktopTimelineCommands() => Material(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.medium),
child: AppCommandToolbar(
groups: [
[
@@ -453,6 +453,7 @@ class AppSelect<T> extends StatelessWidget {
builder: (context, constraints) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final compact = AppTheme.isCompactInspector(context);
final current = options
.where((option) => option.value == value)
.firstOrNull;
@@ -484,8 +485,10 @@ class AppSelect<T> extends StatelessWidget {
child: AnimatedContainer(
duration: const Duration(milliseconds: 100),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(AppRadius.large),
boxShadow: outlined
borderRadius: BorderRadius.circular(
compact ? AppInspectorMetrics.radius : AppRadius.large,
),
boxShadow: outlined && !compact
? [
BoxShadow(
color: colors.shadow.withValues(alpha: .05),
@@ -526,7 +529,11 @@ class AppSelect<T> extends StatelessWidget {
),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.large),
borderRadius: BorderRadius.circular(
compact
? AppInspectorMetrics.radius
: AppRadius.large,
),
),
side: outlined
? theme
@@ -536,8 +543,12 @@ class AppSelect<T> extends StatelessWidget {
BorderSide(color: colors.outlineVariant)
: null,
padding: EdgeInsets.symmetric(
horizontal: outlined ? 12 : AppSpacing.tiny,
vertical: outlined ? AppSpacing.inputVertical : 0,
horizontal: outlined
? (compact ? 8 : 12)
: AppSpacing.tiny,
vertical: outlined && !compact
? AppSpacing.inputVertical
: 0,
),
),
child: Row(
@@ -557,9 +568,9 @@ class AppSelect<T> extends StatelessWidget {
Icon(
AppIcons.expandMore,
size: 16,
color: colors.onSurfaceVariant.withValues(
alpha: .5,
),
color: compact
? colors.onSurfaceVariant
: colors.onSurfaceVariant.withValues(alpha: .5),
),
],
),
@@ -2,6 +2,36 @@ import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
/// Shared inspector gutters, section spacing, and a full-width divider.
class AppPropertySection extends StatelessWidget {
const AppPropertySection({
super.key,
required this.child,
this.bottomSpacing,
});
final Widget child;
final double? bottomSpacing;
@override
Widget build(BuildContext context) {
final content = Padding(
padding: AppTheme.propertySectionPadding(context)
.copyWith(bottom: bottomSpacing),
child: child,
);
if (!AppTheme.isCompactInspector(context)) return content;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Theme.of(context).dividerColor),
),
),
child: content,
);
}
}
/// An inspector property title, its actions, and the controls below it.
class AppPropertyGroup extends StatelessWidget {
const AppPropertyGroup({
@@ -10,43 +40,109 @@ class AppPropertyGroup extends StatelessWidget {
required this.child,
this.labelWidget,
this.actions = const [],
this.padChild = true,
});
final String label;
final Widget? labelWidget;
final List<Widget> actions;
/// Set to false when the child contains [AppPropertyRow] widgets.
final bool padChild;
final Widget child;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ConstrainedBox(
constraints: BoxConstraints(
minHeight: AppTheme.isDesktop(context)
? AppInspectorMetrics.action
: AppControlSize.propertyControl,
),
child: Row(
children: [
Expanded(
child:
labelWidget ??
Text(
label,
style: AppTheme.propertySectionTitleStyle(context),
),
),
for (final action in actions) ...[
SizedBox(width: AppTheme.propertyRowGap(context)),
action,
Widget build(BuildContext context) {
final compact = AppTheme.isCompactInspector(context);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ConstrainedBox(
constraints: BoxConstraints(
minHeight: compact
? AppInspectorMetrics.sectionHeader
: AppControlSize.propertyControl,
),
child: Row(
children: [
Expanded(
child:
labelWidget ??
Text(
label,
style: AppTheme.propertySectionTitleStyle(context),
),
),
for (final action in actions) ...[
SizedBox(
width: compact
? AppSpacing.tiny
: AppTheme.propertyRowGap(context),
),
action,
],
],
],
),
),
if (compact && padChild)
Padding(
padding: const EdgeInsets.symmetric(
vertical: AppInspectorMetrics.rowPadding,
),
child: child,
)
else if (compact)
child
else ...[
SizedBox(height: AppTheme.propertyRowGap(context)),
child,
],
],
);
}
}
/// UI3 control cells share equal widths and a separate 24px action column.
class AppPropertyRow extends StatelessWidget {
const AppPropertyRow({
super.key,
required this.children,
this.trailing,
this.reserveTrailing = true,
this.flexes,
}) : assert(children.length > 0),
assert(flexes == null || flexes.length == children.length);
final List<Widget> children;
final Widget? trailing;
final bool reserveTrailing;
final List<int>? flexes;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(
vertical: AppInspectorMetrics.rowPadding,
),
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: AppInspectorMetrics.input),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (var i = 0; i < children.length; i++) ...[
if (i > 0) const SizedBox(width: AppInspectorMetrics.rowGap),
Expanded(flex: flexes?[i] ?? 1, child: children[i]),
],
if (trailing != null || reserveTrailing) ...[
const SizedBox(width: AppInspectorMetrics.rowGap),
SizedBox(
width: AppInspectorMetrics.action,
child:
trailing ?? const SizedBox(height: AppInspectorMetrics.input),
),
],
],
),
SizedBox(height: AppTheme.propertyRowGap(context)),
child,
],
),
);
}
@@ -6,23 +6,24 @@ import '../theme/app_palette.dart';
import '../theme/app_theme.dart';
import 'app_property_group.dart';
import 'app_text_field.dart';
import 'app_button_group.dart';
@Preview(
name: 'Property groups — light',
group: 'Desktop inspector',
size: Size(280, 240),
size: Size(240, 360),
)
Widget propertyGroupsLightPreview() => _preview(Brightness.light);
@Preview(
name: 'Property groups — dark',
group: 'Desktop inspector',
size: Size(280, 240),
size: Size(240, 360),
)
@Preview(
name: 'Narrow property groups',
group: 'Desktop inspector',
size: Size(220, 240),
size: Size(220, 360),
)
Widget propertyGroupsDarkPreview() => _preview(Brightness.dark);
@@ -49,6 +50,7 @@ class _PropertyGroupsPreviewState extends State<_PropertyGroupsPreview> {
TextEditingController(text: '100'),
TextEditingController(text: '100'),
TextEditingController(text: '0'),
TextEditingController(text: '0'),
];
bool _locked = true;
final _keyed = <int>{};
@@ -70,19 +72,17 @@ class _PropertyGroupsPreviewState extends State<_PropertyGroupsPreview> {
}),
);
Widget _pair(String a, String b, int index, {String? unit}) => Row(
Widget _pair(
String a,
String b,
int index, {
String? unit,
Widget? trailing,
}) => AppPropertyRow(
trailing: trailing,
children: [
Expanded(
child: AppTextField(label: a, unit: unit, controller: _values[index]),
),
const SizedBox(width: 4),
Expanded(
child: AppTextField(
label: b,
unit: unit,
controller: _values[index + 1],
),
),
AppTextField(label: a, unit: unit, controller: _values[index]),
AppTextField(label: b, unit: unit, controller: _values[index + 1]),
],
);
@@ -93,41 +93,100 @@ class _PropertyGroupsPreviewState extends State<_PropertyGroupsPreview> {
for (final group in [
AppPropertyGroup(
label: '位置',
actions: [_keyframe(0)],
child: _pair('X', 'Y', 0),
padChild: false,
child: Column(
children: [
AppPropertyRow(
children: [
for (final (index, icons) in [
(
0,
[
AppIcons.alignLeft,
AppIcons.alignHorizontalCenter,
AppIcons.alignRight,
],
),
(
1,
[
AppIcons.alignTop,
AppIcons.alignVerticalCenter,
AppIcons.alignBottom,
],
),
])
AppButtonGroup(
expanded: true,
label: 'Alignment',
children: [
for (var i = 0; i < icons.length; i++)
IconButton(
icon: Icon(icons[i]),
onPressed: () =>
_values[index].text = '${i * 100}',
),
],
),
],
),
_pair('X', 'Y', 0, trailing: _keyframe(0)),
AppPropertyRow(
trailing: _keyframe(2),
children: [
AppTextField(
label: '旋转',
leading: const SizedBox(
width: AppInspectorMetrics.action,
child: Center(child: Icon(AppIcons.angle, size: 14)),
),
unit: '°',
controller: _values[4],
),
const SizedBox.shrink(),
],
),
],
),
),
AppPropertyGroup(
label: '缩放',
actions: [
IconButton(
actions: [_keyframe(1)],
padChild: false,
child: _pair(
'W',
'H',
2,
unit: '%',
trailing: IconButton(
tooltip: 'Lock aspect ratio',
isSelected: _locked,
icon: const Icon(AppIcons.unlock),
selectedIcon: const Icon(AppIcons.lockFilled),
onPressed: () => setState(() => _locked = !_locked),
),
_keyframe(1),
],
child: _pair('W', 'H', 2, unit: '%'),
),
),
AppPropertyGroup(
label: '旋转',
actions: [_keyframe(2)],
child: AppTextField(
label: '旋转',
leading: const Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Icon(AppIcons.angle, size: 14),
),
unit: '°',
controller: _values[4],
label: '圆角',
padChild: false,
child: AppPropertyRow(
trailing: _keyframe(3),
children: [
AppTextField(
label: '圆角',
leading: const SizedBox(
width: AppInspectorMetrics.action,
child: Center(child: Icon(AppIcons.cornerRadius, size: 14)),
),
controller: _values[5],
),
const SizedBox.shrink(),
],
),
),
])
Padding(
padding: AppTheme.propertySectionPadding(context),
child: group,
),
AppPropertySection(child: group),
],
),
);
@@ -40,7 +40,9 @@ class _AppSwitchState extends State<AppSwitch> {
onFocusChange: (value) => setState(() => _focused = value),
child: SizedBox(
width: width,
height: 36,
height: AppTheme.isCompactInspector(context)
? AppInspectorMetrics.input
: 36,
child: Stack(
alignment: Alignment.center,
children: [
@@ -65,6 +65,7 @@ class _AppTextFieldState extends State<AppTextField> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final compact = AppTheme.isCompactInspector(context);
final foreground = widget.enabled
? colors.onSurface
: colors.onSurface.withValues(alpha: 0.38);
@@ -72,9 +73,11 @@ class _AppTextFieldState extends State<AppTextField> {
final borderless =
theme.inputDecorationTheme.enabledBorder?.borderSide == BorderSide.none;
final style = AppTheme.inputTextStyle(context)
.copyWith(color: foreground, letterSpacing: 0);
.copyWith(color: foreground, letterSpacing: compact ? null : 0);
OutlineInputBorder border(Color color) => OutlineInputBorder(
borderRadius: BorderRadius.circular(AppRadius.large),
borderRadius: BorderRadius.circular(
compact ? AppInspectorMetrics.radius : AppRadius.large,
),
borderSide: BorderSide(color: color),
);
@@ -107,12 +110,20 @@ class _AppTextFieldState extends State<AppTextField> {
hintStyle: AppTheme.inputHintStyle(context, style: style),
errorText: widget.errorText,
errorMaxLines: 2,
contentPadding:
theme.inputDecorationTheme.contentPadding ??
const EdgeInsets.symmetric(
horizontal: AppSpacing.controlHorizontal,
vertical: AppSpacing.inputVertical,
),
contentPadding: compact && widget.maxLines == 1
? EdgeInsets.fromLTRB(
!labelAbove && (widget.leading != null || widget.label != null)
? 0
: 8,
4,
widget.unit == null ? 8 : 0,
4,
)
: theme.inputDecorationTheme.contentPadding ??
const EdgeInsets.symmetric(
horizontal: AppSpacing.controlHorizontal,
vertical: AppSpacing.inputVertical,
),
prefixIcon: labelAbove
? null
: widget.leading ??
@@ -122,18 +133,26 @@ class _AppTextFieldState extends State<AppTextField> {
widthFactor: 1,
heightFactor: 1,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.small,
padding: EdgeInsets.symmetric(
horizontal: compact && widget.label!.length == 1
? 0
: AppSpacing.small,
),
child: ExcludeSemantics(
child: Text(
widget.label!,
style: AppTheme.propertyLabelStyle(context)
.copyWith(
color: widget.enabled
? colors.onSurfaceVariant
: foreground,
),
child: SizedBox(
width: compact && widget.label!.length == 1
? AppInspectorMetrics.action
: null,
child: Text(
widget.label!,
textAlign: TextAlign.center,
style: AppTheme.propertyLabelStyle(context)
.copyWith(
color: widget.enabled
? colors.onSurfaceVariant
: foreground,
),
),
),
),
),
@@ -148,8 +167,8 @@ class _AppTextFieldState extends State<AppTextField> {
widthFactor: 1,
heightFactor: 1,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.small,
padding: EdgeInsets.symmetric(
horizontal: compact ? 4 : AppSpacing.small,
),
child: ExcludeSemantics(
child: Text(
@@ -163,8 +182,8 @@ class _AppTextFieldState extends State<AppTextField> {
),
),
),
suffixIconConstraints: const BoxConstraints(
minWidth: AppControlSize.compact,
suffixIconConstraints: BoxConstraints(
minWidth: compact ? 16 : AppControlSize.compact,
minHeight: AppControlSize.input,
),
border: theme.inputDecorationTheme.border,
@@ -201,12 +220,44 @@ class _AppTextFieldState extends State<AppTextField> {
child: Semantics(
label: [widget.label, widget.unit].whereType<String>().join(' '),
child: labelAbove
? AppPropertyGroup(
label: widget.label ?? '',
labelWidget: widget.leading,
actions: widget.labelActions,
child: input,
)
? compact
? Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ConstrainedBox(
constraints: const BoxConstraints(
minHeight: AppInspectorMetrics.lineHeight,
),
child: Row(
children: [
Expanded(
child:
widget.leading ??
Text(
widget.label ?? '',
style: AppTheme.propertyLabelStyle(
context,
),
),
),
for (final action in widget.labelActions) ...[
const SizedBox(width: AppSpacing.tiny),
action,
],
],
),
),
const SizedBox(height: AppInspectorMetrics.rowPadding),
input,
],
)
: AppPropertyGroup(
label: widget.label ?? '',
labelWidget: widget.leading,
actions: widget.labelActions,
child: input,
)
: input,
),
);
@@ -24,8 +24,8 @@ class AppToolbarDropdownButton extends StatelessWidget {
key: buttonKey,
focusNode: focusNode,
onPressed: onPressed,
style: AppTheme.toolbarButtonStyle(context)
.merge(style)
style: (style ?? const ButtonStyle())
.merge(AppTheme.toolbarButtonStyle(context))
.copyWith(
backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
overlayColor: WidgetStateProperty.resolveWith((states) {
@@ -24,14 +24,19 @@ class CompactPanelTabs<T> extends StatelessWidget {
@override
Widget build(BuildContext context) => SizedBox(
height: AppTheme.isDesktop(context)
height: AppTheme.isCompactInspector(context)
? AppInspectorMetrics.sectionHeader
: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
: height,
child: Padding(
padding:
AppTheme.isDesktop(context) &&
padding == const EdgeInsets.all(AppSpacing.gap)
? const EdgeInsets.symmetric(horizontal: 8, vertical: 4)
? EdgeInsets.symmetric(
horizontal: 8,
vertical: AppTheme.isCompactInspector(context) ? 8 : 4,
)
: padding,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
@@ -53,7 +53,7 @@ class _TimelineControlsPreviewState extends State<_TimelineControlsPreview> {
child: SizedBox(
height: AppDesktopMetrics.timelineTabs,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.tiny),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
child: Row(
children: [
Expanded(
@@ -117,7 +117,7 @@ class _TimelineControlsPreviewState extends State<_TimelineControlsPreview> {
SizedBox(
height: AppDesktopMetrics.timelineToolbar,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.medium),
child: AppCommandToolbar(
groups: [
[
@@ -53,7 +53,9 @@ class WorkspacePanel extends StatelessWidget {
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelLarge,
style: AppTheme.isCompactInspector(context)
? Theme.of(context).textTheme.titleSmall
: Theme.of(context).textTheme.labelLarge,
),
),
if (controls case final controls?) ...[
+4
View File
@@ -18,6 +18,9 @@ dev_dependencies:
freezed: ^4.0.2
flutter:
fonts:
- family: Inter
fonts:
- asset: assets/fonts/InterVariable.ttf
- family: PhosphorRegular
fonts:
- asset: assets/fonts/PhosphorRegular.ttf
@@ -25,4 +28,5 @@ flutter:
fonts:
- asset: assets/fonts/PhosphorFill.ttf
assets:
- assets/fonts/INTER_LICENSE.txt
- assets/fonts/PHOSPHOR_LICENSE.txt
@@ -19,8 +19,7 @@ void main() {
home: Scaffold(
body: SizedBox(
width: 220,
child: Padding(
padding: const EdgeInsets.all(12),
child: AppPropertySection(
child: AppPropertyGroup(
label: 'Position',
actions: [
@@ -38,7 +37,7 @@ void main() {
errorText: 'Invalid value',
),
),
SizedBox(width: 4),
SizedBox(width: AppInspectorMetrics.rowGap),
Expanded(child: AppTextField(label: 'Y')),
],
),
@@ -51,8 +50,8 @@ void main() {
await tester.pumpAndSettle();
final first = find.byType(TextField).first;
final second = find.byType(TextField).last;
expect(tester.getRect(first).width, 96);
expect(tester.getRect(second).right, 208);
expect(tester.getRect(first).width, 94);
expect(tester.getRect(second).right, 212);
expect(tester.getRect(first).top, tester.getRect(second).top);
expect(
tester.getRect(first).height,
@@ -60,7 +59,7 @@ void main() {
);
expect(
tester.getRect(find.byType(IconButton)).bottom,
tester.getRect(first).top - 4,
tester.getRect(first).top - 12,
);
expect(
tester.widget<TextField>(first).decoration!.prefixIcon,
+71 -4
View File
@@ -7,12 +7,79 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test(
'desktop inspector keeps panel colors with UI3 typography and inputs',
() {
for (final palette in AppPalette.values) {
for (final brightness in Brightness.values) {
final base = AppTheme.desktopWorkspaceTheme(
AppTheme.forPalette(palette, brightness),
);
final theme = AppTheme.propertiesPanelTheme(base);
final dark = brightness == Brightness.dark;
expect(
theme.colorScheme.surface,
base.colorScheme.surfaceContainerLow,
);
expect(theme.canvasColor, base.colorScheme.surfaceContainerLow);
expect(
theme.colorScheme.surfaceContainerLow,
base.colorScheme.surfaceContainerLow,
);
expect(theme.scaffoldBackgroundColor, base.scaffoldBackgroundColor);
expect(
theme.inputDecorationTheme.fillColor,
dark ? const Color(0xFF383838) : const Color(0xFFF5F5F5),
);
expect(
theme.colorScheme.onSurface,
dark ? Colors.white : Colors.black.withValues(alpha: .9),
);
expect(
theme.colorScheme.onSurfaceVariant,
dark
? Colors.white.withValues(alpha: .7)
: Colors.black.withValues(alpha: .5),
);
expect(
theme.dividerColor,
dark ? const Color(0xFF444444) : const Color(0xFFE6E6E6),
);
expect(theme.colorScheme.primary, base.colorScheme.primary);
final text = theme.textTheme.bodyMedium!;
expect(text.fontFamily, 'packages/cutdex_ui/Inter');
expect(
text.fontFamilyFallback,
base.textTheme.bodyMedium!.fontFamilyFallback,
);
expect(text.fontSize, 11);
expect(text.height! * text.fontSize!, closeTo(16, .001));
expect(text.fontVariations, const [ui.FontVariation('wght', 450)]);
expect(text.letterSpacing, closeTo(.055, .001));
expect(
(theme.inputDecorationTheme.enabledBorder! as OutlineInputBorder)
.borderRadius,
BorderRadius.circular(5),
);
expect(
theme.inputDecorationTheme.enabledBorder!.borderSide,
BorderSide.none,
);
expect(
theme.inputDecorationTheme.focusedBorder!.borderSide.color,
base.colorScheme.primary,
);
}
}
},
);
testWidgets('slider density follows inspector and desktop contexts', (
tester,
) async {
final desktop = AppTheme.desktopWorkspaceTheme(AppTheme.penDark);
for (final (theme, height) in [
(AppTheme.propertiesPanelTheme(desktop), 28.0),
(AppTheme.propertiesPanelTheme(desktop), 24.0),
(desktop, 36.0),
(
AppTheme.propertiesPanelTheme(AppTheme.penDark),
@@ -44,9 +111,9 @@ void main() {
final desktop = AppTheme.desktopWorkspaceTheme(AppTheme.penDark);
final inspector = AppTheme.propertiesPanelTheme(desktop);
expect(desktop.inputDecorationTheme.constraints!.minHeight, 36);
expect(inspector.inputDecorationTheme.constraints!.minHeight, 28);
expect(inspector.textTheme.bodyMedium!.fontSize, 13);
expect(inspector.textTheme.bodySmall!.fontSize, 12);
expect(inspector.inputDecorationTheme.constraints!.minHeight, 24);
expect(inspector.textTheme.bodyMedium!.fontSize, 11);
expect(inspector.textTheme.bodySmall!.fontSize, 11);
expect(
inspector.iconButtonTheme.style!.fixedSize!.resolve({}),
const Size.square(24),