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,213 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../integrations/platform/native_project_drop_region.dart';
|
||||
import '../../integrations/platform/platform_capabilities.dart';
|
||||
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
import '../../shared/widgets/drop_to_add_overlay.dart';
|
||||
import '../../workspace/external_media_import.dart';
|
||||
import '../../workspace/projects.dart';
|
||||
import 'media_browser_body.dart';
|
||||
import 'media_browser_controller.dart';
|
||||
import 'media_browser_feedback.dart';
|
||||
|
||||
/// Desktop presentation owns compact controls and native file dragging.
|
||||
class MediaPanel extends ConsumerStatefulWidget {
|
||||
const MediaPanel({
|
||||
super.key,
|
||||
required this.projectId,
|
||||
this.backgroundColor,
|
||||
this.grid,
|
||||
this.onGridChanged,
|
||||
}) : assert((grid == null) == (onGridChanged == null));
|
||||
final String projectId;
|
||||
final Color? backgroundColor;
|
||||
final bool? grid;
|
||||
final ValueChanged<bool>? onGridChanged;
|
||||
@override
|
||||
ConsumerState<MediaPanel> createState() => _MediaPanelState();
|
||||
}
|
||||
|
||||
class _MediaPanelState extends ConsumerState<MediaPanel> {
|
||||
bool _hovering = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.watch(projectsProvider);
|
||||
final browser = ref.watch(mediaBrowserProvider(widget.projectId));
|
||||
ref.watch(externalMediaImportProvider(widget.projectId));
|
||||
final nativeDrop = ref.watch(platformCapabilitiesProvider).nativeFileDrop;
|
||||
return ListenableBuilder(
|
||||
listenable: browser,
|
||||
builder: (context, _) {
|
||||
final grid = widget.grid ?? browser.grid;
|
||||
final visible =
|
||||
TickerMode.valuesOf(context).enabled &&
|
||||
(ModalRoute.of(context)?.isCurrent ?? true);
|
||||
final enabled = browser.canImport && visible;
|
||||
void toggleGrid() {
|
||||
final next = !grid;
|
||||
if (widget.onGridChanged case final onChanged?) {
|
||||
onChanged(next);
|
||||
} else {
|
||||
browser.grid = next;
|
||||
}
|
||||
}
|
||||
|
||||
final content = MediaImportFeedbackListener(
|
||||
feedback: browser.feedback,
|
||||
child: Material(
|
||||
key: const Key('media-panel-surface'),
|
||||
color: widget.backgroundColor,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const Key('media-panel-header'),
|
||||
height: AppControlSize.panelToolbar,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(AppSpacing.gap),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxWidth < 180;
|
||||
final controls = Row(
|
||||
mainAxisSize: compact
|
||||
? MainAxisSize.min
|
||||
: MainAxisSize.max,
|
||||
children: [
|
||||
if (compact)
|
||||
SizedBox.square(
|
||||
dimension: AppControlSize.headerButton,
|
||||
child: IconButton(
|
||||
key: const Key('media-import-button'),
|
||||
tooltip: context.l10n.importMedia,
|
||||
onPressed: enabled
|
||||
? () => pickMediaFiles(browser)
|
||||
: null,
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
SizedBox(
|
||||
height: AppControlSize.headerButton,
|
||||
child: TextButton.icon(
|
||||
key: const Key('media-import-button'),
|
||||
style: AppTheme.toolbarButtonStyle(
|
||||
context,
|
||||
),
|
||||
onPressed: enabled
|
||||
? () => pickMediaFiles(browser)
|
||||
: null,
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
label: Text(context.l10n.importMedia),
|
||||
),
|
||||
),
|
||||
if (compact)
|
||||
const SizedBox(width: AppSpacing.tiny)
|
||||
else
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
width: 76,
|
||||
child: AppSelect<MediaFilter>(
|
||||
emptyLabel: context.l10n.noMatchingOptions,
|
||||
label: context.l10n.mediaCategory,
|
||||
outlined: false,
|
||||
controlHeight: AppControlSize.headerButton,
|
||||
textStyle: AppTheme.toolbarTextStyle(
|
||||
context,
|
||||
),
|
||||
value: browser.filter,
|
||||
onChanged: (value) =>
|
||||
browser.filter = value,
|
||||
options: [
|
||||
for (final filter in MediaFilter.values)
|
||||
AppSelectOption(
|
||||
filter,
|
||||
filter.label(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
SizedBox.square(
|
||||
dimension: AppControlSize.headerButton,
|
||||
child: IconButton(
|
||||
key: const Key('media-layout-toggle'),
|
||||
onPressed: toggleGrid,
|
||||
icon: Icon(
|
||||
grid
|
||||
? Icons.view_list_outlined
|
||||
: Icons.grid_view_outlined,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
tooltip: grid
|
||||
? context.l10n.listLayout
|
||||
: context.l10n.gridLayout,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
return compact
|
||||
? SingleChildScrollView(
|
||||
key: const Key('media-header-scroll'),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: controls,
|
||||
)
|
||||
: controls;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
key: const Key('media-panel-body'),
|
||||
child: MediaBrowserBody(
|
||||
projectId: widget.projectId,
|
||||
grid: grid,
|
||||
draggable: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (browser.busy)
|
||||
const DelayedLoadingIndicator(
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: LinearProgressIndicator(),
|
||||
),
|
||||
),
|
||||
if (_hovering && enabled)
|
||||
const DropToAddOverlay(key: Key('media-drop-highlight')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!nativeDrop) return content;
|
||||
return NativeProjectDropRegion(
|
||||
enabled: visible && browser.active && (enabled || browser.busy),
|
||||
onEnter: (_) {
|
||||
if (enabled) setState(() => _hovering = true);
|
||||
},
|
||||
onExit: () {
|
||||
if (mounted && _hovering) setState(() => _hovering = false);
|
||||
},
|
||||
onDrop: (files) async {
|
||||
setState(() => _hovering = false);
|
||||
await importMediaFiles(browser, files);
|
||||
},
|
||||
child: content,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user