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/material.dart';
import 'package:flutter/services.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_native/cutdex_native.dart';
/// Moves the existing preview into the root overlay, retaining its native view.
class PreviewFullscreenHost extends StatefulWidget {
const PreviewFullscreenHost({super.key, required this.child});
final Widget child;
@override
State<PreviewFullscreenHost> createState() => _PreviewFullscreenHostState();
}
class _PreviewFullscreenHostState extends State<PreviewFullscreenHost> {
late final _nativeSession = NativeFullscreenSession(
onExit: () {
if (!mounted) return;
_overlay.hide();
setState(() => _fullscreen = false);
},
);
final _overlay = OverlayPortalController();
final _contentKey = GlobalKey();
bool _fullscreen = false;
bool _busy = false;
bool get _native => !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS;
Future<void> _toggle() async {
if (_busy) return;
final entering = !_fullscreen;
setState(() {
_busy = true;
_fullscreen = entering;
});
if (entering) {
_overlay.show();
if (_native) {
_nativeSession.attach();
}
} else {
_overlay.hide();
}
try {
if (_native) await _nativeSession.setFullscreen(entering);
} catch (error) {
if (mounted) {
_overlay.hide();
setState(() => _fullscreen = false);
debugPrint('Could not change preview fullscreen: $error');
}
} finally {
if (mounted) setState(() => _busy = false);
}
}
@override
void dispose() {
_nativeSession.dispose(exitFullscreen: _native && _fullscreen);
super.dispose();
}
@override
Widget build(BuildContext context) {
final fullscreenTheme = AppTheme.previewFullscreenTheme;
final previewBackground = fullscreenTheme
.extension<AppSurfaces>()!
.previewBackground;
final content = PreviewFullscreenScope(
key: _contentKey,
fullscreen: _fullscreen,
toggle: _busy ? null : _toggle,
child: widget.child,
);
return OverlayPortal(
overlayLocation: OverlayChildLocation.rootOverlay,
controller: _overlay,
overlayChildBuilder: (context) => Positioned.fill(
child: Theme(
data: fullscreenTheme,
child: Material(
color: previewBackground,
child: CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.escape): () {
if (_fullscreen && !_busy) unawaited(_toggle());
},
},
child: Focus(autofocus: true, child: content),
),
),
),
),
child: _fullscreen ? const SizedBox.expand() : content,
);
}
}
class PreviewFullscreenScope extends InheritedWidget {
const PreviewFullscreenScope({
super.key,
required this.fullscreen,
required this.toggle,
required super.child,
});
final bool fullscreen;
final VoidCallback? toggle;
static PreviewFullscreenScope? of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<PreviewFullscreenScope>();
@override
bool updateShouldNotify(PreviewFullscreenScope oldWidget) =>
fullscreen != oldWidget.fullscreen || toggle != oldWidget.toggle;
}
/// Keeps the canvas mounted while the toolbar floats over fullscreen playback.
class PreviewFullscreenLayout extends StatelessWidget {
const PreviewFullscreenLayout({
super.key,
required this.canvas,
required this.toolbar,
});
final Widget canvas;
final Widget toolbar;
@override
Widget build(BuildContext context) {
final fullscreen = PreviewFullscreenScope.of(context)?.fullscreen == true;
return Stack(
fit: StackFit.expand,
children: [
Positioned.fill(
bottom: fullscreen ? 0 : AppControlSize.panelHeader,
child: canvas,
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: fullscreen
? const EdgeInsets.only(
left: AppSpacing.extraLarge,
right: AppSpacing.extraLarge,
bottom: AppSpacing.emptyState,
)
: EdgeInsets.zero,
constraints: BoxConstraints(
maxWidth: fullscreen ? 560 : double.infinity,
),
decoration: fullscreen
? BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer
.withValues(alpha: .93),
borderRadius: BorderRadius.circular(AppRadius.large),
)
: null,
child: toolbar,
),
),
],
);
}
}