feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
This commit was merged in pull request #13.
This commit is contained in:
1 parent
aa5255d1e4
commit
abc1868550
260 files changed
+43964
-5591
No files matched your search
@@ -0,0 +1,109 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'phosphor_icons.g.dart';
|
||||
|
||||
/// Shared Cutdex icons, using Regular by default and explicit Fill variants.
|
||||
@staticIconProvider
|
||||
abstract final class AppIcons {
|
||||
static const IconData close = PhosphorIconsRegular.x;
|
||||
static const IconData check = PhosphorIconsRegular.check;
|
||||
static const IconData add = PhosphorIconsRegular.plus;
|
||||
static const IconData remove = PhosphorIconsRegular.minus;
|
||||
static const IconData search = PhosphorIconsRegular.magnifyingGlass;
|
||||
static const IconData settings = PhosphorIconsRegular.gear;
|
||||
static const IconData appearance = PhosphorIconsRegular.palette;
|
||||
static const IconData more = PhosphorIconsRegular.dotsThree;
|
||||
static const IconData expandMore = PhosphorIconsRegular.caretDown;
|
||||
static const IconData expandLess = PhosphorIconsRegular.caretUp;
|
||||
static const IconData chevronLeft = PhosphorIconsRegular.caretLeft;
|
||||
static const IconData chevronRight = PhosphorIconsRegular.caretRight;
|
||||
static const IconData arrowBack = PhosphorIconsRegular.arrowLeft;
|
||||
static const IconData arrowForward = PhosphorIconsRegular.arrowRight;
|
||||
static const IconData arrowUp = PhosphorIconsRegular.arrowUp;
|
||||
static const IconData arrowDown = PhosphorIconsRegular.arrowDown;
|
||||
static const IconData sort = PhosphorIconsRegular.sortAscending;
|
||||
static const IconData play = PhosphorIconsRegular.play;
|
||||
static const IconData pause = PhosphorIconsRegular.pause;
|
||||
static const IconData stop = PhosphorIconsRegular.stop;
|
||||
static const IconData undo = PhosphorIconsRegular.arrowUUpLeft;
|
||||
static const IconData redo = PhosphorIconsRegular.arrowUUpRight;
|
||||
static const IconData refresh = PhosphorIconsRegular.arrowsClockwise;
|
||||
static const IconData reset = PhosphorIconsRegular.arrowCounterClockwise;
|
||||
static const IconData angle = PhosphorIconsRegular.angle;
|
||||
static const IconData seekStart = PhosphorIconsRegular.skipBack;
|
||||
static const IconData previousFrame = PhosphorIconsRegular.caretLineLeft;
|
||||
static const IconData nextFrame = PhosphorIconsRegular.caretLineRight;
|
||||
static const IconData cut = PhosphorIconsRegular.scissors;
|
||||
static const IconData delete = PhosphorIconsRegular.trash;
|
||||
static const IconData edit = PhosphorIconsRegular.pencilSimple;
|
||||
static const IconData rename = PhosphorIconsRegular.textbox;
|
||||
static const IconData copy = PhosphorIconsRegular.copy;
|
||||
static const IconData folder = PhosphorIconsRegular.folder;
|
||||
static const IconData folderOpen = PhosphorIconsRegular.folderOpen;
|
||||
static const IconData folderUnavailable = PhosphorIconsRegular.folderDashed;
|
||||
static const IconData file = PhosphorIconsRegular.file;
|
||||
static const IconData attachment = PhosphorIconsRegular.paperclip;
|
||||
static const IconData video = PhosphorIconsRegular.filmStrip;
|
||||
static const IconData image = PhosphorIconsRegular.image;
|
||||
static const IconData audio = PhosphorIconsRegular.musicNotes;
|
||||
static const IconData audioFile = PhosphorIconsRegular.fileAudio;
|
||||
static const IconData imageUnavailable = PhosphorIconsRegular.imageBroken;
|
||||
static const IconData mediaLibrary = PhosphorIconsRegular.images;
|
||||
static const IconData videoLibrary = PhosphorIconsRegular.filmReel;
|
||||
static const IconData timeline = PhosphorIconsRegular.rows;
|
||||
static const IconData audioWaveform = PhosphorIconsRegular.waveform;
|
||||
static const IconData removeBackground = PhosphorIconsRegular.userMinus;
|
||||
static const IconData subtitles = PhosphorIconsRegular.subtitles;
|
||||
static const IconData textWrap = PhosphorIconsRegular.arrowElbowDownLeft;
|
||||
static const IconData volume = PhosphorIconsRegular.speakerHigh;
|
||||
static const IconData mute = PhosphorIconsRegular.speakerSlash;
|
||||
static const IconData visible = PhosphorIconsRegular.eye;
|
||||
static const IconData hidden = PhosphorIconsRegular.eyeSlash;
|
||||
static const IconData lock = PhosphorIconsRegular.lock;
|
||||
static const IconData unlock = PhosphorIconsRegular.lockOpen;
|
||||
static const IconData fullscreen = PhosphorIconsRegular.arrowsOut;
|
||||
static const IconData exitFullscreen = PhosphorIconsRegular.arrowsIn;
|
||||
static const IconData fitContent = PhosphorIconsRegular.cornersIn;
|
||||
static const IconData menu = PhosphorIconsRegular.list;
|
||||
static const IconData sidebar = PhosphorIconsRegular.sidebarSimple;
|
||||
static const IconData splitVertical =
|
||||
PhosphorIconsRegular.squareSplitVertical;
|
||||
static const IconData listView = PhosphorIconsRegular.listBullets;
|
||||
static const IconData gridView = PhosphorIconsRegular.squaresFour;
|
||||
static const IconData collapseVertical =
|
||||
PhosphorIconsRegular.arrowsInLineVertical;
|
||||
static const IconData dragHandle = PhosphorIconsRegular.dotsSixVertical;
|
||||
static const IconData windowRestore = PhosphorIconsRegular.copy;
|
||||
static const IconData chat = PhosphorIconsRegular.chatCircle;
|
||||
static const IconData home = PhosphorIconsRegular.house;
|
||||
static const IconData conversations = PhosphorIconsRegular.chatsCircle;
|
||||
static const IconData assistant = PhosphorIconsRegular.sparkle;
|
||||
static const IconData model = PhosphorIconsRegular.brain;
|
||||
static const IconData lightning = PhosphorIconsRegular.lightning;
|
||||
static const IconData terminal = PhosphorIconsRegular.terminalWindow;
|
||||
static const IconData tune = PhosphorIconsRegular.slidersHorizontal;
|
||||
static const IconData error = PhosphorIconsRegular.warningCircle;
|
||||
static const IconData success = PhosphorIconsRegular.checkCircle;
|
||||
static const IconData info = PhosphorIconsRegular.info;
|
||||
static const IconData pin = PhosphorIconsRegular.pushPin;
|
||||
static const IconData pinFilled = PhosphorIconsFill.pushPin;
|
||||
static const IconData square = PhosphorIconsRegular.square;
|
||||
static const IconData squareFilled = PhosphorIconsFill.square;
|
||||
static const IconData circle = PhosphorIconsRegular.circle;
|
||||
static const IconData maskRegion = PhosphorIconsRegular.frameCorners;
|
||||
static const IconData maskIntersect = PhosphorIconsRegular.intersectSquare;
|
||||
static const IconData alignLeft = PhosphorIconsRegular.alignLeft;
|
||||
static const IconData alignRight = PhosphorIconsRegular.alignRight;
|
||||
static const IconData alignHorizontalCenter =
|
||||
PhosphorIconsRegular.alignCenterHorizontal;
|
||||
static const IconData alignTop = PhosphorIconsRegular.alignTop;
|
||||
static const IconData alignBottom = PhosphorIconsRegular.alignBottom;
|
||||
static const IconData alignVerticalCenter =
|
||||
PhosphorIconsRegular.alignCenterVertical;
|
||||
static const IconData download = PhosphorIconsRegular.downloadSimple;
|
||||
static const IconData upload = PhosphorIconsRegular.uploadSimple;
|
||||
static const IconData star = PhosphorIconsRegular.star;
|
||||
static const IconData folderFilled = PhosphorIconsFill.folder;
|
||||
static const IconData starFilled = PhosphorIconsFill.star;
|
||||
static const IconData lockFilled = PhosphorIconsFill.lock;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
/// Workspace color families, independent of light or dark appearance.
|
||||
enum AppPalette { graphite, violet, teal }
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import 'app_menu.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
@@ -31,6 +32,7 @@ class _AppComboboxState<T> extends State<AppCombobox<T>> {
|
||||
final _focus = FocusNode();
|
||||
final _input = TextEditingController();
|
||||
final _firstOption = GlobalKey();
|
||||
final _menuStorage = PageStorageBucket();
|
||||
String _query = '';
|
||||
|
||||
String get _selectedLabel =>
|
||||
@@ -122,121 +124,146 @@ class _AppComboboxState<T> extends State<AppCombobox<T>> {
|
||||
builder: (context, constraints) {
|
||||
final theme = Theme.of(context);
|
||||
final colors = theme.colorScheme;
|
||||
final inputStyle = AppTheme.inputTextStyle(
|
||||
context,
|
||||
style: AppTheme.isDesktop(context)
|
||||
? theme.textTheme.bodyMedium
|
||||
: theme.textTheme.bodyLarge,
|
||||
);
|
||||
final width = constraints.hasBoundedWidth ? constraints.maxWidth : 240.0;
|
||||
final filtered = _filtered;
|
||||
return MenuAnchor(
|
||||
controller: _menu,
|
||||
childFocusNode: _focus,
|
||||
consumeOutsideTap: false,
|
||||
crossAxisUnconstrained: false,
|
||||
alignmentOffset: const Offset(0, 4),
|
||||
style: AppMenuStyle.selectPanel(context, minWidth: width).copyWith(
|
||||
maximumSize: const WidgetStatePropertyAll(Size(double.infinity, 320)),
|
||||
),
|
||||
onClose: _restore,
|
||||
menuChildren: [
|
||||
if (filtered.isEmpty) AppMenuLabel(widget.emptyLabel),
|
||||
for (var i = 0; i < filtered.length; i++)
|
||||
Builder(
|
||||
key: i == 0 ? _firstOption : null,
|
||||
builder: (_) {
|
||||
final option = filtered[i];
|
||||
return AppMenuItem(
|
||||
label: option.label,
|
||||
selected: option.value == widget.value,
|
||||
selectOption: true,
|
||||
requestFocusOnHover: false,
|
||||
onPressed: widget.onChanged == null || !option.enabled
|
||||
? null
|
||||
: () => widget.onChanged!(option.value),
|
||||
);
|
||||
},
|
||||
return PageStorage(
|
||||
bucket: _menuStorage,
|
||||
child: MenuAnchor(
|
||||
controller: _menu,
|
||||
childFocusNode: _focus,
|
||||
consumeOutsideTap: false,
|
||||
crossAxisUnconstrained: false,
|
||||
alignmentOffset: const Offset(0, 4),
|
||||
style: AppMenuStyle.selectPanel(context, minWidth: width).copyWith(
|
||||
maximumSize: const WidgetStatePropertyAll(
|
||||
Size(double.infinity, 320),
|
||||
),
|
||||
],
|
||||
child: Semantics(
|
||||
label: widget.label,
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: Focus(
|
||||
canRequestFocus: false,
|
||||
onKeyEvent: _handleKey,
|
||||
child: Opacity(
|
||||
opacity: widget.onChanged == null ? .5 : 1,
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: AppControlSize.input,
|
||||
),
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: AppSpacing.compact,
|
||||
end: 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _input,
|
||||
focusNode: _focus,
|
||||
enabled: widget.onChanged != null,
|
||||
onTap: _open,
|
||||
onTapAlwaysCalled: true,
|
||||
onChanged: (text) {
|
||||
setState(() => _query = text);
|
||||
if (!_menu.isOpen) _menu.open();
|
||||
},
|
||||
style: theme.textTheme.bodyLarge,
|
||||
decoration: InputDecoration(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: AppControlSize.input - 2,
|
||||
),
|
||||
onClose: _restore,
|
||||
menuChildren: [
|
||||
if (filtered.isEmpty) AppMenuLabel(widget.emptyLabel),
|
||||
for (var i = 0; i < filtered.length; i++)
|
||||
Builder(
|
||||
key: i == 0 ? _firstOption : null,
|
||||
builder: (_) {
|
||||
final option = filtered[i];
|
||||
return AppMenuItem(
|
||||
label: option.label,
|
||||
selected: option.value == widget.value,
|
||||
selectOption: true,
|
||||
requestFocusOnHover: false,
|
||||
onPressed: widget.onChanged == null || !option.enabled
|
||||
? null
|
||||
: () => widget.onChanged!(option.value),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
child: Semantics(
|
||||
label: widget.label,
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: Focus(
|
||||
canRequestFocus: false,
|
||||
onKeyEvent: _handleKey,
|
||||
child: Opacity(
|
||||
opacity: widget.onChanged == null ? .5 : 1,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: AppTheme.isDesktop(context)
|
||||
? theme.inputDecorationTheme.constraints?.minHeight ??
|
||||
AppDesktopMetrics.input
|
||||
: AppControlSize.input,
|
||||
),
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: AppSpacing.compact,
|
||||
end: 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _input,
|
||||
focusNode: _focus,
|
||||
enabled: widget.onChanged != null,
|
||||
onTap: _open,
|
||||
onTapAlwaysCalled: true,
|
||||
onChanged: (text) {
|
||||
setState(() => _query = text);
|
||||
if (!_menu.isOpen) _menu.open();
|
||||
},
|
||||
style: inputStyle,
|
||||
cursorHeight: AppTheme.inputCursorHeight(
|
||||
context,
|
||||
style: inputStyle,
|
||||
),
|
||||
hintText: widget.searchHint,
|
||||
isDense: true,
|
||||
filled: false,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: AppSpacing.inputVertical - 2,
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
decoration: InputDecoration(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: AppControlSize.input - 2,
|
||||
),
|
||||
hintText: widget.searchHint,
|
||||
hintStyle: AppTheme.inputHintStyle(
|
||||
context,
|
||||
style: inputStyle,
|
||||
),
|
||||
isDense: true,
|
||||
filled: false,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: AppSpacing.inputVertical - 2,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
focusedErrorBorder: InputBorder.none,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
focusedErrorBorder: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: null,
|
||||
onPressed: widget.onChanged == null
|
||||
? null
|
||||
: () => _menu.isOpen ? _menu.close() : _open(),
|
||||
style: IconButton.styleFrom(
|
||||
overlayColor: Colors.transparent,
|
||||
minimumSize: const Size.square(
|
||||
AppControlSize.input - 2,
|
||||
IconButton(
|
||||
tooltip: null,
|
||||
onPressed: widget.onChanged == null
|
||||
? null
|
||||
: () => _menu.isOpen ? _menu.close() : _open(),
|
||||
style: IconButton.styleFrom(
|
||||
overlayColor: Colors.transparent,
|
||||
minimumSize: const Size.square(
|
||||
AppControlSize.input - 2,
|
||||
),
|
||||
padding: const EdgeInsets.all(
|
||||
AppSpacing.inputVertical,
|
||||
),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
padding: const EdgeInsets.all(
|
||||
AppSpacing.inputVertical,
|
||||
icon: Icon(
|
||||
AppIcons.expandMore,
|
||||
size: 16,
|
||||
color: colors.onSurfaceVariant.withValues(
|
||||
alpha: .5,
|
||||
),
|
||||
),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
icon: Icon(
|
||||
Icons.expand_more,
|
||||
size: 16,
|
||||
color: colors.onSurfaceVariant.withValues(alpha: .5),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'app_menu.dart';
|
||||
import 'app_popover.dart';
|
||||
|
||||
class AppToolbarCommand {
|
||||
const AppToolbarCommand({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.onPressed,
|
||||
this.key,
|
||||
this.semanticLabel,
|
||||
});
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final VoidCallback? onPressed;
|
||||
final Key? key;
|
||||
final String? semanticLabel;
|
||||
}
|
||||
|
||||
/// Keeps primary commands and view controls visible when a panel narrows.
|
||||
class AppCommandToolbar extends StatelessWidget {
|
||||
const AppCommandToolbar({
|
||||
super.key,
|
||||
required this.groups,
|
||||
this.trailing = const [],
|
||||
this.status,
|
||||
});
|
||||
final List<List<AppToolbarCommand>> groups;
|
||||
final List<AppToolbarCommand> trailing;
|
||||
final Widget? status;
|
||||
|
||||
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),
|
||||
padding: EdgeInsets.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(AppRadius.small)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
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 groupSpace = (groups.length - 1).clamp(0, groups.length) * 16;
|
||||
final allFit =
|
||||
constraints.maxWidth >= commands.length * 32 + groupSpace + reserved;
|
||||
final visibleCount = allFit
|
||||
? commands.length
|
||||
: ((constraints.maxWidth - reserved - groupSpace - 36) / 32)
|
||||
.floor()
|
||||
.clamp(0, commands.length);
|
||||
final hidden = commands.skip(visibleCount).toList();
|
||||
var index = 0;
|
||||
return Row(
|
||||
children: [
|
||||
for (final group in groups) ...[
|
||||
if (index > 0 && index < visibleCount)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: SizedBox(height: 16, child: VerticalDivider(width: 1)),
|
||||
),
|
||||
for (final command in group)
|
||||
if (index++ < visibleCount) ...[
|
||||
_button(command),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
],
|
||||
if (hidden.isNotEmpty)
|
||||
AppPopover(
|
||||
width: 240,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final command in hidden)
|
||||
AppMenuItem(
|
||||
label: command.label,
|
||||
icon: command.icon,
|
||||
onPressed: command.onPressed,
|
||||
),
|
||||
],
|
||||
),
|
||||
builder: (context, toggle) => _button(
|
||||
AppToolbarCommand(
|
||||
key: const Key('toolbar-overflow'),
|
||||
label: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||
icon: AppIcons.more,
|
||||
onPressed: toggle,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
for (final command in trailing) _button(command),
|
||||
?status,
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widget_previews.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_palette.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'app_command_toolbar.dart';
|
||||
|
||||
@Preview(
|
||||
name: 'Timeline commands — light',
|
||||
group: 'Desktop workspace',
|
||||
size: Size(480, 36),
|
||||
)
|
||||
Widget desktopTimelineToolbarLightPreview() =>
|
||||
_toolbarPreview(Brightness.light);
|
||||
|
||||
@Preview(
|
||||
name: 'Timeline commands — dark',
|
||||
group: 'Desktop workspace',
|
||||
size: Size(480, 36),
|
||||
)
|
||||
@Preview(
|
||||
name: 'Narrow timeline commands',
|
||||
group: 'Desktop workspace',
|
||||
size: Size(180, 36),
|
||||
)
|
||||
Widget desktopTimelineToolbarPreview() => _toolbarPreview(Brightness.dark);
|
||||
|
||||
Widget _toolbarPreview(Brightness brightness) => MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.desktopWorkspaceTheme(
|
||||
AppTheme.forPalette(AppPalette.graphite, brightness),
|
||||
),
|
||||
home: Scaffold(body: desktopTimelineCommands()),
|
||||
);
|
||||
|
||||
Widget desktopTimelineCommands() => Material(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: AppCommandToolbar(
|
||||
groups: [
|
||||
[
|
||||
AppToolbarCommand(
|
||||
label: 'Undo',
|
||||
icon: AppIcons.undo,
|
||||
onPressed: () {},
|
||||
),
|
||||
const AppToolbarCommand(
|
||||
label: 'Redo',
|
||||
icon: AppIcons.redo,
|
||||
onPressed: null,
|
||||
),
|
||||
],
|
||||
[
|
||||
AppToolbarCommand(
|
||||
label: 'Split',
|
||||
icon: AppIcons.cut,
|
||||
onPressed: () {},
|
||||
),
|
||||
AppToolbarCommand(
|
||||
label: 'Trim left',
|
||||
icon: AppIcons.alignLeft,
|
||||
onPressed: () {},
|
||||
),
|
||||
AppToolbarCommand(
|
||||
label: 'Trim right',
|
||||
icon: AppIcons.alignRight,
|
||||
onPressed: () {},
|
||||
),
|
||||
AppToolbarCommand(
|
||||
label: 'Delete',
|
||||
icon: AppIcons.delete,
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
],
|
||||
trailing: [
|
||||
AppToolbarCommand(
|
||||
label: 'Fit timeline',
|
||||
icon: AppIcons.fitContent,
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
Future<T?> showAppDialog<T>({
|
||||
@@ -307,7 +308,10 @@ class AppDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.close, size: AppIconSize.header),
|
||||
icon: const Icon(
|
||||
AppIcons.close,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
/// A rounded, non-modal dialog surface positioned by its parent.
|
||||
class AppFloatingDialog extends StatelessWidget {
|
||||
const AppFloatingDialog({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.backgroundColor,
|
||||
this.shape,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final Color? backgroundColor;
|
||||
final ShapeBorder? shape;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final background =
|
||||
backgroundColor ??
|
||||
theme.dialogTheme.backgroundColor ??
|
||||
theme.colorScheme.surfaceContainer;
|
||||
return Theme(
|
||||
data: theme.copyWith(
|
||||
canvasColor: background,
|
||||
colorScheme: theme.colorScheme.copyWith(surface: background),
|
||||
),
|
||||
child: Material(
|
||||
color: background,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
elevation: 8,
|
||||
shadowColor: theme.colorScheme.shadow,
|
||||
shape:
|
||||
shape ??
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.dialog),
|
||||
side: BorderSide(
|
||||
color: theme.dividerColor,
|
||||
width: theme.dividerTheme.thickness ?? 1,
|
||||
),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widget_previews.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'app_floating_dialog.dart';
|
||||
|
||||
@Preview(name: 'Floating input — light', group: 'Dialogs', size: Size(600, 140))
|
||||
Widget floatingInputLightPreview() => _inputPreview(AppTheme.penLight);
|
||||
|
||||
@Preview(name: 'Floating input — dark', group: 'Dialogs', size: Size(600, 140))
|
||||
Widget floatingInputDarkPreview() => _inputPreview(AppTheme.penDark);
|
||||
|
||||
Widget _inputPreview(ThemeData theme) => MaterialApp(
|
||||
theme: theme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 560,
|
||||
child: AppFloatingDialog(
|
||||
shape: const StadiumBorder(),
|
||||
backgroundColor: theme.extension<AppSurfaces>()!.composerBackground,
|
||||
child: Builder(
|
||||
builder: (context) => Padding(
|
||||
padding: const EdgeInsets.all(AppSpacing.small),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
style: _controlStyle(),
|
||||
onPressed: () {},
|
||||
icon: const Icon(AppIcons.add),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
minLines: 1,
|
||||
maxLines: 1,
|
||||
style: AppTheme.composerTextStyle(context),
|
||||
cursorHeight: AppTheme.composerCursorHeight(context),
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
decoration: AppTheme.composerInputDecoration.copyWith(
|
||||
hintText: 'Message Agent…',
|
||||
hintStyle: AppTheme.composerHintStyle(context),
|
||||
isDense: true,
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: AppControlSize.headerButton,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.small,
|
||||
vertical: AppSpacing.tiny,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
style: _controlStyle(),
|
||||
onPressed: () {},
|
||||
icon: const Icon(AppIcons.model),
|
||||
),
|
||||
IconButton.filled(
|
||||
style: AppTheme.accentIconButtonStyle(context)
|
||||
.merge(_controlStyle()),
|
||||
onPressed: () {},
|
||||
icon: const Icon(AppIcons.arrowUp),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
ButtonStyle _controlStyle() => IconButton.styleFrom(
|
||||
minimumSize: const Size.square(AppControlSize.headerButton),
|
||||
maximumSize: const Size.square(AppControlSize.headerButton),
|
||||
fixedSize: const Size.square(AppControlSize.headerButton),
|
||||
iconSize: AppIconSize.header,
|
||||
padding: EdgeInsets.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
);
|
||||
@@ -2,10 +2,12 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../theme/menu_metrics.dart';
|
||||
import 'native_context_menu.dart';
|
||||
import 'app_combobox.dart';
|
||||
import 'menu_trigger_focus.dart';
|
||||
|
||||
part 'app_menu.freezed.dart';
|
||||
|
||||
@@ -203,7 +205,7 @@ class _AppMenuItemState extends State<AppMenuItem> {
|
||||
? null
|
||||
: SizedBox.square(
|
||||
dimension: AppMenuMetrics.iconSize,
|
||||
child: widget.selected! ? const Icon(Icons.check) : null,
|
||||
child: widget.selected! ? const Icon(AppIcons.check) : null,
|
||||
),
|
||||
child: widget.selectOption
|
||||
? Row(
|
||||
@@ -219,7 +221,7 @@ class _AppMenuItemState extends State<AppMenuItem> {
|
||||
SizedBox.square(
|
||||
dimension: 16,
|
||||
child: widget.selected == true
|
||||
? const Icon(Icons.check, size: 16)
|
||||
? const Icon(AppIcons.check, size: 16)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
@@ -261,7 +263,7 @@ class AppMenuSeparator extends StatelessWidget {
|
||||
horizontal: AppMenuMetrics.iconGap,
|
||||
vertical: AppMenuMetrics.separatorVerticalPadding,
|
||||
),
|
||||
child: Divider(height: 1, thickness: 1),
|
||||
child: Divider(height: 1),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -335,53 +337,67 @@ class AppDropdownMenu extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AppDropdownMenuState extends State<AppDropdownMenu> {
|
||||
final _focus = FocusNode();
|
||||
final _controller = MenuController();
|
||||
late final _triggerFocus = MenuTriggerFocus(controller: _controller);
|
||||
FocusNode get _focus => _triggerFocus.node;
|
||||
final _entryKey = GlobalKey();
|
||||
// MenuAnchor owns a scroll view. Do not let its offset read or overwrite
|
||||
// an enclosing inspector's expansion state or scroll position.
|
||||
final _menuStorage = PageStorageBucket();
|
||||
@override
|
||||
void dispose() {
|
||||
_focus.dispose();
|
||||
_triggerFocus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => MenuAnchor(
|
||||
controller: _controller,
|
||||
childFocusNode: _focus,
|
||||
consumeOutsideTap: true,
|
||||
crossAxisUnconstrained: widget.crossAxisUnconstrained,
|
||||
alignmentOffset: widget.alignmentOffset,
|
||||
style:
|
||||
(widget.menuStyle ??
|
||||
AppMenuStyle.panel(context, minWidth: widget.minWidth))
|
||||
.copyWith(
|
||||
maximumSize: widget.maxHeight == null
|
||||
? null
|
||||
: WidgetStatePropertyAll(
|
||||
Size(double.infinity, widget.maxHeight!),
|
||||
),
|
||||
),
|
||||
onClose: widget.onClose,
|
||||
onOpen: () => _focusMenu(_entryKey),
|
||||
menuChildren: [
|
||||
for (var i = 0; i < widget.items.length; i++)
|
||||
if (i == 0)
|
||||
Builder(key: _entryKey, builder: (_) => widget.items[i])
|
||||
else
|
||||
widget.items[i],
|
||||
],
|
||||
builder: (context, controller, _) => Shortcuts(
|
||||
shortcuts: const {
|
||||
SingleActivator(LogicalKeyboardKey.arrowDown): ActivateIntent(),
|
||||
Widget build(BuildContext context) => PageStorage(
|
||||
bucket: _menuStorage,
|
||||
child: MenuAnchor(
|
||||
controller: _controller,
|
||||
childFocusNode: _focus,
|
||||
// Close on outside clicks without swallowing the target control's action.
|
||||
consumeOutsideTap: false,
|
||||
crossAxisUnconstrained: widget.crossAxisUnconstrained,
|
||||
alignmentOffset: widget.alignmentOffset,
|
||||
style:
|
||||
(widget.menuStyle ??
|
||||
AppMenuStyle.panel(context, minWidth: widget.minWidth))
|
||||
.copyWith(
|
||||
maximumSize: widget.maxHeight == null
|
||||
? null
|
||||
: WidgetStatePropertyAll(
|
||||
Size(double.infinity, widget.maxHeight!),
|
||||
),
|
||||
),
|
||||
onClose: () {
|
||||
_triggerFocus.onClose();
|
||||
widget.onClose?.call();
|
||||
},
|
||||
child: widget.builder(
|
||||
context,
|
||||
!widget.enabled
|
||||
? null
|
||||
: () {
|
||||
controller.isOpen ? controller.close() : controller.open();
|
||||
},
|
||||
_focus,
|
||||
onOpen: () {
|
||||
_triggerFocus.onOpen();
|
||||
_focusMenu(_entryKey);
|
||||
},
|
||||
menuChildren: [
|
||||
for (var i = 0; i < widget.items.length; i++)
|
||||
if (i == 0)
|
||||
Builder(key: _entryKey, builder: (_) => widget.items[i])
|
||||
else
|
||||
widget.items[i],
|
||||
],
|
||||
builder: (context, controller, _) => Shortcuts(
|
||||
shortcuts: const {
|
||||
SingleActivator(LogicalKeyboardKey.arrowDown): ActivateIntent(),
|
||||
},
|
||||
child: widget.builder(
|
||||
context,
|
||||
!widget.enabled
|
||||
? null
|
||||
: () {
|
||||
controller.isOpen ? controller.close() : controller.open();
|
||||
},
|
||||
_focus,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -495,9 +511,18 @@ class AppSelect<T> extends StatelessWidget {
|
||||
: Size.fromHeight(controlHeight!),
|
||||
minimumSize: Size(
|
||||
0,
|
||||
outlined
|
||||
? AppControlSize.input
|
||||
: AppControlSize.small,
|
||||
controlHeight ??
|
||||
(AppTheme.isDesktop(context)
|
||||
? outlined
|
||||
? theme
|
||||
.inputDecorationTheme
|
||||
.constraints
|
||||
?.minHeight ??
|
||||
AppDesktopMetrics.input
|
||||
: AppDesktopMetrics.iconButton
|
||||
: outlined
|
||||
? AppControlSize.input
|
||||
: AppControlSize.small),
|
||||
),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -530,7 +555,7 @@ class AppSelect<T> extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: AppSpacing.small),
|
||||
Icon(
|
||||
Icons.expand_more,
|
||||
AppIcons.expandMore,
|
||||
size: 16,
|
||||
color: colors.onSurfaceVariant.withValues(
|
||||
alpha: .5,
|
||||
@@ -563,6 +588,7 @@ class _AppContextMenuState extends State<AppContextMenu> {
|
||||
final _controller = MenuController();
|
||||
final _focus = FocusNode();
|
||||
final _entryKey = GlobalKey();
|
||||
final _menuStorage = PageStorageBucket();
|
||||
Offset _anchorPosition = Offset.zero;
|
||||
bool _focusFirstItem = false;
|
||||
bool _opening = false;
|
||||
@@ -640,17 +666,22 @@ class _AppContextMenuState extends State<AppContextMenu> {
|
||||
Positioned(
|
||||
left: _anchorPosition.dx,
|
||||
top: _anchorPosition.dy,
|
||||
child: MenuAnchor(
|
||||
controller: _controller,
|
||||
childFocusNode: _focus,
|
||||
consumeOutsideTap: true,
|
||||
crossAxisUnconstrained: false,
|
||||
style: AppMenuStyle.panel(context),
|
||||
onOpen: () {
|
||||
if (_focusFirstItem) _focusMenu(_entryKey);
|
||||
},
|
||||
menuChildren: _items(context),
|
||||
child: const IgnorePointer(child: SizedBox.square(dimension: 1)),
|
||||
child: PageStorage(
|
||||
bucket: _menuStorage,
|
||||
child: MenuAnchor(
|
||||
controller: _controller,
|
||||
childFocusNode: _focus,
|
||||
// Nested anchors share their parent's open state. Consuming an
|
||||
// outside tap here would also block clicks outside that parent.
|
||||
consumeOutsideTap: false,
|
||||
crossAxisUnconstrained: false,
|
||||
style: AppMenuStyle.panel(context),
|
||||
onOpen: () {
|
||||
if (_focusFirstItem) _focusMenu(_entryKey);
|
||||
},
|
||||
menuChildren: _items(context),
|
||||
child: const IgnorePointer(child: SizedBox.square(dimension: 1)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../theme/app_theme.dart';
|
||||
import '../theme/menu_metrics.dart';
|
||||
import 'menu_trigger_focus.dart';
|
||||
|
||||
/// Anchored shadcn-style surface, dismissed outside or with Escape.
|
||||
class AppPopover extends StatefulWidget {
|
||||
@@ -39,6 +40,18 @@ class AppPopover extends StatefulWidget {
|
||||
|
||||
class _AppPopoverState extends State<AppPopover> {
|
||||
final _menu = MenuController();
|
||||
final _triggerScope = FocusScopeNode();
|
||||
late final _triggerFocus = MenuTriggerFocus(
|
||||
controller: _menu,
|
||||
node: _triggerScope,
|
||||
);
|
||||
final _menuStorage = PageStorageBucket();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_triggerFocus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _toggle() {
|
||||
if (!widget.enabled) return;
|
||||
@@ -65,90 +78,100 @@ class _AppPopoverState extends State<AppPopover> {
|
||||
);
|
||||
final endAligned = widget.alignment == AlignmentDirectional.bottomEnd;
|
||||
final direction = Directionality.of(context);
|
||||
return MenuAnchor(
|
||||
controller: _menu,
|
||||
alignmentOffset: Offset(
|
||||
endAligned
|
||||
? (direction == TextDirection.ltr ? -surfaceWidth : surfaceWidth)
|
||||
: 0,
|
||||
4,
|
||||
),
|
||||
consumeOutsideTap: false,
|
||||
crossAxisUnconstrained: false,
|
||||
clipBehavior: Clip.none,
|
||||
style: MenuStyle(
|
||||
alignment: widget.alignment,
|
||||
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
|
||||
backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
surfaceTintColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shadowColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
// The inner surface owns the border; do not inherit MenuTheme's stroke.
|
||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
return PageStorage(
|
||||
bucket: _menuStorage,
|
||||
child: MenuAnchor(
|
||||
controller: _menu,
|
||||
childFocusNode: _triggerScope,
|
||||
onOpen: _triggerFocus.onOpen,
|
||||
onClose: _triggerFocus.onClose,
|
||||
alignmentOffset: Offset(
|
||||
endAligned
|
||||
? (direction == TextDirection.ltr ? -surfaceWidth : surfaceWidth)
|
||||
: 0,
|
||||
4,
|
||||
),
|
||||
consumeOutsideTap: false,
|
||||
crossAxisUnconstrained: false,
|
||||
clipBehavior: Clip.none,
|
||||
style: MenuStyle(
|
||||
alignment: widget.alignment,
|
||||
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
|
||||
backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
surfaceTintColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shadowColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
// The inner surface owns the border; do not inherit MenuTheme's stroke.
|
||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
menuChildren: [
|
||||
SizedBox(
|
||||
key: widget.surfaceKey,
|
||||
width: surfaceWidth,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
widget.backgroundColor ?? AppTheme.popoverBackground(context),
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
border: Border.all(
|
||||
color: colors.outlineVariant,
|
||||
width: AppMenuMetrics.borderWidth,
|
||||
menuChildren: [
|
||||
SizedBox(
|
||||
key: widget.surfaceKey,
|
||||
width: surfaceWidth,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
widget.backgroundColor ??
|
||||
AppTheme.popoverBackground(context),
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
border: Border.all(
|
||||
color: colors.outlineVariant,
|
||||
width: AppMenuMetrics.borderWidth,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: colors.shadow.withValues(alpha: .1),
|
||||
offset: const Offset(0, 4),
|
||||
blurRadius: 6,
|
||||
spreadRadius: -1,
|
||||
),
|
||||
BoxShadow(
|
||||
color: colors.shadow.withValues(alpha: .1),
|
||||
offset: const Offset(0, 2),
|
||||
blurRadius: 4,
|
||||
spreadRadius: -2,
|
||||
),
|
||||
],
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: colors.shadow.withValues(alpha: .1),
|
||||
offset: const Offset(0, 4),
|
||||
blurRadius: 6,
|
||||
spreadRadius: -1,
|
||||
),
|
||||
BoxShadow(
|
||||
color: colors.shadow.withValues(alpha: .1),
|
||||
offset: const Offset(0, 2),
|
||||
blurRadius: 4,
|
||||
spreadRadius: -2,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
child: Padding(
|
||||
padding: widget.padding,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: math.max(
|
||||
0,
|
||||
math.min(widget.maxHeight, viewport.height - 96),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
child: Padding(
|
||||
padding: widget.padding,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: math.max(
|
||||
0,
|
||||
math.min(widget.maxHeight, viewport.height - 96),
|
||||
),
|
||||
),
|
||||
child: Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
_menu.close();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
child: Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
_menu.close();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
builder: (context, _, _) => FocusScope(
|
||||
node: _triggerScope,
|
||||
child: widget.builder(context, _toggle),
|
||||
),
|
||||
],
|
||||
builder: (context, _, _) => widget.builder(context, _toggle),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
/// An inspector property title, its actions, and the controls below it.
|
||||
class AppPropertyGroup extends StatelessWidget {
|
||||
const AppPropertyGroup({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.child,
|
||||
this.labelWidget,
|
||||
this.actions = const [],
|
||||
});
|
||||
|
||||
final String label;
|
||||
final Widget? labelWidget;
|
||||
final List<Widget> actions;
|
||||
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,
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppTheme.propertyRowGap(context)),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widget_previews.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_palette.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'app_property_group.dart';
|
||||
import 'app_text_field.dart';
|
||||
|
||||
@Preview(
|
||||
name: 'Property groups — light',
|
||||
group: 'Desktop inspector',
|
||||
size: Size(280, 240),
|
||||
)
|
||||
Widget propertyGroupsLightPreview() => _preview(Brightness.light);
|
||||
|
||||
@Preview(
|
||||
name: 'Property groups — dark',
|
||||
group: 'Desktop inspector',
|
||||
size: Size(280, 240),
|
||||
)
|
||||
@Preview(
|
||||
name: 'Narrow property groups',
|
||||
group: 'Desktop inspector',
|
||||
size: Size(220, 240),
|
||||
)
|
||||
Widget propertyGroupsDarkPreview() => _preview(Brightness.dark);
|
||||
|
||||
Widget _preview(Brightness brightness) => MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.propertiesPanelTheme(
|
||||
AppTheme.desktopWorkspaceTheme(
|
||||
AppTheme.forPalette(AppPalette.graphite, brightness),
|
||||
),
|
||||
),
|
||||
home: const Scaffold(body: _PropertyGroupsPreview()),
|
||||
);
|
||||
|
||||
class _PropertyGroupsPreview extends StatefulWidget {
|
||||
const _PropertyGroupsPreview();
|
||||
@override
|
||||
State<_PropertyGroupsPreview> createState() => _PropertyGroupsPreviewState();
|
||||
}
|
||||
|
||||
class _PropertyGroupsPreviewState extends State<_PropertyGroupsPreview> {
|
||||
final _values = [
|
||||
TextEditingController(text: '0'),
|
||||
TextEditingController(text: '0'),
|
||||
TextEditingController(text: '100'),
|
||||
TextEditingController(text: '100'),
|
||||
TextEditingController(text: '0'),
|
||||
];
|
||||
bool _locked = true;
|
||||
final _keyed = <int>{};
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final value in _values) {
|
||||
value.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _keyframe(int channel) => IconButton(
|
||||
tooltip: 'Toggle keyframe',
|
||||
isSelected: _keyed.contains(channel),
|
||||
icon: const Icon(AppIcons.square, size: 12),
|
||||
onPressed: () => setState(() {
|
||||
if (!_keyed.add(channel)) _keyed.remove(channel);
|
||||
}),
|
||||
);
|
||||
|
||||
Widget _pair(String a, String b, int index, {String? unit}) => Row(
|
||||
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],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
for (final group in [
|
||||
AppPropertyGroup(
|
||||
label: '位置',
|
||||
actions: [_keyframe(0)],
|
||||
child: _pair('X', 'Y', 0),
|
||||
),
|
||||
AppPropertyGroup(
|
||||
label: '缩放',
|
||||
actions: [
|
||||
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],
|
||||
),
|
||||
),
|
||||
])
|
||||
Padding(
|
||||
padding: AppTheme.propertySectionPadding(context),
|
||||
child: group,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -15,9 +15,17 @@ class AppScrubLabel extends StatefulWidget {
|
||||
required this.onUpdate,
|
||||
required this.onEnd,
|
||||
required this.onCancel,
|
||||
this.padding = const EdgeInsets.symmetric(horizontal: AppSpacing.small),
|
||||
this.alignment = Alignment.center,
|
||||
this.style,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final AlignmentGeometry alignment;
|
||||
final TextStyle? style;
|
||||
final IconData? icon;
|
||||
final bool enabled;
|
||||
final bool Function() onStart;
|
||||
final ValueChanged<double> onUpdate;
|
||||
@@ -104,16 +112,27 @@ class _AppScrubLabelState extends State<AppScrubLabel> {
|
||||
},
|
||||
onHorizontalDragCancel: _cancel,
|
||||
child: Align(
|
||||
alignment: widget.alignment,
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
|
||||
child: Text(
|
||||
widget.label,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
padding: widget.padding,
|
||||
child: widget.icon == null
|
||||
? Text(
|
||||
widget.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
widget.style ?? AppTheme.propertyLabelStyle(context),
|
||||
)
|
||||
: Icon(
|
||||
widget.icon,
|
||||
size: 14,
|
||||
color:
|
||||
(widget.style ?? AppTheme.propertyLabelStyle(context))
|
||||
.color,
|
||||
semanticLabel: widget.label,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -34,7 +34,11 @@ class AppSlider extends StatelessWidget {
|
||||
final colors = theme.colorScheme;
|
||||
final accent = colors.primary;
|
||||
return SizedBox(
|
||||
height: AppControlSize.standard,
|
||||
height: AppTheme.isCompactInspector(context)
|
||||
? AppInspectorMetrics.input
|
||||
: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.input
|
||||
: AppControlSize.standard,
|
||||
child: SliderTheme(
|
||||
data: SliderTheme.of(context).copyWith(
|
||||
trackHeight: 4,
|
||||
|
||||
@@ -2,14 +2,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../theme/app_theme.dart';
|
||||
import 'app_property_group.dart';
|
||||
|
||||
/// Shared inline-labelled input built on Flutter's native text editing.
|
||||
/// Native input with inline prefixes and optional property group titles.
|
||||
class AppTextField extends StatefulWidget {
|
||||
const AppTextField({
|
||||
super.key,
|
||||
this.controller,
|
||||
this.focusNode,
|
||||
this.label,
|
||||
this.labelAbove = false,
|
||||
this.labelActions = const [],
|
||||
this.leading,
|
||||
this.unit,
|
||||
this.hintText,
|
||||
@@ -31,6 +34,8 @@ class AppTextField extends StatefulWidget {
|
||||
final TextEditingController? controller;
|
||||
final FocusNode? focusNode;
|
||||
final String? label;
|
||||
final bool labelAbove;
|
||||
final List<Widget> labelActions;
|
||||
final Widget? leading;
|
||||
final String? unit;
|
||||
final String? hintText;
|
||||
@@ -66,132 +71,143 @@ class _AppTextFieldState extends State<AppTextField> {
|
||||
final focusColor = colors.primary;
|
||||
final borderless =
|
||||
theme.inputDecorationTheme.enabledBorder?.borderSide == BorderSide.none;
|
||||
final style = theme.textTheme.bodyMedium!.copyWith(
|
||||
color: foreground,
|
||||
letterSpacing: 0,
|
||||
);
|
||||
final style = AppTheme.inputTextStyle(context)
|
||||
.copyWith(color: foreground, letterSpacing: 0);
|
||||
OutlineInputBorder border(Color color) => OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.large),
|
||||
borderSide: BorderSide(color: color),
|
||||
);
|
||||
|
||||
final labelAbove =
|
||||
widget.labelAbove && (widget.label != null || widget.leading != null);
|
||||
final input = TextField(
|
||||
controller: widget.controller,
|
||||
focusNode: widget.focusNode,
|
||||
enabled: widget.enabled,
|
||||
readOnly: widget.readOnly,
|
||||
canRequestFocus: widget.canRequestFocus,
|
||||
keyboardType: widget.keyboardType,
|
||||
inputFormatters: widget.inputFormatters,
|
||||
minLines: widget.minLines,
|
||||
maxLines: widget.maxLines,
|
||||
textInputAction: widget.textInputAction,
|
||||
style: style,
|
||||
cursorColor: focusColor,
|
||||
cursorHeight: AppTheme.inputCursorHeight(context),
|
||||
cursorWidth: 1,
|
||||
textAlignVertical: widget.maxLines == 1
|
||||
? TextAlignVertical.center
|
||||
: TextAlignVertical.top,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: theme.inputDecorationTheme.fillColor,
|
||||
hoverColor: Colors.transparent,
|
||||
hintText: widget.hintText,
|
||||
hintStyle: AppTheme.inputHintStyle(context, style: style),
|
||||
errorText: widget.errorText,
|
||||
errorMaxLines: 2,
|
||||
contentPadding:
|
||||
theme.inputDecorationTheme.contentPadding ??
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.controlHorizontal,
|
||||
vertical: AppSpacing.inputVertical,
|
||||
),
|
||||
prefixIcon: labelAbove
|
||||
? null
|
||||
: widget.leading ??
|
||||
(widget.label == null
|
||||
? null
|
||||
: Align(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.small,
|
||||
),
|
||||
child: ExcludeSemantics(
|
||||
child: Text(
|
||||
widget.label!,
|
||||
style: AppTheme.propertyLabelStyle(context)
|
||||
.copyWith(
|
||||
color: widget.enabled
|
||||
? colors.onSurfaceVariant
|
||||
: foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
minWidth: AppControlSize.standard,
|
||||
minHeight: AppControlSize.input,
|
||||
),
|
||||
suffixIcon: widget.unit == null
|
||||
? null
|
||||
: Align(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.small,
|
||||
),
|
||||
child: ExcludeSemantics(
|
||||
child: Text(
|
||||
widget.unit!,
|
||||
style: style.copyWith(
|
||||
color: widget.enabled
|
||||
? colors.onSurfaceVariant
|
||||
: foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
suffixIconConstraints: const BoxConstraints(
|
||||
minWidth: AppControlSize.compact,
|
||||
minHeight: AppControlSize.input,
|
||||
),
|
||||
border: theme.inputDecorationTheme.border,
|
||||
enabledBorder: borderless
|
||||
? theme.inputDecorationTheme.enabledBorder
|
||||
: border(
|
||||
_hovered
|
||||
? colors.outline
|
||||
: theme
|
||||
.inputDecorationTheme
|
||||
.enabledBorder
|
||||
?.borderSide
|
||||
.color ??
|
||||
colors.outlineVariant,
|
||||
),
|
||||
disabledBorder: theme.inputDecorationTheme.disabledBorder,
|
||||
focusedBorder: theme.inputDecorationTheme.focusedBorder,
|
||||
errorBorder: borderless
|
||||
? theme.inputDecorationTheme.errorBorder
|
||||
: border(colors.error),
|
||||
focusedErrorBorder: borderless
|
||||
? theme.inputDecorationTheme.focusedErrorBorder
|
||||
: border(colors.error),
|
||||
),
|
||||
onChanged: widget.onChanged,
|
||||
onEditingComplete: widget.onEditingComplete,
|
||||
onSubmitted: widget.onSubmitted,
|
||||
onTapOutside: widget.onTapOutside,
|
||||
);
|
||||
|
||||
return MouseRegion(
|
||||
onEnter: (_) => setState(() => _hovered = true),
|
||||
onExit: (_) => setState(() => _hovered = false),
|
||||
child: Semantics(
|
||||
label: [widget.label, widget.unit].whereType<String>().join(' '),
|
||||
child: TextField(
|
||||
controller: widget.controller,
|
||||
focusNode: widget.focusNode,
|
||||
enabled: widget.enabled,
|
||||
readOnly: widget.readOnly,
|
||||
canRequestFocus: widget.canRequestFocus,
|
||||
keyboardType: widget.keyboardType,
|
||||
inputFormatters: widget.inputFormatters,
|
||||
minLines: widget.minLines,
|
||||
maxLines: widget.maxLines,
|
||||
textInputAction: widget.textInputAction,
|
||||
style: style,
|
||||
cursorColor: focusColor,
|
||||
cursorHeight: AppTheme.inputCursorHeight(context),
|
||||
cursorWidth: 1,
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: theme.inputDecorationTheme.fillColor,
|
||||
hoverColor: Colors.transparent,
|
||||
hintText: widget.hintText,
|
||||
hintStyle:
|
||||
theme.inputDecorationTheme.hintStyle ??
|
||||
style.copyWith(color: colors.onSurfaceVariant),
|
||||
errorText: widget.errorText,
|
||||
errorMaxLines: 2,
|
||||
contentPadding:
|
||||
theme.inputDecorationTheme.contentPadding ??
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.controlHorizontal,
|
||||
vertical: AppSpacing.inputVertical,
|
||||
),
|
||||
prefixIcon:
|
||||
widget.leading ??
|
||||
(widget.label == null
|
||||
? null
|
||||
: Align(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.small,
|
||||
),
|
||||
child: ExcludeSemantics(
|
||||
child: Text(
|
||||
widget.label!,
|
||||
style: style.copyWith(
|
||||
color: widget.enabled
|
||||
? colors.onSurfaceVariant
|
||||
: foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
minWidth: AppControlSize.standard,
|
||||
minHeight: AppControlSize.input,
|
||||
),
|
||||
suffixIcon: widget.unit == null
|
||||
? null
|
||||
: Align(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.small,
|
||||
),
|
||||
child: ExcludeSemantics(
|
||||
child: Text(
|
||||
widget.unit!,
|
||||
style: style.copyWith(
|
||||
color: widget.enabled
|
||||
? colors.onSurfaceVariant
|
||||
: foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
suffixIconConstraints: const BoxConstraints(
|
||||
minWidth: AppControlSize.compact,
|
||||
minHeight: AppControlSize.input,
|
||||
),
|
||||
border: theme.inputDecorationTheme.border,
|
||||
enabledBorder: borderless
|
||||
? theme.inputDecorationTheme.enabledBorder
|
||||
: border(
|
||||
_hovered
|
||||
? colors.outline
|
||||
: theme
|
||||
.inputDecorationTheme
|
||||
.enabledBorder
|
||||
?.borderSide
|
||||
.color ??
|
||||
colors.outlineVariant,
|
||||
),
|
||||
disabledBorder: theme.inputDecorationTheme.disabledBorder,
|
||||
focusedBorder: theme.inputDecorationTheme.focusedBorder,
|
||||
errorBorder: borderless
|
||||
? theme.inputDecorationTheme.errorBorder
|
||||
: border(colors.error),
|
||||
focusedErrorBorder: borderless
|
||||
? theme.inputDecorationTheme.focusedErrorBorder
|
||||
: border(colors.error),
|
||||
),
|
||||
onChanged: widget.onChanged,
|
||||
onEditingComplete: widget.onEditingComplete,
|
||||
onSubmitted: widget.onSubmitted,
|
||||
onTapOutside: widget.onTapOutside,
|
||||
),
|
||||
child: labelAbove
|
||||
? AppPropertyGroup(
|
||||
label: widget.label ?? '',
|
||||
labelWidget: widget.leading,
|
||||
actions: widget.labelActions,
|
||||
child: input,
|
||||
)
|
||||
: input,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,15 @@ class CompactPanelTabs<T> extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SizedBox(
|
||||
height: height,
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.panelHeader
|
||||
: height,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
padding:
|
||||
AppTheme.isDesktop(context) &&
|
||||
padding == const EdgeInsets.all(AppSpacing.gap)
|
||||
? const EdgeInsets.symmetric(horizontal: 8, vertical: 4)
|
||||
: padding,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// Keeps keyboard focus while releasing a pointer-operated menu's highlight.
|
||||
class MenuTriggerFocus {
|
||||
MenuTriggerFocus({required this.controller, FocusNode? node})
|
||||
: node = node ?? FocusNode();
|
||||
|
||||
final MenuController controller;
|
||||
final FocusNode node;
|
||||
bool _keyboardClose = false;
|
||||
bool _disposed = false;
|
||||
bool _listening = false;
|
||||
|
||||
void onOpen() {
|
||||
_keyboardClose =
|
||||
LogicalKeyboardKey.collapseSynonyms(
|
||||
HardwareKeyboard.instance.logicalKeysPressed,
|
||||
).difference({
|
||||
LogicalKeyboardKey.alt,
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.meta,
|
||||
LogicalKeyboardKey.shift,
|
||||
}).isNotEmpty;
|
||||
if (_listening) return;
|
||||
_listening = true;
|
||||
GestureBinding.instance.pointerRouter.addGlobalRoute(_onPointer);
|
||||
HardwareKeyboard.instance.addHandler(_onKey);
|
||||
}
|
||||
|
||||
void _onPointer(PointerEvent event) {
|
||||
if (event is PointerDownEvent) _keyboardClose = false;
|
||||
}
|
||||
|
||||
bool _onKey(KeyEvent event) {
|
||||
if (event is KeyDownEvent) _keyboardClose = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void _stopListening() {
|
||||
if (!_listening) return;
|
||||
_listening = false;
|
||||
GestureBinding.instance.pointerRouter.removeGlobalRoute(_onPointer);
|
||||
HardwareKeyboard.instance.removeHandler(_onKey);
|
||||
}
|
||||
|
||||
void onClose() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Menu disposal restores focus at the end of the frame. Let that update
|
||||
// and the closing input event finish before clearing pointer focus.
|
||||
scheduleMicrotask(() {
|
||||
if (_disposed || controller.isOpen) return;
|
||||
_stopListening();
|
||||
if (!_keyboardClose && node.hasFocus) node.unfocus();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_disposed = true;
|
||||
_stopListening();
|
||||
node.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widget_previews.dart';
|
||||
|
||||
import '../icons/app_icons.dart';
|
||||
import '../theme/app_palette.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'app_command_toolbar.dart';
|
||||
|
||||
@Preview(
|
||||
name: 'Rounded timeline tabs — light',
|
||||
group: 'Desktop workspace',
|
||||
size: Size(480, 68),
|
||||
)
|
||||
Widget roundedTimelineControlsLightPreview() => _preview(Brightness.light);
|
||||
|
||||
@Preview(
|
||||
name: 'Rounded timeline tabs — dark',
|
||||
group: 'Desktop workspace',
|
||||
size: Size(480, 68),
|
||||
)
|
||||
@Preview(
|
||||
name: 'Rounded timeline tabs — narrow',
|
||||
group: 'Desktop workspace',
|
||||
size: Size(240, 68),
|
||||
)
|
||||
Widget roundedTimelineControlsDarkPreview() => _preview(Brightness.dark);
|
||||
|
||||
Widget _preview(Brightness brightness) => MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.desktopWorkspaceTheme(
|
||||
AppTheme.forPalette(AppPalette.graphite, brightness),
|
||||
),
|
||||
home: const Scaffold(body: _TimelineControlsPreview()),
|
||||
);
|
||||
|
||||
class _TimelineControlsPreview extends StatefulWidget {
|
||||
const _TimelineControlsPreview();
|
||||
|
||||
@override
|
||||
State<_TimelineControlsPreview> createState() =>
|
||||
_TimelineControlsPreviewState();
|
||||
}
|
||||
|
||||
class _TimelineControlsPreviewState extends State<_TimelineControlsPreview> {
|
||||
final _timelines = ['Main edit', 'Portrait', 'Outtakes'];
|
||||
String _selected = 'Main edit';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
children: [
|
||||
ColoredBox(
|
||||
color: AppTheme.timelineTabsBackground(context),
|
||||
child: SizedBox(
|
||||
height: AppDesktopMetrics.timelineTabs,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.tiny),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
for (final name in _timelines)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
end: AppSpacing.hairline,
|
||||
),
|
||||
child: Semantics(
|
||||
selected: name == _selected,
|
||||
child: TextButton(
|
||||
style: AppTheme.timelineTabStyle(
|
||||
context,
|
||||
selected: name == _selected,
|
||||
),
|
||||
onPressed: () =>
|
||||
setState(() => _selected = name),
|
||||
child: Text(name),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'New timeline',
|
||||
style: AppTheme.timelineTabActionStyle,
|
||||
onPressed: () => setState(() {
|
||||
final name = 'Timeline ${_timelines.length + 1}';
|
||||
_timelines.add(name);
|
||||
_selected = name;
|
||||
}),
|
||||
icon: const Icon(AppIcons.add, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'All timelines',
|
||||
style: AppTheme.timelineTabActionStyle,
|
||||
onPressed: () {},
|
||||
icon: const Icon(AppIcons.more, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: AppDesktopMetrics.timelineToolbar,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
|
||||
child: AppCommandToolbar(
|
||||
groups: [
|
||||
[
|
||||
AppToolbarCommand(
|
||||
label: 'Undo',
|
||||
icon: AppIcons.undo,
|
||||
onPressed: () {},
|
||||
),
|
||||
const AppToolbarCommand(
|
||||
label: 'Redo',
|
||||
icon: AppIcons.redo,
|
||||
onPressed: null,
|
||||
),
|
||||
],
|
||||
[
|
||||
for (final command in [
|
||||
('Split', AppIcons.cut),
|
||||
('Trim left', AppIcons.alignLeft),
|
||||
('Trim right', AppIcons.alignRight),
|
||||
('Delete', AppIcons.delete),
|
||||
])
|
||||
AppToolbarCommand(
|
||||
label: command.$1,
|
||||
icon: command.$2,
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
],
|
||||
trailing: [
|
||||
AppToolbarCommand(
|
||||
label: 'Fit timeline',
|
||||
icon: AppIcons.fitContent,
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class WorkspacePanel extends StatelessWidget {
|
||||
required this.child,
|
||||
this.trailing,
|
||||
this.controls,
|
||||
this.headerHeight = AppControlSize.panelHeader,
|
||||
this.headerHeight,
|
||||
this.headerPadding = const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.compact,
|
||||
),
|
||||
@@ -23,7 +23,7 @@ class WorkspacePanel extends StatelessWidget {
|
||||
final Widget child;
|
||||
final Widget? trailing;
|
||||
final Widget? controls;
|
||||
final double headerHeight;
|
||||
final double? headerHeight;
|
||||
final EdgeInsetsGeometry headerPadding;
|
||||
final bool showHeaderDivider;
|
||||
final bool paintBackground;
|
||||
@@ -34,7 +34,11 @@ class WorkspacePanel extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: headerHeight,
|
||||
height:
|
||||
headerHeight ??
|
||||
(AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.panelHeader
|
||||
: AppControlSize.panelHeader),
|
||||
child: Padding(
|
||||
padding: headerPadding,
|
||||
child: Row(
|
||||
|
||||
Reference in new issue
Block a user