refactor(desktop): reorganize workspace panels and navigation
Gitea CI / Windows x64 and Android (pull_request) Successful in 16m21s
Gitea CI / Gitea CI passed (pull_request) Successful in 3s

This commit is contained in:
lingjhf committed 2026-10-06 12:11:59 +08:00
1 parent 826745b407
commit 1f73765745
92 files changed
+5811 -2650

No files matched your search

+16 -23
View File
@@ -103,6 +103,17 @@ abstract final class AppTheme {
_ => '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 ??
@@ -678,11 +689,7 @@ abstract final class AppTheme {
useMaterial3: true,
colorScheme: colors,
fontFamily: systemFontFamily(defaultTargetPlatform),
fontFamilyFallback: const [
'PingFang SC',
'Noto Sans CJK SC',
'sans-serif',
],
fontFamilyFallback: systemFontFamilyFallback(defaultTargetPlatform),
textTheme: text,
primaryTextTheme: text,
scaffoldBackgroundColor: palette.background,
@@ -956,21 +963,11 @@ abstract final class AppTheme {
}) => TextStyle(
inherit: false,
fontFamily: systemFontFamily(defaultTargetPlatform),
fontFamilyFallback: const [
'PingFang SC',
'Noto Sans CJK SC',
'sans-serif',
],
fontFamilyFallback: systemFontFamilyFallback(defaultTargetPlatform),
textBaseline: TextBaseline.alphabetic,
fontSize: size,
height: lineHeight / size,
fontWeight: weight,
fontVariations: [
FontVariation(
'wght',
weight == FontWeight.w400 ? 430 : weight.value.toDouble(),
),
],
letterSpacing: 0,
color: color ?? palette.foreground,
);
@@ -1199,16 +1196,12 @@ abstract final class AppSidebarTypography {
Color? color,
}) => TextStyle(
fontFamily: AppTheme.systemFontFamily(Theme.of(context).platform),
fontFamilyFallback: const ['PingFang SC', 'Noto Sans CJK SC', 'sans-serif'],
fontFamilyFallback: AppTheme.systemFontFamilyFallback(
Theme.of(context).platform,
),
fontSize: fontSize,
height: height,
fontWeight: weight,
fontVariations: [
FontVariation(
'wght',
weight == FontWeight.w400 ? 430 : weight.value.toDouble(),
),
],
color: color ?? AppSidebarColors.of(context).primary,
);
}
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
/// A compact menu trigger with neutral interaction feedback.
class AppToolbarDropdownButton extends StatelessWidget {
const AppToolbarDropdownButton({
super.key,
this.buttonKey,
this.focusNode,
this.onPressed,
this.style,
required this.child,
});
final Key? buttonKey;
final FocusNode? focusNode;
final VoidCallback? onPressed;
final ButtonStyle? style;
final Widget child;
@override
Widget build(BuildContext context) => TextButton(
key: buttonKey,
focusNode: focusNode,
onPressed: onPressed,
style: AppTheme.toolbarButtonStyle(context)
.merge(style)
.copyWith(
backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
overlayColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.disabled)) {
return Colors.transparent;
}
return states.any(
{
WidgetState.hovered,
WidgetState.focused,
WidgetState.pressed,
}.contains,
)
? Theme.of(context).colorScheme.onSurface.withValues(alpha: .05)
: Colors.transparent;
}),
splashFactory: NoSplash.splashFactory,
),
child: child,
);
}
+1
View File
@@ -9,6 +9,7 @@ export 'src/widgets/app_scrub_label.dart';
export 'src/widgets/app_slider.dart';
export 'src/widgets/app_switch.dart';
export 'src/widgets/app_tabs.dart';
export 'src/widgets/app_toolbar_dropdown_button.dart';
export 'src/widgets/app_text_field.dart';
export 'src/widgets/compact_panel_tabs.dart';
export 'src/widgets/delayed_loading_indicator.dart';
@@ -0,0 +1,59 @@
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
for (final theme in [AppTheme.penLight, AppTheme.penDark]) {
testWidgets('toolbar menu feedback is neutral in ${theme.brightness}', (
tester,
) async {
var presses = 0;
final focus = FocusNode();
addTearDown(focus.dispose);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: AppToolbarDropdownButton(
buttonKey: const Key('trigger'),
focusNode: focus,
onPressed: () => presses++,
style: const ButtonStyle(
overlayColor: WidgetStatePropertyAll(Colors.blue),
),
child: const Text('Projects'),
),
),
),
);
final button = tester.widget<TextButton>(
find.byKey(const Key('trigger')),
);
for (final state in [
WidgetState.hovered,
WidgetState.focused,
WidgetState.pressed,
]) {
expect(
button.style!.backgroundColor!.resolve({state}),
Colors.transparent,
);
expect(
button.style!.overlayColor!.resolve({state}),
theme.colorScheme.onSurface.withValues(alpha: .05),
);
expect(
button.style!.overlayColor!.resolve({state, WidgetState.disabled}),
Colors.transparent,
);
}
await tester.tap(find.byKey(const Key('trigger')));
await tester.pump();
expect(presses, 1);
focus.requestFocus();
await tester.pump();
expect(focus.hasFocus, isTrue);
});
}
}