feat: initial Cutdex application

Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
lingjhf committed 2026-10-05 23:36:23 +08:00
commit 27e77fff39
718 files changed
+183958

No files matched your search

@@ -0,0 +1,152 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:cutdex_ui/widgets.dart';
class PropertyNumberInput extends StatefulWidget {
const PropertyNumberInput({
super.key,
required this.label,
required this.value,
required this.enabled,
required this.readOnly,
required this.submit,
this.unit,
this.decimalPlaces = 2,
this.onScrubStart,
required this.onScrubUpdate,
required this.onScrubEnd,
required this.onScrubCancel,
required this.scrubbing,
required this.editContext,
}) : assert(decimalPlaces >= 0 && decimalPlaces <= 20);
final String? label;
final String? unit;
final int decimalPlaces;
final bool Function()? onScrubStart;
final ValueChanged<double> onScrubUpdate;
final VoidCallback onScrubEnd;
final VoidCallback onScrubCancel;
final bool scrubbing;
final Object editContext;
final double value;
final bool enabled;
final bool readOnly;
final Future<bool> Function(double) submit;
@override
State<PropertyNumberInput> createState() => _PropertyNumberInputState();
}
class _PropertyNumberInputState extends State<PropertyNumberInput> {
late final _text = TextEditingController(text: _format(widget.value));
final _focus = FocusNode();
bool _dirty = false;
String? _error;
String _format(double value) {
var text = value.toStringAsFixed(widget.decimalPlaces);
if (text.contains('.')) text = text.replaceFirst(RegExp(r'\.?0+$'), '');
return text == '-0' ? '0' : text;
}
@override
void initState() {
super.initState();
_focus.addListener(_blur);
}
void _blur() {
if (!_focus.hasFocus) _submit();
}
Future<void> _submit() async {
if (!_dirty || !widget.enabled || widget.readOnly) return;
final value = double.tryParse(_text.text);
if (value == null || !value.isFinite) {
setState(() => _error = context.l10n.invalidNumber);
return;
}
_dirty = false;
final accepted = await widget.submit(value);
if (!mounted) return;
setState(() {
_error = accepted ? null : context.l10n.notApplied;
_text.text = _format(widget.value);
});
}
@override
void didUpdateWidget(covariant PropertyNumberInput oldWidget) {
super.didUpdateWidget(oldWidget);
if ((oldWidget.enabled && !widget.enabled) ||
oldWidget.editContext != widget.editContext ||
(!oldWidget.readOnly && widget.readOnly)) {
_dirty = false;
_error = null;
}
final text = _format(widget.value);
// A no-op assignment still resets selection and asks EditableText to
// reveal its caret, competing with the user's scroll on preview updates.
if (!_dirty && _text.text != text) _text.text = text;
}
@override
void dispose() {
_focus.removeListener(_blur);
_focus.dispose();
_text.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => Focus(
onKeyEvent: (_, event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape) {
setState(() {
_dirty = false;
_error = null;
_text.text = _format(widget.value);
});
_focus.unfocus();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: AppTextField(
controller: _text,
focusNode: _focus,
enabled: widget.enabled,
readOnly: widget.readOnly,
canRequestFocus: widget.enabled && !widget.readOnly,
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
signed: true,
),
label: widget.label,
leading: widget.onScrubStart == null
? null
: AppScrubLabel(
label: widget.label!,
enabled: widget.enabled && (!widget.readOnly || widget.scrubbing),
onStart: () {
_dirty = false;
_error = null;
_text.text = _format(widget.value);
return widget.onScrubStart!();
},
onUpdate: widget.onScrubUpdate,
onEnd: widget.onScrubEnd,
onCancel: widget.onScrubCancel,
),
unit: widget.unit,
errorText: _error,
onChanged: (_) {
_dirty = true;
if (_error != null) setState(() => _error = null);
},
onEditingComplete: () {},
onSubmitted: (_) => _submit(),
),
);
}