feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
This commit is contained in:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -0,0 +1,280 @@
|
||||
import 'package:cutdex_sdk/project.dart';
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../workspace/media_availability.dart';
|
||||
import 'audio_asset_tile.dart';
|
||||
import 'media_asset_strip.dart';
|
||||
import 'media_browser_layout.dart';
|
||||
import 'unavailable_media_placeholder.dart';
|
||||
import 'visual_asset_tile.dart';
|
||||
|
||||
/// Desktop cards and rows use the same cover, name and availability labels.
|
||||
class DesktopMediaAssetTile extends StatelessWidget {
|
||||
const DesktopMediaAssetTile({
|
||||
super.key,
|
||||
required this.asset,
|
||||
required this.grid,
|
||||
required this.availability,
|
||||
});
|
||||
final AssetDocument asset;
|
||||
final bool grid;
|
||||
final MediaAvailability? availability;
|
||||
|
||||
static TextStyle? _nameStyle(BuildContext context) =>
|
||||
Theme.of(context).textTheme.bodyMedium
|
||||
?.copyWith(fontSize: 13, height: 20 / 13);
|
||||
|
||||
static TextStyle? _metadataStyle(BuildContext context) =>
|
||||
Theme.of(context).textTheme.bodySmall
|
||||
?.copyWith(fontSize: 12, height: 16 / 12);
|
||||
|
||||
/// Font fallback and fractional scaling can round a line above size × height.
|
||||
static double gridLabelHeight(BuildContext context) {
|
||||
double lineHeight(TextStyle? style) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: '国Ag', style: style),
|
||||
maxLines: 1,
|
||||
textDirection: Directionality.of(context),
|
||||
textScaler: MediaQuery.textScalerOf(context),
|
||||
locale: Localizations.maybeLocaleOf(context),
|
||||
textHeightBehavior: DefaultTextStyle.of(context).textHeightBehavior,
|
||||
)..layout();
|
||||
final height = painter.height.ceilToDouble();
|
||||
painter.dispose();
|
||||
return height;
|
||||
}
|
||||
|
||||
return lineHeight(_nameStyle(context)) +
|
||||
lineHeight(_metadataStyle(context));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final unavailable =
|
||||
availability != null && availability != MediaAvailability.available;
|
||||
final kind = switch (asset.metadata['kind']) {
|
||||
'video' => context.l10n.video,
|
||||
'image' => context.l10n.picture,
|
||||
'audio' => context.l10n.audio,
|
||||
_ => context.l10n.materials,
|
||||
};
|
||||
final width = asset.metadata['width'];
|
||||
final height = asset.metadata['height'];
|
||||
final dimensions = width is num && height is num && width > 0 && height > 0
|
||||
? '${width.toInt()} × ${height.toInt()}'
|
||||
: null;
|
||||
final info = unavailable
|
||||
? availability == MediaAvailability.missing
|
||||
? context.l10n.mediaMissing
|
||||
: context.l10n.mediaUnavailable
|
||||
: dimensions == null
|
||||
? kind
|
||||
: '$kind · $dimensions';
|
||||
final name = Tooltip(
|
||||
message: asset.name,
|
||||
child: Text(
|
||||
asset.name,
|
||||
key: ValueKey('media-name-${asset.id}'),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: _nameStyle(context),
|
||||
),
|
||||
);
|
||||
Widget metadata({bool showDuration = false}) => Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
info,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: _metadataStyle(context)?.copyWith(
|
||||
color: unavailable
|
||||
? theme.colorScheme.error
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (showDuration && !unavailable) ...[
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: MediaAssetDuration(asset: asset, badge: false)),
|
||||
],
|
||||
],
|
||||
);
|
||||
final cover = ClipRRect(
|
||||
key: ValueKey('desktop-media-cover-${asset.id}'),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (unavailable)
|
||||
AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: UnavailableMediaPlaceholder(
|
||||
availability: availability!,
|
||||
showLabel: false,
|
||||
),
|
||||
)
|
||||
else
|
||||
switch (asset.metadata['kind']) {
|
||||
'video' ||
|
||||
'image' => VisualAssetTile(asset: asset, showName: false),
|
||||
'audio' => AudioAssetTile(asset: asset, showName: false),
|
||||
_ => AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: ColoredBox(
|
||||
color: AppSurfaces.of(context).previewBackground,
|
||||
child: const Center(child: Icon(AppIcons.file, size: 20)),
|
||||
),
|
||||
),
|
||||
},
|
||||
if (grid && !unavailable)
|
||||
Positioned(
|
||||
bottom: 4,
|
||||
left: 4,
|
||||
right: 4,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: MediaAssetDuration(asset: asset),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!grid) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final columns = DesktopMediaListColumns(constraints.maxWidth);
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: DesktopMediaMetrics.listCover,
|
||||
height: DesktopMediaMetrics.listCover * 9 / 16,
|
||||
child: cover,
|
||||
),
|
||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
name,
|
||||
if (!columns.specification)
|
||||
metadata(showDuration: !columns.duration),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (columns.duration)
|
||||
SizedBox(
|
||||
width: DesktopMediaListColumns.durationWidth,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: unavailable
|
||||
? const SizedBox.shrink()
|
||||
: MediaAssetDuration(asset: asset, badge: false),
|
||||
),
|
||||
),
|
||||
if (columns.specification) ...[
|
||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
||||
SizedBox(
|
||||
width: DesktopMediaListColumns.specificationWidth,
|
||||
child: Text(
|
||||
unavailable ? info : dimensions ?? '—',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: _metadataStyle(context)?.copyWith(
|
||||
color: unavailable
|
||||
? theme.colorScheme.error
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (columns.kind) ...[
|
||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
||||
SizedBox(
|
||||
width: DesktopMediaListColumns.kindWidth,
|
||||
child: Text(
|
||||
kind,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: _metadataStyle(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [cover, const SizedBox(height: 4), name, metadata()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// List labels follow the same column widths and breakpoints as asset rows.
|
||||
class DesktopMediaListHeader extends StatelessWidget {
|
||||
const DesktopMediaListHeader({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: DesktopMediaMetrics.padding + DesktopMediaMetrics.tilePadding,
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final columns = DesktopMediaListColumns(constraints.maxWidth);
|
||||
Widget label(String text, {bool end = false}) => Text(
|
||||
text,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: end ? TextAlign.end : TextAlign.start,
|
||||
style: DesktopMediaAssetTile._metadataStyle(context)
|
||||
?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
);
|
||||
return SizedBox(
|
||||
height: (MediaQuery.textScalerOf(context).scale(16) + 8).clamp(
|
||||
DesktopMediaMetrics.listHeader,
|
||||
double.infinity,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start:
|
||||
DesktopMediaMetrics.listCover + DesktopMediaMetrics.gap,
|
||||
),
|
||||
child: label(context.l10n.name),
|
||||
),
|
||||
),
|
||||
if (columns.duration)
|
||||
SizedBox(
|
||||
width: DesktopMediaListColumns.durationWidth,
|
||||
child: label(context.l10n.duration, end: true),
|
||||
),
|
||||
if (columns.specification) ...[
|
||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
||||
SizedBox(
|
||||
width: DesktopMediaListColumns.specificationWidth,
|
||||
child: label(context.l10n.mediaSpecification),
|
||||
),
|
||||
],
|
||||
if (columns.kind) ...[
|
||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
||||
SizedBox(
|
||||
width: DesktopMediaListColumns.kindWidth,
|
||||
child: label(context.l10n.mediaCategory),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user