Gitea CI / Check code and tests (pull_request) Failing after 8s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 1s
137 lines
4.9 KiB
Dart
137 lines
4.9 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:cutdex_core/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),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|