Files
cutdex/lib/features/properties/stroke_list.dart
T
lingjhf 789af7a68e feat(inspector): edit animated effects, strokes and corner distortion
Replace the shadow-only inspector with layered effect and stroke controls and per-corner distortion editors. Share color inputs, layer rows, keyframe controls and property edit boundaries; keep nested selection menus within their property popover and update localized labels.

Add property editing, preview interaction and benchmark comparison coverage. Validation: Dart analysis reports no issues and 160 targeted application tests pass. The macOS development app was rebuilt and visually checked during native rendering validation. Exclude local dependency override changes from the committed lockfile.
2026-10-10 16:55:27 +08:00

137 lines
4.9 KiB
Dart

import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'property_keyframe_controls.dart';
import 'property_layer_row.dart';
class StrokeList extends StatelessWidget {
const StrokeList({
super.key,
required this.stack,
required this.enabled,
required this.keyframes,
required this.onAdd,
required this.onReorder,
required this.onToggle,
required this.onRemove,
required this.editorBuilder,
this.error,
});
final ClipStrokeStack stack;
final bool enabled;
final PropertyKeyframeControls keyframes;
final VoidCallback onAdd;
final void Function(List<String>) onReorder;
final void Function(ClipStrokeLayer) onToggle, onRemove;
final Widget Function(ClipStrokeLayer) editorBuilder;
final String? error;
@override
Widget build(BuildContext context) {
final layers = stack.layers;
return AppPropertySection(
bottomSpacing: layers.isEmpty ? 0 : null,
child: AppPropertyGroup(
label: context.l10n.strokes,
padChild: false,
actions: [
keyframes.button(
context,
stack.parameterIds,
context.l10n.strokes,
'strokes-key',
),
IconButton(
key: const ValueKey('stroke-add'),
tooltip: context.l10n.addStroke,
onPressed: enabled && stack.canAdd ? onAdd : null,
icon: const Icon(AppIcons.add, size: 16),
),
],
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ReorderableListView(
shrinkWrap: true,
primary: false,
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
buildDefaultDragHandles: false,
onReorderItem: (from, to) {
if (!enabled) return;
final order = layers.map((l) => l.id).toList();
order.insert(to, order.removeAt(from));
onReorder(order);
},
children: [
for (var i = 0; i < layers.length; i++)
PropertyLayerRow(
key: ValueKey('stroke-layer-${layers[i].id}'),
id: layers[i].id,
prefix: 'stroke',
index: i,
enabled: enabled,
visible: layers[i].enabled,
label:
'${layers[i].values['width']!.toStringAsFixed(layers[i].values['width']! % 1 == 0 ? 0 : 1)} · ${(layers[i].values['opacity']! * 100).round()}%',
editorLabel: context.l10n.stroke,
leading: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
color: Color.from(
alpha: layers[i].values['opacity']!,
red: layers[i].values['color.r']!,
green: layers[i].values['color.g']!,
blue: layers[i].values['color.b']!,
),
borderRadius: BorderRadius.circular(3),
border: Border.all(
color: Theme.of(context).colorScheme.outlineVariant,
),
),
),
tooltip: context.l10n.strokes,
onVisibility: () => onToggle(layers[i]),
onRemove: () => onRemove(layers[i]),
menuItems: [
for (final (delta, label) in [
(-1, context.l10n.effectMoveUp),
(1, context.l10n.effectMoveDown),
])
AppMenuItem(
label: label,
closeAncestors: false,
onPressed:
!enabled ||
i + delta < 0 ||
i + delta >= layers.length
? null
: () {
final order = layers
.map((l) => l.id)
.toList();
order.insert(i + delta, order.removeAt(i));
onReorder(order);
},
),
],
editor: editorBuilder(layers[i]),
),
],
),
if (error != null)
Text(
error!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
),
),
);
}
}