Files
cutdex/lib/features/editor/layouts/bounded_editor_layout.dart
T
lingjhf 06f1c26681
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
Move editor UI into the app and release verified Core dependencies (#14)
2026-10-11 19:59:40 +00:00

164 lines
5.2 KiB
Dart

import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../../../integrations/platform/device_experience.dart';
import '../../../l10n/l10n.dart';
import '../../../shared/layout/workspace_layout_metrics.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import '../editor_presentation_controller.dart';
/// Space changes the tool bounds; device experience determines its interactions.
class BoundedEditorLayout extends StatelessWidget {
const BoundedEditorLayout({
super.key,
required this.experience,
required this.editing,
required this.tool,
required this.media,
required this.properties,
required this.onCloseTool,
});
final DeviceExperience experience;
final Widget editing;
final EditorTool? tool;
final Widget media;
final Widget properties;
final VoidCallback onCloseTool;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final page = experience == DeviceExperience.phone;
final desktop = experience == DeviceExperience.desktop;
Widget toolSurface() => Column(
children: [
SizedBox(
height: desktop ? AppDesktopMetrics.panelHeader : 48,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: desktop ? AppSpacing.small : 0,
),
child: Row(
children: [
SizedBox.square(
dimension: desktop ? AppControlSize.headerButton : 48,
child: IconButton(
key: const Key('editor-tool-close'),
tooltip: MaterialLocalizations.of(context)
.closeButtonTooltip,
onPressed: onCloseTool,
icon: Icon(page ? AppIcons.arrowBack : AppIcons.close),
),
),
Expanded(
child: Text(
tool == EditorTool.media
? context.l10n.materials
: context.l10n.expandProperties,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: desktop && tool == EditorTool.properties
? AppTheme.propertiesPanelTheme(Theme.of(context))
.textTheme
.titleSmall
: null,
),
),
],
),
),
),
const Divider(height: 1),
Expanded(child: tool == EditorTool.media ? media : properties),
],
);
return PopScope<Object?>(
canPop: desktop || tool == null,
onPopInvokedWithResult: (didPop, result) {
if (didPop || desktop || tool == null) return;
final scaffold = Scaffold.maybeOf(context);
if (scaffold?.isDrawerOpen ?? false) {
scaffold!.closeDrawer();
} else {
onCloseTool();
}
},
child: Stack(
key: Key('${experience.name}-editor-tools'),
fit: StackFit.expand,
children: [
ExcludeFocus(
excluding: page && tool != null,
child: IgnorePointer(
ignoring: page && tool != null,
child: TickerMode(
enabled: !page || tool == null,
child: editing,
),
),
),
if (tool != null)
Positioned(
top: desktop ? AppDesktopMetrics.panelHeader + 1 : 0,
bottom: 0,
right: 0,
width: page
? constraints.maxWidth
: math.min(
desktop && tool == EditorTool.properties
? WorkspaceLayoutMetrics.propertiesPanelWidth
: 320,
constraints.maxWidth,
),
child: Material(
key: const Key('editor-tool-surface'),
elevation: page ? 0 : 8,
color: Theme.of(context).colorScheme.surface,
child: toolSurface(),
),
),
],
),
);
},
);
}
/// A shared preview/timeline arrangement for touch experiences.
class TouchEditingLayout extends StatelessWidget {
const TouchEditingLayout({
super.key,
required this.preview,
required this.timeline,
});
final Widget preview;
final Widget timeline;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final short = constraints.maxHeight < 340 && constraints.maxWidth >= 600;
return short
? Row(
children: [
Expanded(child: preview),
const VerticalDivider(width: 1),
Expanded(child: timeline),
],
)
: Column(
children: [
Expanded(flex: 3, child: preview),
const Divider(height: 1),
Expanded(flex: 2, child: timeline),
],
);
},
);
}