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:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
/// A host/device experience, independent of window size and connected inputs.
|
||||
enum DeviceExperience { desktop, tablet, phone }
|
||||
|
||||
final deviceExperienceProvider = Provider<DeviceExperience>((ref) {
|
||||
final display = ui.PlatformDispatcher.instance.views.firstOrNull?.display;
|
||||
return DeviceExperienceDetector.fallback(
|
||||
platform: defaultTargetPlatform,
|
||||
displaySize: display?.size ?? ui.Size.zero,
|
||||
pixelRatio: display?.devicePixelRatio ?? 1,
|
||||
);
|
||||
});
|
||||
|
||||
/// Resolves once at startup; resizing, rotation and keyboard events do not run it.
|
||||
abstract final class DeviceExperienceDetector {
|
||||
static DeviceExperience fallback({
|
||||
required TargetPlatform platform,
|
||||
required ui.Size displaySize,
|
||||
required double pixelRatio,
|
||||
}) {
|
||||
if (platform != TargetPlatform.android && platform != TargetPlatform.iOS) {
|
||||
return DeviceExperience.desktop;
|
||||
}
|
||||
// This is the full display, never MediaQuery's application window.
|
||||
return pixelRatio > 0 && displaySize.shortestSide / pixelRatio >= 600
|
||||
? DeviceExperience.tablet
|
||||
: DeviceExperience.phone;
|
||||
}
|
||||
|
||||
static Future<DeviceExperience> detect({
|
||||
required TargetPlatform platform,
|
||||
required ui.Size displaySize,
|
||||
required double pixelRatio,
|
||||
bool web = false,
|
||||
}) async {
|
||||
final defaultExperience = fallback(
|
||||
platform: platform,
|
||||
displaySize: displaySize,
|
||||
pixelRatio: pixelRatio,
|
||||
);
|
||||
if (web ||
|
||||
(platform != TargetPlatform.android &&
|
||||
platform != TargetPlatform.iOS)) {
|
||||
return defaultExperience;
|
||||
}
|
||||
final info = await NativeDeviceInfo.read();
|
||||
if (platform == TargetPlatform.iOS) {
|
||||
return switch (info?.interfaceIdiom) {
|
||||
NativeInterfaceIdiom.pad => DeviceExperience.tablet,
|
||||
NativeInterfaceIdiom.mac => DeviceExperience.desktop,
|
||||
NativeInterfaceIdiom.phone => DeviceExperience.phone,
|
||||
null => defaultExperience,
|
||||
};
|
||||
}
|
||||
final shortestSide = info?.displayShortestSideDp;
|
||||
return shortestSide == null
|
||||
? defaultExperience
|
||||
: shortestSide >= 600
|
||||
? DeviceExperience.tablet
|
||||
: DeviceExperience.phone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'window_caption_controls.dart';
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
|
||||
/// Shared native titlebar layout; a close callback opts into editor navigation.
|
||||
class EditorWindowChrome extends StatefulWidget {
|
||||
const EditorWindowChrome({
|
||||
super.key,
|
||||
required this.headerHeight,
|
||||
this.onCloseRequested,
|
||||
required this.builder,
|
||||
});
|
||||
|
||||
static const trafficLightWidth = 88.0;
|
||||
static bool get isWindows => WindowChromeSession.isWindows;
|
||||
static double get leadingWidth => isWindows ? 0 : trafficLightWidth;
|
||||
final double headerHeight;
|
||||
final VoidCallback? onCloseRequested;
|
||||
final Widget Function(BuildContext context, bool integrated) builder;
|
||||
|
||||
@override
|
||||
State<EditorWindowChrome> createState() => _EditorWindowChromeState();
|
||||
}
|
||||
|
||||
class _EditorWindowChromeState extends State<EditorWindowChrome> {
|
||||
late final _session = WindowChromeSession(
|
||||
headerHeight: widget.headerHeight,
|
||||
onCloseRequested: widget.onCloseRequested,
|
||||
);
|
||||
bool _integrated = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_session.addListener(_integrationChanged);
|
||||
_session.attach();
|
||||
}
|
||||
|
||||
void _integrationChanged() {
|
||||
if (_integrated != _session.integrated) {
|
||||
setState(() => _integrated = _session.integrated);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_session.setInteractive(ModalRoute.of(context)?.isCurrent ?? true);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant EditorWindowChrome oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
_session.configure(
|
||||
headerHeight: widget.headerHeight,
|
||||
onCloseRequested: widget.onCloseRequested,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_session.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_integrated || !EditorWindowChrome.isWindows) {
|
||||
return widget.builder(context, _integrated);
|
||||
}
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) => WindowHeaderLayout(
|
||||
captionBounds: Rect.fromLTWH(
|
||||
constraints.maxWidth - WindowCaptionControls.width,
|
||||
0,
|
||||
WindowCaptionControls.width,
|
||||
widget.headerHeight,
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Builder(builder: (context) => widget.builder(context, true)),
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
width: WindowCaptionControls.width,
|
||||
height: widget.headerHeight,
|
||||
child: WindowCaptionControls(
|
||||
session: _session,
|
||||
height: widget.headerHeight,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:filegate/filegate.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../workspace/media_import.dart';
|
||||
|
||||
part 'file_picker.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
AppFilePicker filePicker(Ref ref) => const AppFilePicker();
|
||||
|
||||
class AppFilePicker {
|
||||
const AppFilePicker();
|
||||
|
||||
Future<String?> pickDirectory({
|
||||
String? initialDirectory,
|
||||
String? confirmButtonText,
|
||||
}) async {
|
||||
final entry = await const Filegate().pickDirectory(
|
||||
initialDirectory: initialDirectory,
|
||||
confirmButtonText: confirmButtonText,
|
||||
);
|
||||
return entry == null ? null : _localPath(entry);
|
||||
}
|
||||
|
||||
Future<List<ExternalMediaFile>> pickFiles({
|
||||
required List<String> allowedExtensions,
|
||||
}) async {
|
||||
final entries = await const Filegate().pickFiles(
|
||||
allowMultiple: true,
|
||||
allowedExtensions: allowedExtensions,
|
||||
persistAccess: false,
|
||||
);
|
||||
return [
|
||||
for (final entry in entries ?? <PickedEntry>[])
|
||||
if (entry.isContentUri)
|
||||
ExternalMediaFile.content(
|
||||
uri: entry.uri!,
|
||||
name: entry.name,
|
||||
byteLength: entry.size,
|
||||
)
|
||||
else
|
||||
ExternalMediaFile(path: _localPath(entry)),
|
||||
];
|
||||
}
|
||||
|
||||
String _localPath(PickedEntry entry) {
|
||||
final path = entry.fileSystemPath;
|
||||
if (path == null) {
|
||||
throw PlatformException(
|
||||
code: 'unsupported_location',
|
||||
message: 'Cutdex requires a local file system path.',
|
||||
details: entry.path,
|
||||
);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'file_picker.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(filePicker)
|
||||
final filePickerProvider = FilePickerProvider._();
|
||||
|
||||
final class FilePickerProvider
|
||||
extends $FunctionalProvider<AppFilePicker, AppFilePicker, AppFilePicker>
|
||||
with $Provider<AppFilePicker> {
|
||||
FilePickerProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'filePickerProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$filePickerHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<AppFilePicker> $createElement($ProviderPointer pointer) =>
|
||||
$ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
AppFilePicker create(Ref ref) {
|
||||
return filePicker(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(AppFilePicker value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<AppFilePicker>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$filePickerHash() => r'8f869df0d25e7b43e434586c35e8e6aed225245d';
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:filegate/filegate.dart';
|
||||
|
||||
/// Streams provider documents without exposing filegate to workspace logic.
|
||||
class MediaSourceReader {
|
||||
const MediaSourceReader();
|
||||
|
||||
Stream<List<int>> openRead(Uri uri) async* {
|
||||
final session = const Filegate().openRead(uri.toString());
|
||||
try {
|
||||
yield* session.stream;
|
||||
} finally {
|
||||
await session.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
|
||||
import '../../workspace/media_file_extensions.dart';
|
||||
import '../../workspace/media_import.dart';
|
||||
|
||||
/// File acceptance shared by Flutter and the native drop destinations.
|
||||
enum NativeFileDropPolicy {
|
||||
mediaLibrary,
|
||||
timeline,
|
||||
attachments;
|
||||
|
||||
List<String>? get allowedExtensions => switch (this) {
|
||||
timeline => selectableTimelineFileExtensions,
|
||||
// Library imports validate each file so mixed batches retain valid media.
|
||||
mediaLibrary || attachments => null,
|
||||
};
|
||||
|
||||
int? get maximumFileCount => this == timeline ? 1 : null;
|
||||
|
||||
bool accepts(List<ExternalMediaFile> files) =>
|
||||
files.every((file) => file.localPath != null) &&
|
||||
configuration.accepts([for (final file in files) file.localPath!]);
|
||||
|
||||
NativeDropConfiguration get configuration => NativeDropConfiguration(
|
||||
allowedExtensions: allowedExtensions,
|
||||
maximumFileCount: maximumFileCount,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../workspace/media_import.dart';
|
||||
import 'native_file_drop_policy.dart';
|
||||
|
||||
/// Applies application media rules to a generic native file destination.
|
||||
class NativeProjectDropRegion extends StatelessWidget {
|
||||
const NativeProjectDropRegion({
|
||||
super.key,
|
||||
this.regionId = 'media-library',
|
||||
this.policy = NativeFileDropPolicy.mediaLibrary,
|
||||
required this.enabled,
|
||||
required this.onEnter,
|
||||
required this.onExit,
|
||||
required this.onDrop,
|
||||
required this.child,
|
||||
});
|
||||
final String regionId;
|
||||
final NativeFileDropPolicy policy;
|
||||
final bool enabled;
|
||||
final ValueChanged<List<ExternalMediaFile>> onEnter;
|
||||
final VoidCallback onExit;
|
||||
final Future<void> Function(List<ExternalMediaFile>) onDrop;
|
||||
final Widget child;
|
||||
|
||||
List<ExternalMediaFile> _files(List<String> paths) => [
|
||||
for (final path in paths) ExternalMediaFile(path: path),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => NativeFileDropRegion(
|
||||
regionId: regionId,
|
||||
configuration: policy.configuration,
|
||||
enabled: enabled,
|
||||
onEnter: (paths) => onEnter(_files(paths)),
|
||||
onExit: onExit,
|
||||
onDrop: (paths) => onDrop(_files(paths)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final platformCapabilitiesProvider = Provider<PlatformCapabilities>(
|
||||
(ref) => PlatformCapabilities(
|
||||
localFileSelection: !kIsWeb,
|
||||
nativeFileDrop:
|
||||
!kIsWeb &&
|
||||
(defaultTargetPlatform == TargetPlatform.macOS ||
|
||||
defaultTargetPlatform == TargetPlatform.windows),
|
||||
),
|
||||
);
|
||||
|
||||
/// Describes supported integration paths, never a workspace size class.
|
||||
final class PlatformCapabilities {
|
||||
const PlatformCapabilities({
|
||||
required this.localFileSelection,
|
||||
required this.nativeFileDrop,
|
||||
});
|
||||
final bool localFileSelection;
|
||||
final bool nativeFileDrop;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
|
||||
/// Windows caption buttons; native window state only rebuilds this strip.
|
||||
class WindowCaptionControls extends StatelessWidget {
|
||||
const WindowCaptionControls({
|
||||
super.key,
|
||||
required this.session,
|
||||
required this.height,
|
||||
});
|
||||
static const buttonWidth = 46.0;
|
||||
static const width = buttonWidth * 3;
|
||||
final WindowChromeSession session;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: session,
|
||||
builder: (context, _) => Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Row(
|
||||
children: [
|
||||
_button(
|
||||
context,
|
||||
WindowCaptionCommand.minimize,
|
||||
Icons.remove,
|
||||
context.l10n.windowMinimize,
|
||||
),
|
||||
_button(
|
||||
context,
|
||||
WindowCaptionCommand.toggleMaximize,
|
||||
session.maximized ? Icons.filter_none : Icons.crop_square,
|
||||
session.maximized
|
||||
? context.l10n.windowRestore
|
||||
: context.l10n.windowMaximize,
|
||||
role: HeaderControlRole.maximize,
|
||||
hovered: session.maximizeHovered,
|
||||
),
|
||||
_button(
|
||||
context,
|
||||
WindowCaptionCommand.close,
|
||||
Icons.close,
|
||||
MaterialLocalizations.of(context).closeButtonTooltip,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _button(
|
||||
BuildContext context,
|
||||
WindowCaptionCommand command,
|
||||
IconData icon,
|
||||
String label, {
|
||||
HeaderControlRole role = HeaderControlRole.control,
|
||||
bool hovered = false,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final close = command == WindowCaptionCommand.close;
|
||||
final key = command == WindowCaptionCommand.toggleMaximize
|
||||
? 'maximize'
|
||||
: command.name;
|
||||
return HeaderControlRegion(
|
||||
role: role,
|
||||
child: SizedBox(
|
||||
width: buttonWidth,
|
||||
height: height,
|
||||
child: IconButton(
|
||||
key: Key('window-$key'),
|
||||
tooltip: label,
|
||||
onPressed: () => unawaited(session.perform(command)),
|
||||
icon: Icon(icon, size: 16),
|
||||
style: ButtonStyle(
|
||||
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
|
||||
shape: const WidgetStatePropertyAll(RoundedRectangleBorder()),
|
||||
backgroundColor: WidgetStateProperty.resolveWith(
|
||||
(states) => states.contains(WidgetState.hovered) || hovered
|
||||
? close
|
||||
? const Color(0xffc42b1c)
|
||||
: colors.onSurface.withValues(alpha: 0.08)
|
||||
: Colors.transparent,
|
||||
),
|
||||
foregroundColor: WidgetStateProperty.resolveWith(
|
||||
(states) => close && states.contains(WidgetState.hovered)
|
||||
? Colors.white
|
||||
: colors.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user