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,115 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:cutdex_sdk/project.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../integrations/runtime/media_presentations.dart';
|
||||
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
|
||||
import 'audio_asset_tile.dart';
|
||||
import 'media_asset_cover.dart';
|
||||
|
||||
/// Compact full-width preview used by the media library's list layout.
|
||||
class MediaAssetStrip extends StatelessWidget {
|
||||
const MediaAssetStrip({super.key, required this.asset});
|
||||
static const height = 46.0;
|
||||
final AssetDocument asset;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SizedBox(
|
||||
height: height,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (asset.metadata['kind'] == 'audio') {
|
||||
return AudioAssetTile(
|
||||
asset: asset,
|
||||
showName: false,
|
||||
aspectRatio: constraints.maxWidth / height,
|
||||
);
|
||||
}
|
||||
|
||||
return _VisualAssetStrip(asset: asset, width: constraints.maxWidth);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _VisualAssetStrip extends ConsumerWidget {
|
||||
const _VisualAssetStrip({required this.asset, required this.width});
|
||||
final AssetDocument asset;
|
||||
final double width;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final video = asset.metadata['kind'] == 'video';
|
||||
final duration = video
|
||||
? ref.watch(mediaDurationProvider(asset)).value
|
||||
: null;
|
||||
final count = (width / (MediaAssetStrip.height * 16 / 9)).ceil().clamp(
|
||||
1,
|
||||
16,
|
||||
);
|
||||
return ColoredBox(
|
||||
color: AppSurfaces.of(context).previewBackground,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (var index = 0; index < count; index++)
|
||||
Expanded(
|
||||
child: MediaAssetCover(
|
||||
asset: asset,
|
||||
fit: BoxFit.cover,
|
||||
timeMilliseconds: video && duration != null
|
||||
? (duration * 1000 * index / count).floor()
|
||||
: 0,
|
||||
fallback: const Center(child: Icon(Icons.movie_outlined)),
|
||||
errorFallback: const Center(
|
||||
child: Icon(Icons.broken_image_outlined),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MediaAssetDuration extends ConsumerWidget {
|
||||
const MediaAssetDuration({super.key, required this.asset});
|
||||
final AssetDocument asset;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
if (!const {'audio', 'video'}.contains(asset.metadata['kind'])) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final duration = ref.watch(mediaDurationProvider(asset)).value;
|
||||
if (duration == null) return const SizedBox.shrink();
|
||||
final seconds = math.max(0, duration.floor());
|
||||
final hours = seconds ~/ 3600;
|
||||
final minutes = hours > 0 ? (seconds ~/ 60) % 60 : seconds ~/ 60;
|
||||
final text =
|
||||
'${hours > 0 ? '$hours:' : ''}'
|
||||
'${minutes.toString().padLeft(2, '0')}:'
|
||||
'${(seconds % 60).toString().padLeft(2, '0')}';
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: .55),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
|
||||
child: Text(
|
||||
text,
|
||||
key: ValueKey('media-duration-${asset.id}'),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Colors.white,
|
||||
fontFeatures: const [FontFeature.tabularFigures()],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user