refactor(desktop): reorganize workspace panels and navigation
This commit is contained in:
1 parent
826745b407
commit
1f73765745
92 files changed
+5811
-2650
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'subtitle_download.dart';
|
||||
@@ -691,8 +692,8 @@ class _SubtitleTaskCardState extends ConsumerState<_SubtitleTaskCard> {
|
||||
setState(() => _validationError = null);
|
||||
await action();
|
||||
if (mounted && !widget.details && _error != null) {
|
||||
ScaffoldMessenger.maybeOf(context)
|
||||
?.showSnackBar(SnackBar(content: Text(_error!)));
|
||||
ErrorNotificationHost.maybeOf(context)
|
||||
?.show(ErrorNotification(content: Text(_error!)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||
import 'package:cutdex/errors/app_failure.dart';
|
||||
|
||||
import 'dart:math' as math;
|
||||
@@ -34,6 +35,7 @@ extension MediaFilterLabel on MediaFilter {
|
||||
}
|
||||
|
||||
const maximumMediaGridTileWidth = 160.0;
|
||||
const maximumCompactMediaGridTileWidth = 120.0;
|
||||
|
||||
class MediaBrowserBody extends ConsumerStatefulWidget {
|
||||
const MediaBrowserBody({
|
||||
@@ -41,10 +43,12 @@ class MediaBrowserBody extends ConsumerStatefulWidget {
|
||||
required this.projectId,
|
||||
required this.grid,
|
||||
this.draggable = false,
|
||||
this.compact = false,
|
||||
});
|
||||
final String projectId;
|
||||
final bool grid;
|
||||
final bool draggable;
|
||||
final bool compact;
|
||||
@override
|
||||
ConsumerState<MediaBrowserBody> createState() => _MediaBrowserBodyState();
|
||||
}
|
||||
@@ -82,16 +86,11 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
||||
Future<void> _action(Future<bool> Function() action) async {
|
||||
final ok = await action();
|
||||
if (!mounted || ok) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
context.l10n.failureMessage(
|
||||
ref.read(projectsProvider).asData?.value.error ??
|
||||
const AppFailure(AppErrorCode.operationFailed),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final failure =
|
||||
ref.read(projectsProvider).asData?.value.error ??
|
||||
const AppFailure(AppErrorCode.operationFailed);
|
||||
ErrorNotificationHost.of(context)
|
||||
.showFailure(failure, context.l10n.failureMessage(failure));
|
||||
}
|
||||
|
||||
Future<void> _rename(AssetDocument asset) async {
|
||||
@@ -166,7 +165,17 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
||||
);
|
||||
Widget _buildBrowser(BuildContext context) {
|
||||
ref.watch(externalMediaImportProvider(widget.projectId));
|
||||
final workspace = ref.watch(projectsProvider).asData?.value;
|
||||
ref.watch(
|
||||
projectsProvider.select(
|
||||
(value) => (
|
||||
value.value?.activeProject?.id,
|
||||
value.value?.assets,
|
||||
value.value?.timeline?.id,
|
||||
value.value?.projectBusy,
|
||||
),
|
||||
),
|
||||
);
|
||||
final workspace = ref.read(projectsProvider).value;
|
||||
final active = workspace?.activeProject?.id == widget.projectId;
|
||||
final allAssets = active ? workspace!.assets : <AssetDocument>[];
|
||||
final assets = _filter == MediaFilter.all
|
||||
@@ -197,15 +206,22 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
||||
)
|
||||
: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const spacing = AppSpacing.small;
|
||||
final width = math.max(
|
||||
1.0,
|
||||
constraints.maxWidth - AppSpacing.compact * 2,
|
||||
);
|
||||
final spacing = widget.compact
|
||||
? AppSpacing.gap
|
||||
: AppSpacing.small;
|
||||
final padding = widget.compact
|
||||
? AppSidebarMetrics.outerPadding
|
||||
: AppSpacing.compact;
|
||||
final width = math.max(1.0, constraints.maxWidth - padding * 2);
|
||||
final columns = math.max(
|
||||
1,
|
||||
((width + spacing) / (maximumMediaGridTileWidth + spacing))
|
||||
.ceil(),
|
||||
widget.compact
|
||||
? ((width + spacing) /
|
||||
(maximumCompactMediaGridTileWidth + spacing))
|
||||
.ceil()
|
||||
: ((width + spacing) /
|
||||
(maximumMediaGridTileWidth + spacing))
|
||||
.ceil(),
|
||||
);
|
||||
final tileWidth = (width - spacing * (columns - 1)) / columns;
|
||||
final textStyle = Theme.of(context).textTheme.bodySmall!;
|
||||
@@ -308,23 +324,26 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
||||
? ListView.separated(
|
||||
key: PageStorageKey(('media-list', widget.projectId)),
|
||||
controller: controller,
|
||||
padding: const EdgeInsets.all(AppSpacing.compact),
|
||||
padding: EdgeInsets.all(padding),
|
||||
itemCount: assets.length,
|
||||
itemBuilder: item,
|
||||
separatorBuilder: (_, _) =>
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
separatorBuilder: (_, _) => SizedBox(height: spacing),
|
||||
)
|
||||
: GridView.builder(
|
||||
key: PageStorageKey(('media-grid', widget.projectId)),
|
||||
controller: controller,
|
||||
padding: const EdgeInsets.all(AppSpacing.compact),
|
||||
padding: EdgeInsets.all(padding),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: columns,
|
||||
crossAxisSpacing: spacing,
|
||||
mainAxisSpacing: AppSpacing.compact,
|
||||
mainAxisSpacing: widget.compact
|
||||
? spacing
|
||||
: AppSpacing.compact,
|
||||
mainAxisExtent:
|
||||
tileWidth * 9 / 16 +
|
||||
AppSpacing.small +
|
||||
(widget.compact
|
||||
? AppSpacing.gap
|
||||
: AppSpacing.small) +
|
||||
labelHeight +
|
||||
2,
|
||||
),
|
||||
@@ -403,7 +422,7 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
SizedBox(height: widget.compact ? AppSpacing.gap : AppSpacing.small),
|
||||
name,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
@@ -74,7 +75,7 @@ class _MediaImportFeedbackListenerState
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scheduled = false;
|
||||
if (!mounted || !_visible || !widget.feedback.hasPending) return;
|
||||
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||
final messenger = ErrorNotificationHost.maybeOf(context);
|
||||
if (messenger == null) return;
|
||||
for (final result in widget.feedback.takePending()) {
|
||||
final messages = [
|
||||
@@ -84,8 +85,13 @@ class _MediaImportFeedbackListenerState
|
||||
'${failure.name}: ${context.l10n.failureMessage(failure.failure)}',
|
||||
if (result?.failed == true) context.l10n.noImportableFiles,
|
||||
];
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
messenger.show(
|
||||
ErrorNotification(
|
||||
details: [
|
||||
for (final failure
|
||||
in result?.result?.failures ?? <MediaImportFailure>[])
|
||||
'${failure.name}: code=${failure.failure.code.name}\n${failure.failure.diagnostic ?? ''}',
|
||||
].join('\n'),
|
||||
content: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 180),
|
||||
child: SingleChildScrollView(child: Text(messages.join('\n'))),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
@@ -142,8 +143,8 @@ class TouchMediaBrowser extends ConsumerWidget {
|
||||
selected,
|
||||
);
|
||||
if (!inserted && context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
ErrorNotificationHost.of(context).show(
|
||||
ErrorNotification(
|
||||
content: Text(context.l10n.operationFailed),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../workspace/project_state.dart';
|
||||
import 'media_browser_body.dart';
|
||||
import 'media_browser_controller.dart';
|
||||
|
||||
class MediaBrowserToolbar extends StatefulWidget {
|
||||
const MediaBrowserToolbar({
|
||||
super.key,
|
||||
required this.canImport,
|
||||
required this.onImport,
|
||||
required this.filter,
|
||||
required this.onFilterChanged,
|
||||
required this.grid,
|
||||
required this.onToggleGrid,
|
||||
this.projects = const [],
|
||||
this.selectedProjectId,
|
||||
this.onProjectSelected,
|
||||
});
|
||||
|
||||
final bool canImport;
|
||||
final VoidCallback onImport;
|
||||
final MediaFilter filter;
|
||||
final ValueChanged<MediaFilter> onFilterChanged;
|
||||
final bool grid;
|
||||
final VoidCallback onToggleGrid;
|
||||
final List<RecentProject> projects;
|
||||
final String? selectedProjectId;
|
||||
final ValueChanged<RecentProject>? onProjectSelected;
|
||||
|
||||
@override
|
||||
State<MediaBrowserToolbar> createState() => _MediaBrowserToolbarState();
|
||||
}
|
||||
|
||||
class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
|
||||
Object? _filterConfiguration;
|
||||
Widget? _filterControls;
|
||||
|
||||
bool get canImport => widget.canImport;
|
||||
VoidCallback get onImport => widget.onImport;
|
||||
MediaFilter get filter => widget.filter;
|
||||
ValueChanged<MediaFilter> get onFilterChanged =>
|
||||
(value) => widget.onFilterChanged(value);
|
||||
bool get grid => widget.grid;
|
||||
VoidCallback get onToggleGrid =>
|
||||
() => widget.onToggleGrid();
|
||||
List<RecentProject> get projects => widget.projects;
|
||||
String? get selectedProjectId => widget.selectedProjectId;
|
||||
ValueChanged<RecentProject>? get onProjectSelected =>
|
||||
widget.onProjectSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final configuration = (
|
||||
filter,
|
||||
grid,
|
||||
Theme.of(context),
|
||||
Localizations.localeOf(context),
|
||||
MediaQuery.textScalerOf(context),
|
||||
Directionality.of(context),
|
||||
);
|
||||
if (_filterConfiguration != configuration) {
|
||||
_filterConfiguration = configuration;
|
||||
_filterControls = null;
|
||||
}
|
||||
final selected = projects
|
||||
.where((project) => project.id == selectedProjectId)
|
||||
.firstOrNull;
|
||||
Widget row(Key key, Widget child) => SizedBox(
|
||||
key: key,
|
||||
height: AppControlSize.panelToolbar,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSidebarMetrics.outerPadding,
|
||||
vertical: AppSpacing.gap,
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
return Column(
|
||||
key: const Key('media-panel-header'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
row(
|
||||
const Key('media-project-row'),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(
|
||||
text: context.l10n.importMedia,
|
||||
style: AppTheme.toolbarTextStyle(context),
|
||||
),
|
||||
textDirection: Directionality.of(context),
|
||||
textScaler: MediaQuery.textScalerOf(context),
|
||||
)..layout();
|
||||
final compact = constraints.maxWidth < painter.width + 140;
|
||||
painter.dispose();
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppDropdownMenu(
|
||||
enabled: onProjectSelected != null && projects.isNotEmpty,
|
||||
maxHeight: 320,
|
||||
items: [
|
||||
for (final project in projects)
|
||||
AppMenuItem(
|
||||
key: ValueKey('media-project-${project.id}'),
|
||||
label: project.name,
|
||||
selected: project.id == selectedProjectId,
|
||||
selectOption: true,
|
||||
onPressed: onProjectSelected == null
|
||||
? null
|
||||
: () => onProjectSelected!(project),
|
||||
),
|
||||
],
|
||||
builder: (context, toggle, focusNode) =>
|
||||
AppToolbarDropdownButton(
|
||||
buttonKey: const Key('media-project-button'),
|
||||
focusNode: focusNode,
|
||||
onPressed: toggle,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
selected?.name ??
|
||||
context.l10n.selectProject,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
if (compact)
|
||||
SizedBox.square(
|
||||
dimension: AppControlSize.headerButton,
|
||||
child: IconButton(
|
||||
key: const Key('media-import-button'),
|
||||
tooltip: context.l10n.importMedia,
|
||||
onPressed: canImport ? onImport : 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: canImport ? onImport : null,
|
||||
icon: const Icon(Icons.add, size: AppIconSize.header),
|
||||
label: Text(context.l10n.importMedia),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
_filterControls ??= row(
|
||||
const Key('media-filter-row'),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: SizedBox(
|
||||
width: 88,
|
||||
height: AppControlSize.headerButton,
|
||||
child: Semantics(
|
||||
label: context.l10n.mediaCategory,
|
||||
child: AppDropdownMenu(
|
||||
items: [
|
||||
for (final option in MediaFilter.values)
|
||||
AppMenuItem(
|
||||
label: option.label(context),
|
||||
selected: option == filter,
|
||||
selectOption: true,
|
||||
onPressed: () => onFilterChanged(option),
|
||||
),
|
||||
],
|
||||
builder: (context, toggle, focus) =>
|
||||
AppToolbarDropdownButton(
|
||||
buttonKey: const Key('media-category-button'),
|
||||
focusNode: focus,
|
||||
onPressed: toggle,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
filter.label(context),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
SizedBox.square(
|
||||
dimension: AppControlSize.headerButton,
|
||||
child: IconButton(
|
||||
key: const Key('media-layout-toggle'),
|
||||
onPressed: onToggleGrid,
|
||||
icon: Icon(
|
||||
grid ? Icons.view_list_outlined : Icons.grid_view_outlined,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
tooltip: grid
|
||||
? context.l10n.listLayout
|
||||
: context.l10n.gridLayout,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
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 '../../shared/widgets/listenable_selector.dart';
|
||||
import '../../workspace/external_media_import.dart';
|
||||
import '../../workspace/projects.dart';
|
||||
import '../../workspace/project_state.dart';
|
||||
import '../../l10n/l10n.dart';
|
||||
import 'media_browser_body.dart';
|
||||
import 'media_browser_toolbar.dart';
|
||||
import 'media_browser_controller.dart';
|
||||
import 'media_browser_feedback.dart';
|
||||
|
||||
@@ -23,8 +25,10 @@ class MediaPanel extends ConsumerStatefulWidget {
|
||||
this.backgroundColor,
|
||||
this.grid,
|
||||
this.onGridChanged,
|
||||
this.onSelectProject,
|
||||
}) : assert((grid == null) == (onGridChanged == null));
|
||||
final String projectId;
|
||||
final String? projectId;
|
||||
final ValueChanged<RecentProject>? onSelectProject;
|
||||
final Color? backgroundColor;
|
||||
final bool? grid;
|
||||
final ValueChanged<bool>? onGridChanged;
|
||||
@@ -34,14 +38,70 @@ class MediaPanel extends ConsumerStatefulWidget {
|
||||
|
||||
class _MediaPanelState extends ConsumerState<MediaPanel> {
|
||||
bool _hovering = false;
|
||||
(String, bool)? _bodyConfiguration;
|
||||
Widget? _body;
|
||||
|
||||
Widget _browserBody(String projectId, bool grid) {
|
||||
final configuration = (projectId, grid);
|
||||
if (_bodyConfiguration != configuration) {
|
||||
_bodyConfiguration = configuration;
|
||||
_body = MediaBrowserBody(
|
||||
projectId: projectId,
|
||||
grid: grid,
|
||||
draggable: true,
|
||||
compact: true,
|
||||
);
|
||||
}
|
||||
return _body!;
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant MediaPanel oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.projectId != widget.projectId) _hovering = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.watch(projectsProvider);
|
||||
final browser = ref.watch(mediaBrowserProvider(widget.projectId));
|
||||
ref.watch(externalMediaImportProvider(widget.projectId));
|
||||
final workspace = ref.watch(
|
||||
projectsProvider.select(
|
||||
(value) => (
|
||||
value.value?.recent ?? const <RecentProject>[],
|
||||
value.value?.projectBusy ?? false,
|
||||
value.value?.activeProject?.id,
|
||||
),
|
||||
),
|
||||
);
|
||||
final projectId = widget.projectId;
|
||||
final onSelectProject = workspace.$2 ? null : widget.onSelectProject;
|
||||
if (projectId == null) {
|
||||
return Material(
|
||||
key: const Key('media-panel-surface'),
|
||||
color: widget.backgroundColor ?? Colors.transparent,
|
||||
child: Column(
|
||||
children: [
|
||||
MediaBrowserToolbar(
|
||||
projects: workspace.$1,
|
||||
onProjectSelected: onSelectProject,
|
||||
canImport: false,
|
||||
onImport: () {},
|
||||
filter: MediaFilter.all,
|
||||
onFilterChanged: (_) {},
|
||||
grid: true,
|
||||
onToggleGrid: () {},
|
||||
),
|
||||
Expanded(child: Center(child: Text(context.l10n.selectProject))),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final browser = ref.watch(mediaBrowserProvider(projectId));
|
||||
ref.watch(externalMediaImportProvider(projectId));
|
||||
final nativeDrop = ref.watch(platformCapabilitiesProvider).nativeFileDrop;
|
||||
return ListenableBuilder(
|
||||
return ListenableSelector(
|
||||
listenable: browser,
|
||||
select: () =>
|
||||
(browser.filter, browser.grid, browser.busy, browser.canImport),
|
||||
builder: (context, _) {
|
||||
final grid = widget.grid ?? browser.grid;
|
||||
final visible =
|
||||
@@ -61,121 +121,26 @@ class _MediaPanelState extends ConsumerState<MediaPanel> {
|
||||
feedback: browser.feedback,
|
||||
child: Material(
|
||||
key: const Key('media-panel-surface'),
|
||||
color: widget.backgroundColor,
|
||||
color: widget.backgroundColor ?? Colors.transparent,
|
||||
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;
|
||||
},
|
||||
),
|
||||
),
|
||||
MediaBrowserToolbar(
|
||||
projects: workspace.$1,
|
||||
selectedProjectId: projectId,
|
||||
onProjectSelected: onSelectProject,
|
||||
canImport: enabled,
|
||||
onImport: () => pickMediaFiles(browser),
|
||||
filter: browser.filter,
|
||||
onFilterChanged: (value) => browser.filter = value,
|
||||
grid: grid,
|
||||
onToggleGrid: toggleGrid,
|
||||
),
|
||||
Expanded(
|
||||
key: const Key('media-panel-body'),
|
||||
child: MediaBrowserBody(
|
||||
projectId: widget.projectId,
|
||||
grid: grid,
|
||||
draggable: true,
|
||||
),
|
||||
child: _browserBody(projectId, grid),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user