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,167 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
enum WindowCaptionCommand { minimize, toggleMaximize, close }
enum HeaderControlRole { control, maximize }
/// Owns native window chrome while its Flutter owner is active.
class WindowChromeSession extends ChangeNotifier {
WindowChromeSession({required this._headerHeight, this._onCloseRequested});
static const _chrome = MethodChannel('cutdex_native/window');
static const _controls = MethodChannel('cutdex_native/window_controls');
static final _sessions = <WindowChromeSession>[];
static WindowChromeSession? _owner;
static bool get isWindows =>
!kIsWeb && defaultTargetPlatform == TargetPlatform.windows;
static bool get supported =>
!kIsWeb && (defaultTargetPlatform == TargetPlatform.macOS || isWindows);
double _headerHeight;
VoidCallback? _onCloseRequested;
bool _interactive = true;
bool _disposed = false;
int _revision = 0;
bool _integrated = false;
bool _maximized = false;
bool _maximizeHovered = false;
bool get integrated => _integrated;
bool get maximized => _maximized;
bool get maximizeHovered => _maximizeHovered;
void attach() {
if (!supported || _disposed || _sessions.contains(this)) return;
_sessions.add(this);
_activate();
}
void _activate() {
_owner = this;
_chrome.setMethodCallHandler(_handleMethodCall);
unawaited(_enable());
}
void configure({
required double headerHeight,
VoidCallback? onCloseRequested,
}) {
final changed =
_headerHeight != headerHeight ||
(_onCloseRequested == null) != (onCloseRequested == null);
_headerHeight = headerHeight;
_onCloseRequested = onCloseRequested;
if (changed && identical(_owner, this)) unawaited(_enable());
}
void setInteractive(bool interactive) {
if (_interactive == interactive) return;
_interactive = interactive;
if (isWindows && identical(_owner, this)) {
unawaited(_invoke<void>('setHeaderInteractive', interactive));
}
}
Future<void> perform(WindowCaptionCommand command) async {
if (!_disposed && identical(_owner, this)) {
await _invoke<void>(command.name);
}
}
Future<bool> _handleMethodCall(MethodCall call) async {
if (_disposed || !identical(_owner, this)) return false;
switch (call.method) {
case 'windowState':
final state = call.arguments as Map;
final maximized = state['maximized'] == true;
final hovered = state['maximizeHovered'] == true;
if (_maximized != maximized || _maximizeHovered != hovered) {
_maximized = maximized;
_maximizeHovered = hovered;
notifyListeners();
}
return true;
case 'requestClose':
if (_onCloseRequested == null) return false;
_onCloseRequested!();
return true;
default:
throw MissingPluginException('Unsupported window chrome method');
}
}
Future<void> _enable() async {
final revision = ++_revision;
final enabled = await _invoke<bool>('configureChrome', {
'enabled': true,
'headerHeight': _headerHeight,
'interceptClose': _onCloseRequested != null,
if (isWindows) 'headerInteractive': _interactive,
});
if (!_disposed &&
identical(_owner, this) &&
revision == _revision &&
_integrated != (enabled == true)) {
_integrated = enabled == true;
notifyListeners();
}
}
static Future<T?> _invoke<T>(String method, [Object? arguments]) async {
try {
return await _chrome.invokeMethod<T>(method, arguments);
} on MissingPluginException {
// Widget tests without native plugins keep the standard header.
} on PlatformException catch (error) {
debugPrint('Could not update window chrome: ${error.code}');
}
return null;
}
static Future<void> reportControl(
String id,
Rect? rect,
HeaderControlRole role,
) async {
try {
await _controls.invokeMethod<void>('setHeaderControlRegion', {
'id': id,
'role': role.name,
'rect': rect == null
? null
: {
'x': rect.left,
'y': rect.top,
'width': rect.width,
'height': rect.height,
},
});
} on MissingPluginException {
// Widget tests do not register native plugins.
} on PlatformException catch (error) {
debugPrint('Could not update titlebar controls: ${error.code}');
}
}
@override
void dispose() {
_disposed = true;
_sessions.remove(this);
if (identical(_owner, this)) {
_owner = null;
_chrome.setMethodCallHandler(null);
if (_sessions.isNotEmpty) {
_sessions.last._activate();
} else {
scheduleMicrotask(() {
if (_owner == null) {
unawaited(_invoke<bool>('configureChrome', {'enabled': false}));
}
});
}
}
super.dispose();
}
}