feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
This commit is contained in:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -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,
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user