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.
104 lines
3.1 KiB
Dart
104 lines
3.1 KiB
Dart
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../media/media_asset_cover.dart';
|
|
|
|
import 'package:cutdex_ui/theme.dart';
|
|
|
|
import '../media/audio_asset_tile.dart';
|
|
|
|
/// Compact project-media preview shared by the composer and sent messages.
|
|
class AgentAttachmentCard extends StatelessWidget {
|
|
const AgentAttachmentCard({super.key, required this.asset, this.onRemove});
|
|
|
|
final AssetDocument asset;
|
|
final VoidCallback? onRemove;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final kind = asset.metadata['kind'];
|
|
final colors = Theme.of(context).colorScheme;
|
|
final preview = switch (kind) {
|
|
'image' || 'video' => SizedBox.expand(
|
|
child: MediaAssetCover(
|
|
asset: asset,
|
|
fit: BoxFit.cover,
|
|
fallback: Center(
|
|
child: Icon(
|
|
kind == 'image' ? Icons.image_outlined : Icons.movie_outlined,
|
|
color: colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
errorFallback: Center(
|
|
child: Icon(
|
|
Icons.broken_image_outlined,
|
|
color: colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
'audio' => AudioAssetTile(
|
|
asset: asset,
|
|
showName: false,
|
|
aspectRatio: 132 / 96,
|
|
),
|
|
_ => Center(
|
|
child: Icon(
|
|
Icons.insert_drive_file_outlined,
|
|
color: colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
};
|
|
return SizedBox(
|
|
width: 132,
|
|
height: 122,
|
|
child: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: ColoredBox(
|
|
color: AppSurfaces.of(context).previewBackground,
|
|
child: Column(
|
|
children: [
|
|
Expanded(child: SizedBox.expand(child: preview)),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8,
|
|
vertical: 5,
|
|
),
|
|
child: Text(
|
|
asset.name,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (onRemove != null)
|
|
Positioned(
|
|
top: -4,
|
|
right: -4,
|
|
child: IconButton.filled(
|
|
key: Key('agent-attachment-remove-${asset.id}'),
|
|
tooltip: MaterialLocalizations.of(context).deleteButtonTooltip,
|
|
onPressed: onRemove,
|
|
style: IconButton.styleFrom(
|
|
minimumSize: const Size(20, 20),
|
|
maximumSize: const Size(20, 20),
|
|
padding: EdgeInsets.zero,
|
|
backgroundColor: colors.surface,
|
|
foregroundColor: colors.onSurface,
|
|
),
|
|
icon: const Icon(Icons.close, size: 13),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|