Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: files media improvements (#6632)

Mathias Mogensenbae19b9c3af0
diff --git a/frontend/appflowy_flutter/integration_test/desktop/database/database_media_test.dart b/frontend/appflowy_flutter/integration_test/desktop/database/database_media_test.dart
index 2703c3ebc6..cb24a949bb 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/database/database_media_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/database/database_media_test.dart
@@ -68,10 +68,7 @@ void main() {
await tester.pumpAndSettle();
// Tap on the upload interaction
- await tester.tapButtonWithName(
- LocaleKeys.document_plugins_file_fileUploadHint.tr(),
- );
- await tester.pumpAndSettle();
+ await tester.tapFileUploadHint();
// Expect one file
expect(find.byType(RenderMedia), findsOneWidget);
@@ -84,9 +81,7 @@ void main() {
await tester.pumpAndSettle();
// Tap on the upload interaction
- await tester.tapButtonWithName(
- LocaleKeys.document_plugins_file_fileUploadHint.tr(),
- );
+ await tester.tapFileUploadHint();
await tester.pumpAndSettle();
// Expect two files
@@ -138,10 +133,7 @@ void main() {
await tester.pumpAndSettle();
// Tap on the upload interaction
- await tester.tapButtonWithName(
- LocaleKeys.document_plugins_file_fileUploadHint.tr(),
- );
- await tester.pumpAndSettle();
+ await tester.tapFileUploadHint();
// Expect two files
expect(find.byType(RenderMedia), findsNWidgets(2));
@@ -192,10 +184,7 @@ void main() {
await tester.pumpAndSettle();
// Tap on the upload interaction
- await tester.tapButtonWithName(
- LocaleKeys.document_plugins_file_fileUploadHint.tr(),
- );
- await tester.pumpAndSettle();
+ await tester.tapFileUploadHint();
// Expect two files
expect(find.byType(RenderMedia), findsNWidgets(2));
@@ -229,7 +218,7 @@ void main() {
await Future.wait([firstFile.delete(), secondFile.delete()]);
});
- testWidgets('hide file names', (tester) async {
+ testWidgets('show file names', (tester) async {
await tester.initializeAppFlowy();
await tester.tapAnonymousSignInButton();
@@ -271,10 +260,7 @@ void main() {
await tester.pumpAndSettle();
// Tap on the upload interaction
- await tester.tapButtonWithName(
- LocaleKeys.document_plugins_file_fileUploadHint.tr(),
- );
- await tester.pumpAndSettle();
+ await tester.tapFileUploadHint();
// Expect two files
expect(find.byType(RenderMedia), findsNWidgets(2));
@@ -282,28 +268,28 @@ void main() {
await tester.dismissCellEditor();
await tester.pumpAndSettle();
- // Open first row in row detail view then toggle hide file names
+ // Open first row in row detail view then toggle show file names
await tester.openFirstRowDetailPage();
await tester.pumpAndSettle();
- // Expect file names to be shown
- expect(find.text('sample.jpeg'), findsOneWidget);
- expect(find.text('sample.gif'), findsOneWidget);
+ // Expect file names to not be shown (hidden)
+ expect(find.text('sample.jpeg'), findsNothing);
+ expect(find.text('sample.gif'), findsNothing);
await tester.tapGridFieldWithNameInRowDetailPage('Type');
await tester.pumpAndSettle();
- // Toggle hide file names
+ // Toggle show file names
await tester.tap(find.byType(Toggle));
await tester.pumpAndSettle();
+ // Expect file names to be shown
+ expect(find.text('sample.jpeg'), findsOneWidget);
+ expect(find.text('sample.gif'), findsOneWidget);
+
await tester.dismissRowDetailPage();
await tester.pumpAndSettle();
- // Expect file names to be hidden
- expect(find.text('sample.jpeg'), findsNothing);
- expect(find.text('sample.gif'), findsNothing);
-
// Remove the temp files
await Future.wait([firstFile.delete(), secondFile.delete()]);
});
diff --git a/frontend/appflowy_flutter/integration_test/desktop/database/database_row_cover_test.dart b/frontend/appflowy_flutter/integration_test/desktop/database/database_row_cover_test.dart
index 979cd0f98f..6c96a4825e 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/database/database_row_cover_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/database/database_row_cover_test.dart
@@ -62,9 +62,7 @@ void main() {
await tester.pumpAndSettle();
// Tap on the upload interaction
- await tester.tapButtonWithName(
- LocaleKeys.document_plugins_file_fileUploadHint.tr(),
- );
+ await tester.tapFileUploadHint();
// Expect one file
expect(find.byType(RenderMedia), findsOneWidget);
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_with_file_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_with_file_test.dart
index 7508ad4a8b..9d7a97e6a8 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_with_file_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_with_file_test.dart
@@ -47,9 +47,7 @@ void main() {
mockPickFilePaths(paths: [filePath]);
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, '0');
- await tester.tap(
- find.text(LocaleKeys.document_plugins_file_fileUploadHint.tr()),
- );
+ await tester.tapFileUploadHint();
await tester.pumpAndSettle();
expect(find.byType(FileUploadMenu), findsNothing);
diff --git a/frontend/appflowy_flutter/integration_test/shared/common_operations.dart b/frontend/appflowy_flutter/integration_test/shared/common_operations.dart
index 522259c99a..4649413717 100644
--- a/frontend/appflowy_flutter/integration_test/shared/common_operations.dart
+++ b/frontend/appflowy_flutter/integration_test/shared/common_operations.dart
@@ -775,6 +775,18 @@ extension CommonOperations on WidgetTester {
await tap(button);
await pump();
}
+
+ Future<void> tapFileUploadHint() async {
+ final finder = find.byWidgetPredicate(
+ (w) =>
+ w is RichText &&
+ w.text.toPlainText().contains(
+ LocaleKeys.document_plugins_file_fileUploadHint.tr(),
+ ),
+ );
+ await tap(finder);
+ await pumpAndSettle(const Duration(seconds: 2));
+ }
}
extension SettingsFinder on CommonFinders {
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_media_upload.dart b/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_media_upload.dart
new file mode 100644
index 0000000000..11292e3194
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_media_upload.dart
@@ -0,0 +1,96 @@
+import 'package:appflowy/plugins/database/application/cell/bloc/media_cell_bloc.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/file/file_util.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/file/mobile_file_upload_menu.dart';
+import 'package:appflowy/util/xfile_ext.dart';
+import 'package:appflowy_backend/protobuf/flowy-database2/file_entities.pbenum.dart';
+import 'package:appflowy_backend/protobuf/flowy-database2/media_entities.pbenum.dart';
+import 'package:cross_file/cross_file.dart';
+import 'package:flutter/widgets.dart';
+import 'package:go_router/go_router.dart';
+import 'package:provider/provider.dart';
+
+class MobileMediaUploadSheetContent extends StatelessWidget {
+ const MobileMediaUploadSheetContent({super.key, required this.dialogContext});
+
+ final BuildContext dialogContext;
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ margin: const EdgeInsets.only(top: 12),
+ constraints: const BoxConstraints(
+ maxHeight: 340,
+ minHeight: 80,
+ ),
+ child: MobileFileUploadMenu(
+ onInsertLocalFile: (files) async {
+ dialogContext.pop();
+
+ await insertLocalFiles(
+ context,
+ files,
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ documentId: context.read<MediaCellBloc>().rowId,
+ onUploadSuccess: (file, path, isLocalMode) {
+ final mediaCellBloc = context.read<MediaCellBloc>();
+ if (mediaCellBloc.isClosed) {
+ return;
+ }
+
+ mediaCellBloc.add(
+ MediaCellEvent.addFile(
+ url: path,
+ name: file.name,
+ uploadType: isLocalMode
+ ? FileUploadTypePB.LocalFile
+ : FileUploadTypePB.CloudFile,
+ fileType: file.fileType.toMediaFileTypePB(),
+ ),
+ );
+ },
+ );
+ },
+ onInsertNetworkFile: (url) async => _onInsertNetworkFile(
+ url,
+ dialogContext,
+ context,
+ ),
+ ),
+ );
+ }
+
+ Future<void> _onInsertNetworkFile(
+ String url,
+ BuildContext dialogContext,
+ BuildContext context,
+ ) async {
+ dialogContext.pop();
+
+ if (url.isEmpty) return;
+ final uri = Uri.tryParse(url);
+ if (uri == null) {
+ return;
+ }
+
+ final fakeFile = XFile(uri.path);
+ MediaFileTypePB fileType = fakeFile.fileType.toMediaFileTypePB();
+ fileType =
+ fileType == MediaFileTypePB.Other ? MediaFileTypePB.Link : fileType;
+
+ String name = uri.pathSegments.isNotEmpty ? uri.pathSegments.last : "";
+ if (name.isEmpty && uri.pathSegments.length > 1) {
+ name = uri.pathSegments[uri.pathSegments.length - 2];
+ } else if (name.isEmpty) {
+ name = uri.host;
+ }
+
+ context.read<MediaCellBloc>().add(
+ MediaCellEvent.addFile(
+ url: url,
+ name: name,
+ uploadType: FileUploadTypePB.NetworkFile,
+ fileType: fileType,
+ ),
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/option_text_field.dart b/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/option_text_field.dart
index 20ea4bc5f4..e2614296af 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/option_text_field.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/option_text_field.dart
@@ -11,6 +11,7 @@ class OptionTextField extends StatelessWidget {
const OptionTextField({
super.key,
required this.controller,
+ this.autoFocus = false,
required this.isPrimary,
required this.fieldType,
required this.onTextChanged,
@@ -18,6 +19,7 @@ class OptionTextField extends StatelessWidget {
});
final TextEditingController controller;
+ final bool autoFocus;
final bool isPrimary;
final FieldType fieldType;
final void Function(String value) onTextChanged;
@@ -27,6 +29,7 @@ class OptionTextField extends StatelessWidget {
Widget build(BuildContext context) {
return FlowyOptionTile.textField(
controller: controller,
+ autofocus: autoFocus,
textFieldPadding: const EdgeInsets.symmetric(horizontal: 12.0),
onTextChanged: onTextChanged,
leftIcon: GestureDetector(
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_field_bottom_sheets.dart b/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_field_bottom_sheets.dart
index 74c7a5a56b..11a6b239e9 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_field_bottom_sheets.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_field_bottom_sheets.dart
@@ -21,15 +21,15 @@ import 'mobile_quick_field_editor.dart';
const mobileSupportedFieldTypes = [
FieldType.RichText,
FieldType.Number,
- FieldType.URL,
FieldType.SingleSelect,
FieldType.MultiSelect,
FieldType.DateTime,
- FieldType.LastEditedTime,
- FieldType.CreatedTime,
+ FieldType.Media,
+ FieldType.URL,
FieldType.Checkbox,
FieldType.Checklist,
- FieldType.Media,
+ FieldType.LastEditedTime,
+ FieldType.CreatedTime,
// FieldType.Time,
];
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart b/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart
index 02c8c12b80..a01356d8db 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart
@@ -224,6 +224,7 @@ class _MobileFieldEditorState extends State<MobileFieldEditor> {
const _Divider(),
OptionTextField(
controller: controller,
+ autoFocus: widget.mode == FieldOptionMode.add,
fieldType: values.type,
isPrimary: widget.isPrimary,
onTextChanged: (value) {
diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/media_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/media_cell_bloc.dart
index 9874646e32..7a3075e0f2 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/media_cell_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/media_cell_bloc.dart
@@ -3,12 +3,14 @@ import 'dart:async';
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart';
import 'package:appflowy/plugins/database/application/field/field_info.dart';
import 'package:appflowy/plugins/database/application/field/type_option/type_option_data_parser.dart';
+import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy/user/application/user_service.dart';
import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/cell_entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/file_entities.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/media_entities.pb.dart';
+import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
import 'package:flowy_infra/uuid.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -24,7 +26,10 @@ class MediaCellBloc extends Bloc<MediaCellEvent, MediaCellState> {
_startListening();
}
+ late final RowBackendService _rowService =
+ RowBackendService(viewId: cellController.viewId);
final MediaCellController cellController;
+
void Function()? _onCellChangedFn;
String get databaseId => cellController.viewId;
@@ -110,10 +115,6 @@ class MediaCellBloc extends Bloc<MediaCellEvent, MediaCellState> {
},
reorderFiles: (from, to) async {
final files = List<MediaFilePB>.from(state.files);
- if (from < to) {
- to--;
- }
-
files.insert(to, files.removeAt(from));
// We emit the new state first to update the UI
@@ -153,6 +154,10 @@ class MediaCellBloc extends Bloc<MediaCellEvent, MediaCellState> {
toggleShowAllFiles: () {
emit(state.copyWith(showAllFiles: !state.showAllFiles));
},
+ setCover: (cover) => _rowService.updateMeta(
+ rowId: cellController.rowId,
+ cover: cover,
+ ),
);
},
);
@@ -214,6 +219,8 @@ class MediaCellEvent with _$MediaCellEvent {
}) = _RenameFile;
const factory MediaCellEvent.toggleShowAllFiles() = _ToggleShowAllFiles;
+
+ const factory MediaCellEvent.setCover(RowCoverPB cover) = _SetCover;
}
@freezed
@@ -223,7 +230,7 @@ class MediaCellState with _$MediaCellState {
required String fieldName,
@Default([]) List<MediaFilePB> files,
@Default(false) showAllFiles,
- @Default(false) hideFileNames,
+ @Default(true) hideFileNames,
}) = _MediaCellState;
factory MediaCellState.initial(MediaCellController cellController) {
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_media_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_media_cell.dart
index 2b6dd08d26..bcf136bcf1 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_media_cell.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_media_cell.dart
@@ -1,3 +1,8 @@
+import 'package:appflowy/core/helpers/url_launcher.dart';
+import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_media_upload.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/image/common.dart';
+import 'package:appflowy/workspace/presentation/widgets/image_viewer/image_provider.dart';
+import 'package:appflowy/workspace/presentation/widgets/image_viewer/interactive_image_viewer.dart';
import 'package:flutter/material.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
@@ -36,16 +41,22 @@ class GridMediaCellSkin extends IEditableMediaCellSkin {
Widget child = BlocBuilder<MediaCellBloc, MediaCellState>(
builder: (context, state) {
- final filesToDisplay = state.files.take(4).toList();
- final extraCount = state.files.length - filesToDisplay.length;
-
final wrapContent = context.read<MediaCellBloc>().wrapContent;
- final children = <Widget>[
- ...filesToDisplay.map((file) => _FilePreviewRender(file: file)),
- if (extraCount > 0) _ExtraInfo(extraCount: extraCount),
- ];
+ final List<Widget> children = state.files
+ .map<Widget>(
+ (file) => GestureDetector(
+ onTap: () => _openOrExpandFile(context, file, state.files),
+ child: Padding(
+ padding: wrapContent
+ ? const EdgeInsets.only(right: 4)
+ : EdgeInsets.zero,
+ child: _FilePreviewRender(file: file),
+ ),
+ ),
+ )
+ .toList();
- if (isMobileRowDetail && filesToDisplay.isEmpty) {
+ if (isMobileRowDetail && state.files.isEmpty) {
children.add(
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
@@ -80,8 +91,8 @@ class GridMediaCellSkin extends IEditableMediaCellSkin {
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SeparatedRow(
- separatorBuilder: () => const HSpace(6),
- children: children,
+ separatorBuilder: () => const HSpace(4),
+ children: children..add(const SizedBox(width: 16)),
),
),
),
@@ -130,15 +141,7 @@ class GridMediaCellSkin extends IEditableMediaCellSkin {
child = InkWell(
borderRadius:
isMobileRowDetail ? BorderRadius.circular(12) : BorderRadius.zero,
- onTap: () {
- showMobileBottomSheet(
- context,
- builder: (_) => BlocProvider.value(
- value: context.read<MediaCellBloc>(),
- child: const MobileMediaCellEditor(),
- ),
- );
- },
+ onTap: () => _tapCellMobile(context),
hoverColor: Colors.transparent,
child: child,
);
@@ -149,69 +152,113 @@ class GridMediaCellSkin extends IEditableMediaCellSkin {
child: Builder(builder: (context) => child),
);
}
-}
-class _FilePreviewRender extends StatelessWidget {
- const _FilePreviewRender({required this.file});
+ void _openOrExpandFile(
+ BuildContext context,
+ MediaFilePB file,
+ List<MediaFilePB> files,
+ ) {
+ if (file.fileType != MediaFileTypePB.Image) {
+ afLaunchUrlString(file.url);
+ return;
+ }
- final MediaFilePB file;
+ final images =
+ files.where((f) => f.fileType == MediaFileTypePB.Image).toList();
+ final index = images.indexOf(file);
- @override
- Widget build(BuildContext context) {
- if (file.fileType != MediaFileTypePB.Image) {
- return Container(
- margin: const EdgeInsets.symmetric(horizontal: 2),
- height: 32,
- width: 32,
- clipBehavior: Clip.antiAlias,
- padding: const EdgeInsets.all(8),
- decoration: BoxDecoration(
- color: AFThemeExtension.of(context).greyHover,
- borderRadius: BorderRadius.circular(4),
+ showDialog(
+ context: context,
+ builder: (_) => InteractiveImageViewer(
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ imageProvider: AFBlockImageProvider(
+ initialIndex: index,
+ images: images
+ .map(
+ (e) => ImageBlockData(
+ url: e.url,
+ type: e.uploadType.toCustomImageType(),
+ ),
+ )
+ .toList(),
+ onDeleteImage: (index) {
+ final deleteFile = images[index];
+ context.read<MediaCellBloc>().deleteFile(deleteFile.id);
+ },
),
- child: FlowySvg(
- file.fileType.icon,
- color: AFThemeExtension.of(context).textColor,
+ ),
+ );
+ }
+
+ void _tapCellMobile(BuildContext context) {
+ final files = context.read<MediaCellBloc>().state.files;
+
+ if (files.isEmpty) {
+ showMobileBottomSheet(
+ context,
+ title: LocaleKeys.grid_media_addFileMobile.tr(),
+ showHeader: true,
+ showCloseButton: true,
+ showDragHandle: true,
+ builder: (dContext) => BlocProvider.value(
+ value: context.read<MediaCellBloc>(),
+ child: MobileMediaUploadSheetContent(
+ dialogContext: dContext,
+ ),
),
);
+ return;
}
- return Container(
- margin: const EdgeInsets.symmetric(horizontal: 2),
- height: 32,
- width: 32,
- clipBehavior: Clip.antiAlias,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- child: AFImage(
- url: file.url,
- uploadType: file.uploadType,
- userProfile: context.read<MediaCellBloc>().state.userProfile,
+ showMobileBottomSheet(
+ context,
+ builder: (_) => BlocProvider.value(
+ value: context.read<MediaCellBloc>(),
+ child: const MobileMediaCellEditor(),
),
);
}
}
-class _ExtraInfo extends StatelessWidget {
- const _ExtraInfo({required this.extraCount});
+class _FilePreviewRender extends StatelessWidget {
+ const _FilePreviewRender({required this.file});
- final int extraCount;
+ final MediaFilePB file;
@override
Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.all(2),
- child: Container(
- height: 32,
- padding: const EdgeInsets.all(8),
- decoration: BoxDecoration(
- color: AFThemeExtension.of(context).greyHover,
- borderRadius: BorderRadius.circular(4),
+ if (file.fileType != MediaFileTypePB.Image) {
+ return FlowyTooltip(
+ message: file.name,
+ child: Container(
+ height: 28,
+ width: 28,
+ clipBehavior: Clip.antiAlias,
+ padding: const EdgeInsets.all(8),
+ decoration: BoxDecoration(
+ color: AFThemeExtension.of(context).greyHover,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ child: FlowySvg(
+ file.fileType.icon,
+ size: const Size.square(12),
+ color: AFThemeExtension.of(context).textColor,
+ ),
),
- child: FlowyText.regular(
- LocaleKeys.grid_media_moreFilesHint.tr(args: ['$extraCount']),
- lineHeight: 1,
+ );
+ }
+
+ return FlowyTooltip(
+ message: file.name,
+ child: Container(
+ height: 28,
+ width: 28,
+ clipBehavior: Clip.antiAlias,
+ decoration: BoxDecoration(borderRadius: BorderRadius.circular(4)),
+ child: AFImage(
+ url: file.url,
+ uploadType: file.uploadType,
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
),
),
);
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_media_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_media_cell.dart
index 7a27d0337a..53fc5d558a 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_media_cell.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_media_cell.dart
@@ -1,5 +1,4 @@
-import 'package:flutter/material.dart';
-
+import 'package:appflowy/core/helpers/url_launcher.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/cell/bloc/media_cell_bloc.dart';
@@ -8,13 +7,14 @@ import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/me
import 'package:appflowy/plugins/database/widgets/cell_editor/media_cell_editor.dart';
import 'package:appflowy/plugins/database/widgets/media_file_type_ext.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
+import 'package:appflowy/plugins/document/presentation/editor_drop_manager.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/file/file_block_menu.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/file/file_upload_menu.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/file/file_util.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/common.dart';
import 'package:appflowy/shared/af_image.dart';
-import 'package:appflowy/util/theme_extension.dart';
import 'package:appflowy/util/xfile_ext.dart';
+import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/shared_widget.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy/workspace/presentation/widgets/image_viewer/image_provider.dart';
import 'package:appflowy/workspace/presentation/widgets/image_viewer/interactive_image_viewer.dart';
@@ -23,12 +23,14 @@ import 'package:collection/collection.dart';
import 'package:cross_file/cross_file.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/size.dart';
-import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
+import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:reorderables/reorderables.dart';
-const _defaultFilesToDisplay = 5;
+const _dropFileKey = 'files_media';
+const _itemWidth = 86.4;
class DekstopRowDetailMediaCellSkin extends IEditableMediaCellSkin {
final mutex = PopoverMutex();
@@ -47,102 +49,123 @@ class DekstopRowDetailMediaCellSkin extends IEditableMediaCellSkin {
) {
return BlocProvider.value(
value: bloc,
- child: Builder(
- builder: (context) => BlocBuilder<MediaCellBloc, MediaCellState>(
- builder: (context, state) {
- final filesToDisplay = state.showAllFiles
- ? state.files
- : state.files.take(_defaultFilesToDisplay).toList();
- final extraCount = state.files.length - _defaultFilesToDisplay;
+ child: BlocBuilder<MediaCellBloc, MediaCellState>(
+ builder: (context, state) => LayoutBuilder(
+ builder: (context, constraints) {
+ if (state.files.isEmpty) {
+ return _AddFileButton(
+ controller: popoverController,
+ direction: PopoverDirection.bottomWithLeftAligned,
+ mutex: mutex,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 6,
+ ),
+ child: FlowyText(
+ LocaleKeys.grid_row_textPlaceholder.tr(),
+ color: Theme.of(context).hintColor,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ );
+ }
+
+ int itemsToShow = state.showAllFiles ? state.files.length : 0;
+ if (!state.showAllFiles) {
+ // The row width is surrounded by 8px padding on each side
+ final rowWidth = constraints.maxWidth - 16;
+
+ // Each item needs 94.4 px to render, 86.4px width + 8px runSpacing
+ final itemsPerRow = rowWidth ~/ (_itemWidth + 8);
+
+ // We show at most 2 rows
+ itemsToShow = itemsPerRow * 2;
+ }
+
+ final filesToDisplay =
+ state.showAllFiles || itemsToShow >= state.files.length
+ ? state.files
+ : state.files.take(itemsToShow - 1).toList();
+ final extraCount = state.files.length - itemsToShow;
final images = state.files
.where((f) => f.fileType == MediaFileTypePB.Image)
.toList();
- return SizedBox(
- width: double.infinity,
- child: LayoutBuilder(
- builder: (context, constraints) {
- if (state.files.isEmpty) {
- return _AddFileButton(
- controller: popoverController,
- direction: PopoverDirection.bottomWithLeftAligned,
- mutex: mutex,
- child: FlowyHover(
- style: HoverStyle(
- hoverColor:
- AFThemeExtension.of(context).lightGreyHover,
- ),
- child: GestureDetector(
- onTap: popoverController.show,
- behavior: HitTestBehavior.translucent,
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 8,
- vertical: 6,
- ),
- child: FlowyText(
- LocaleKeys.grid_row_textPlaceholder.tr(),
- color: Theme.of(context).hintColor,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ),
- ),
- );
- }
-
- final size = constraints.maxWidth / 2 - 6;
- return Wrap(
- runSpacing: 12,
- spacing: 12,
- children: [
- ...filesToDisplay.mapIndexed(
- (index, file) => _FilePreviewRender(
- key: ValueKey(file.id),
- file: state.files[index],
- index: index,
- images: images,
- size: size,
- mutex: mutex,
- hideFileNames: state.hideFileNames,
- ),
- ),
- SizedBox(
- width: size,
- height: size / 2,
- child: _AddFileButton(
- controller: popoverController,
- mutex: mutex,
- child: FlowyHover(
- resetHoverOnRebuild: false,
- child: GestureDetector(
- onTap: popoverController.show,
- behavior: HitTestBehavior.translucent,
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const FlowySvg(
- FlowySvgs.add_s,
- size: Size.square(24),
- ),
- const VSpace(4),
- FlowyText(
- LocaleKeys.grid_media_addFileOrImage.tr(),
- ),
- ],
- ),
+ final size = constraints.maxWidth / 2 - 6;
+ return _AddFileButton(
+ controller: popoverController,
+ mutex: mutex,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: ReorderableWrap(
+ needsLongPressDraggable: false,
+ runSpacing: 8,
+ spacing: 8,
+ onReorder: (from, to) => context
+ .read<MediaCellBloc>()
+ .add(MediaCellEvent.reorderFiles(from: from, to: to)),
+ footer: extraCount > 0 && !state.showAllFiles
+ ? GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _toggleShowAllFiles(context),
+ child: _FilePreviewRender(
+ key: ValueKey(state.files[itemsToShow - 1].id),
+ file: state.files[itemsToShow - 1],
+ index: 9,
+ images: images,
+ size: size,
+ mutex: mutex,
+ hideFileNames: state.hideFileNames,
+ foregroundText: LocaleKeys.grid_media_extraCount
+ .tr(args: [extraCount.toString()]),
),
+ )
+ : null,
+ buildDraggableFeedback: (_, __, child) =>
+ BlocProvider.value(
+ value: context.read<MediaCellBloc>(),
+ child: _FilePreviewFeedback(child: child),
+ ),
+ children: filesToDisplay
+ .mapIndexed(
+ (index, file) => _FilePreviewRender(
+ key: ValueKey(file.id),
+ file: file,
+ index: index,
+ images: images,
+ size: size,
+ mutex: mutex,
+ hideFileNames: state.hideFileNames,
),
- ),
+ )
+ .toList(),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(4),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const FlowySvg(
+ FlowySvgs.add_thin_s,
+ size: Size.square(12),
),
- ),
- if (extraCount > 0)
- _ShowAllFilesButton(extraCount: extraCount),
- ],
- );
- },
+ const HSpace(6),
+ FlowyText.medium(
+ LocaleKeys.grid_media_addFileOrImage.tr(),
+ fontSize: 12,
+ color: Theme.of(context).hintColor,
+ figmaLineHeight: 18,
+ ),
+ ],
+ ),
+ ),
+ ],
),
);
},
@@ -150,6 +173,50 @@ class DekstopRowDetailMediaCellSkin extends IEditableMediaCellSkin {
),
);
}
+
+ void _toggleShowAllFiles(BuildContext context) {
+ context
+ .read<MediaCellBloc>()
+ .add(const MediaCellEvent.toggleShowAllFiles());
+ }
+}
+
+class _FilePreviewFeedback extends StatelessWidget {
+ const _FilePreviewFeedback({required this.child});
+
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ return DecoratedBox(
+ position: DecorationPosition.foreground,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(6),
+ border: Border.all(
+ width: 2,
+ color: const Color(0xFF00BCF0),
+ ),
+ ),
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ boxShadow: [
+ BoxShadow(
+ color: const Color(0xFF1F2329).withOpacity(.2),
+ blurRadius: 6,
+ offset: const Offset(0, 3),
+ ),
+ ],
+ ),
+ child: BlocProvider.value(
+ value: context.read<MediaCellBloc>(),
+ child: Material(
+ type: MaterialType.transparency,
+ child: child,
+ ),
+ ),
+ ),
+ );
+ }
}
class _AddFileButton extends StatelessWidget {
@@ -174,67 +241,80 @@ class _AddFileButton extends StatelessWidget {
offset: const Offset(0, 10),
direction: direction,
constraints: const BoxConstraints(maxWidth: 350),
- popupBuilder: (_) => FileUploadMenu(
- allowMultipleFiles: true,
- onInsertLocalFile: (files) => insertLocalFiles(
- context,
- files,
- userProfile: context.read<MediaCellBloc>().state.userProfile,
- documentId: context.read<MediaCellBloc>().rowId,
- onUploadSuccess: (file, path, isLocalMode) {
- final mediaCellBloc = context.read<MediaCellBloc>();
- if (mediaCellBloc.isClosed) {
+ margin: EdgeInsets.zero,
+ onClose: () =>
+ context.read<EditorDropManagerState>().remove(_dropFileKey),
+ popupBuilder: (_) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ context.read<EditorDropManagerState>().add(_dropFileKey);
+ });
+
+ return FileUploadMenu(
+ allowMultipleFiles: true,
+ onInsertLocalFile: (files) => insertLocalFiles(
+ context,
+ files,
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ documentId: context.read<MediaCellBloc>().rowId,
+ onUploadSuccess: (file, path, isLocalMode) {
+ final mediaCellBloc = context.read<MediaCellBloc>();
+ if (mediaCellBloc.isClosed) {
+ return;
+ }
+
+ mediaCellBloc.add(
+ MediaCellEvent.addFile(
+ url: path,
+ name: file.name,
+ uploadType: isLocalMode
+ ? FileUploadTypePB.LocalFile
+ : FileUploadTypePB.CloudFile,
+ fileType: file.fileType.toMediaFileTypePB(),
+ ),
+ );
+
+ controller.close();
+ },
+ ),
+ onInsertNetworkFile: (url) {
+ if (url.isEmpty) return;
+ final uri = Uri.tryParse(url);
+ if (uri == null) {
return;
}
- mediaCellBloc.add(
- MediaCellEvent.addFile(
- url: path,
- name: file.name,
- uploadType: isLocalMode
- ? FileUploadTypePB.LocalFile
- : FileUploadTypePB.CloudFile,
- fileType: file.fileType.toMediaFileTypePB(),
- ),
- );
+ final fakeFile = XFile(uri.path);
+ MediaFileTypePB fileType = fakeFile.fileType.toMediaFileTypePB();
+ fileType = fileType == MediaFileTypePB.Other
+ ? MediaFileTypePB.Link
+ : fileType;
+
+ String name =
+ uri.pathSegments.isNotEmpty ? uri.pathSegments.last : "";
+ if (name.isEmpty && uri.pathSegments.length > 1) {
+ name = uri.pathSegments[uri.pathSegments.length - 2];
+ } else if (name.isEmpty) {
+ name = uri.host;
+ }
+
+ context.read<MediaCellBloc>().add(
+ MediaCellEvent.addFile(
+ url: url,
+ name: name,
+ uploadType: FileUploadTypePB.NetworkFile,
+ fileType: fileType,
+ ),
+ );
controller.close();
},
- ),
- onInsertNetworkFile: (url) {
- if (url.isEmpty) return;
- final uri = Uri.tryParse(url);
- if (uri == null) {
- return;
- }
-
- final fakeFile = XFile(uri.path);
- MediaFileTypePB fileType = fakeFile.fileType.toMediaFileTypePB();
- fileType = fileType == MediaFileTypePB.Other
- ? MediaFileTypePB.Link
- : fileType;
-
- String name =
- uri.pathSegments.isNotEmpty ? uri.pathSegments.last : "";
- if (name.isEmpty && uri.pathSegments.length > 1) {
- name = uri.pathSegments[uri.pathSegments.length - 2];
- } else if (name.isEmpty) {
- name = uri.host;
- }
-
- context.read<MediaCellBloc>().add(
- MediaCellEvent.addFile(
- url: url,
- name: name,
- uploadType: FileUploadTypePB.NetworkFile,
- fileType: fileType,
- ),
- );
-
- controller.close();
- },
+ );
+ },
+ child: GestureDetector(
+ onTap: controller.show,
+ behavior: HitTestBehavior.translucent,
+ child: FlowyHover(resetHoverOnRebuild: false, child: child),
),
- child: child,
);
}
}
@@ -248,6 +328,7 @@ class _FilePreviewRender extends StatefulWidget {
required this.size,
required this.mutex,
this.hideFileNames = false,
+ this.foregroundText,
});
final MediaFilePB file;
@@ -256,6 +337,7 @@ class _FilePreviewRender extends StatefulWidget {
final double size;
final PopoverMutex mutex;
final bool hideFileNames;
+ final String? foregroundText;
@override
State<_FilePreviewRender> createState() => _FilePreviewRenderState();
@@ -263,7 +345,6 @@ class _FilePreviewRender extends StatefulWidget {
class _FilePreviewRenderState extends State<_FilePreviewRender> {
final nameController = TextEditingController();
- final errorMessage = ValueNotifier<String?>(null);
final controller = PopoverController();
bool isHovering = false;
bool isSelected = false;
@@ -280,6 +361,7 @@ class _FilePreviewRenderState extends State<_FilePreviewRender> {
@override
void dispose() {
+ nameController.dispose();
controller.close();
super.dispose();
}
@@ -298,348 +380,341 @@ class _FilePreviewRenderState extends State<_FilePreviewRender> {
url: file.url,
uploadType: file.uploadType,
userProfile: context.read<MediaCellBloc>().state.userProfile,
+ width: _itemWidth,
+ borderRadius: BorderRadius.only(
+ topLeft: Corners.s5Radius,
+ topRight: Corners.s5Radius,
+ bottomLeft: widget.hideFileNames ? Corners.s5Radius : Radius.zero,
+ bottomRight: widget.hideFileNames ? Corners.s5Radius : Radius.zero,
+ ),
);
} else {
child = DecoratedBox(
decoration: BoxDecoration(color: file.fileType.color),
child: Center(
- child: Container(
+ child: Padding(
padding: const EdgeInsets.all(8),
child: FlowySvg(
file.fileType.icon,
- color: AFThemeExtension.of(context).strongText,
- size: const Size.square(32),
+ color: const Color(0xFF666D76),
),
),
),
);
}
- return AppFlowyPopover(
- controller: controller,
- constraints: const BoxConstraints(maxWidth: 165),
- offset: const Offset(0, 5),
- onClose: () => setState(() => isSelected = false),
- popupBuilder: (_) => SeparatedColumn(
- separatorBuilder: () => const VSpace(4),
- mainAxisSize: MainAxisSize.min,
+ if (widget.foregroundText != null) {
+ child = Stack(
children: [
- if (file.fileType == MediaFileTypePB.Image) ...[
- FlowyButton(
- onTap: () {
- controller.close();
- showDialog(
- context: context,
- builder: (_) => InteractiveImageViewer(
- userProfile:
- context.read<MediaCellBloc>().state.userProfile,
- imageProvider: AFBlockImageProvider(
- initialIndex: thisIndex,
- images: widget.images
- .map(
- (e) => ImageBlockData(
- url: e.url,
- type: e.uploadType.toCustomImageType(),
- ),
- )
- .toList(),
- onDeleteImage: (index) {
- final deleteFile = widget.images[index];
- context.read<MediaCellBloc>().deleteFile(deleteFile.id);
- },
- ),
- ),
- );
- },
- leftIcon: FlowySvg(
- FlowySvgs.full_view_s,
- color: Theme.of(context).iconTheme.color,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.settings_files_open.tr(),
- color: AFThemeExtension.of(context).textColor,
- ),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- ),
- FlowyButton(
- onTap: () {
- controller.close();
- context.read<RowDetailBloc>().add(
- RowDetailEvent.setCover(
- RowCoverPB(
- data: file.url,
- uploadType: file.uploadType,
- coverType: CoverTypePB.FileCover,
- ),
- ),
- );
- },
- leftIcon: FlowySvg(
- FlowySvgs.add_cover_s,
- color: Theme.of(context).iconTheme.color,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.grid_media_setAsCover.tr(),
- color: AFThemeExtension.of(context).textColor,
- ),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- ),
- ],
- FlowyButton(
- leftIcon: FlowySvg(
- FlowySvgs.edit_s,
- color: Theme.of(context).iconTheme.color,
+ Positioned.fill(
+ child: DecoratedBox(
+ position: DecorationPosition.foreground,
+ decoration: BoxDecoration(color: Colors.black.withOpacity(0.5)),
+ child: child,
),
- text: FlowyText.regular(
- LocaleKeys.grid_media_rename.tr(),
- color: AFThemeExtension.of(context).textColor,
- ),
- onTap: () {
- controller.close();
-
- nameController.text = file.name;
- nameController.selection = TextSelection(
- baseOffset: 0,
- extentOffset: nameController.text.length,
- );
-
- showCustomConfirmDialog(
- context: context,
- title: LocaleKeys.document_plugins_file_renameFile_title.tr(),
- description: LocaleKeys
- .document_plugins_file_renameFile_description
- .tr(),
- closeOnConfirm: false,
- builder: (dialogContext) => FileRenameTextField(
- nameController: nameController,
- errorMessage: errorMessage,
- onSubmitted: () => _saveName(context),
- disposeController: false,
- ),
- confirmLabel: LocaleKeys.button_save.tr(),
- onConfirm: () => _saveName(context),
- );
- },
),
- FlowyButton(
- onTap: () async => downloadMediaFile(
- context,
- file,
- userProfile: context.read<MediaCellBloc>().state.userProfile,
- ),
- leftIcon: FlowySvg(
- FlowySvgs.download_s,
- color: Theme.of(context).iconTheme.color,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.button_download.tr(),
- color: AFThemeExtension.of(context).textColor,
+ Positioned.fill(
+ child: Center(
+ child: FlowyText.semibold(
+ widget.foregroundText!,
+ color: Colors.white,
+ fontSize: 14,
+ ),
),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
),
- FlowyButton(
- onTap: () {
- controller.close();
- showConfirmDeletionDialog(
- context: context,
- name: file.name,
- description: LocaleKeys.grid_media_deleteFileDescription.tr(),
- onConfirm: () => context
- .read<MediaCellBloc>()
- .add(MediaCellEvent.removeFile(fileId: file.id)),
- );
- },
- leftIcon: FlowySvg(
- FlowySvgs.delete_s,
- color: Theme.of(context).colorScheme.error,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.button_delete.tr(),
- color: Theme.of(context).colorScheme.error,
+ ],
+ );
+ }
+
+ return MouseRegion(
+ onEnter: (_) => setState(() => isHovering = true),
+ onExit: (_) => setState(() => isHovering = false),
+ child: FlowyTooltip(
+ message: file.name,
+ child: AppFlowyPopover(
+ controller: controller,
+ constraints: const BoxConstraints(maxWidth: 240),
+ offset: const Offset(0, 5),
+ triggerActions: PopoverTriggerFlags.none,
+ onClose: () => setState(() => isSelected = false),
+ popupBuilder: (popoverContext) => MultiBlocProvider(
+ providers: [
+ BlocProvider.value(value: context.read<RowDetailBloc>()),
+ BlocProvider.value(value: context.read<MediaCellBloc>()),
+ ],
+ child: _FileMenu(
+ parentContext: context,
+ index: thisIndex,
+ file: file,
+ images: widget.images,
+ controller: controller,
+ nameController: nameController,
),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
),
- ],
- ),
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: file.fileType != MediaFileTypePB.Image
- ? null
- : () => openInteractiveViewerFromFiles(
- context,
- widget.images,
- userProfile: context.read<MediaCellBloc>().state.userProfile,
- initialIndex: thisIndex,
- onDeleteImage: (index) {
- final deleteFile = widget.images[index];
- context.read<MediaCellBloc>().deleteFile(deleteFile.id);
+ child: GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: widget.foregroundText != null
+ ? null
+ : () {
+ if (file.fileType != MediaFileTypePB.Image) {
+ afLaunchUrlString(widget.file.url);
+ return;
+ }
+
+ openInteractiveViewerFromFiles(
+ context,
+ widget.images,
+ userProfile:
+ context.read<MediaCellBloc>().state.userProfile,
+ initialIndex: thisIndex,
+ onDeleteImage: (index) {
+ final deleteFile = widget.images[index];
+ context.read<MediaCellBloc>().deleteFile(deleteFile.id);
+ },
+ );
},
- ),
- child: FlowyHover(
- isSelected: () => isSelected,
- resetHoverOnRebuild: false,
- onHover: (hovering) => setState(() => isHovering = hovering),
- child: Stack(
- children: [
- DecoratedBox(
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Corners.s6Radius),
- boxShadow: [
- BoxShadow(
- color: Colors.black.withOpacity(0.15),
- blurRadius: 2,
- ),
- ],
- ),
- child: Column(
- children: [
- Container(
- height: widget.size,
- width: widget.size,
- constraints: BoxConstraints(
- maxHeight: widget.size < 150 ? 100 : 195,
- minHeight: widget.size < 150 ? 100 : 195,
- ),
- clipBehavior: Clip.antiAlias,
- decoration: BoxDecoration(
- color: AFThemeExtension.of(context).greyHover,
- borderRadius: BorderRadius.only(
- topLeft: Corners.s6Radius,
- topRight: Corners.s6Radius,
- bottomLeft: widget.hideFileNames
- ? Corners.s6Radius
- : Radius.zero,
- bottomRight: widget.hideFileNames
- ? Corners.s6Radius
- : Radius.zero,
- ),
- ),
- child: child,
- ),
- if (!widget.hideFileNames)
- Container(
- height: 28,
- width: widget.size,
- clipBehavior: Clip.antiAlias,
- decoration: BoxDecoration(
- color: Theme.of(context).isLightMode
- ? Theme.of(context).cardColor
- : AFThemeExtension.of(context).greyHover,
- borderRadius: const BorderRadius.only(
- bottomLeft: Corners.s6Radius,
- bottomRight: Corners.s6Radius,
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Center(
- child: FlowyText(
- file.name,
- overflow: TextOverflow.ellipsis,
- fontSize: 12,
- color: AFThemeExtension.of(context)
- .secondaryTextColor,
+ child: Container(
+ width: _itemWidth,
+ clipBehavior: Clip.antiAlias,
+ decoration: BoxDecoration(
+ borderRadius: const BorderRadius.all(Corners.s6Radius),
+ border: Border.all(color: Theme.of(context).dividerColor),
+ color: Theme.of(context).cardColor,
+ ),
+ child: Stack(
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(height: 68, child: child),
+ if (!widget.hideFileNames)
+ Row(
+ children: [
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.all(4),
+ child: FlowyText(
+ file.name,
+ fontSize: 10,
+ overflow: TextOverflow.ellipsis,
+ figmaLineHeight: 16,
+ ),
+ ),
),
- ),
+ ],
),
- ),
- ],
- ),
- ),
- if (isHovering || isSelected)
- Positioned(
- top: 5,
- right: 5,
- child: DecoratedBox(
- decoration: BoxDecoration(
- color: Theme.of(context).cardColor,
- borderRadius: const BorderRadius.all(Corners.s8Radius),
- ),
- child: Padding(
- padding: const EdgeInsets.all(3),
+ ],
+ ),
+ if (widget.foregroundText == null &&
+ (isHovering || isSelected))
+ Positioned(
+ top: 3,
+ right: 3,
child: FlowyIconButton(
onPressed: () {
setState(() => isSelected = true);
controller.show();
},
- width: 20,
- radius: BorderRadius.circular(0),
- icon: FlowySvg(
+ fillColor: Colors.black.withOpacity(0.4),
+ width: 18,
+ radius: BorderRadius.circular(4),
+ icon: const FlowySvg(
FlowySvgs.three_dots_s,
- color: AFThemeExtension.of(context).textColor,
+ color: Colors.white,
+ size: Size.square(16),
),
),
),
- ),
- ),
- ],
+ ],
+ ),
+ ),
),
),
),
);
}
+}
+
+class _FileMenu extends StatefulWidget {
+ const _FileMenu({
+ required this.parentContext,
+ required this.index,
+ required this.file,
+ required this.images,
+ required this.controller,
+ required this.nameController,
+ });
+
+ /// Parent [BuildContext] used to retrieve the [MediaCellBloc]
+ final BuildContext parentContext;
+
+ /// Index of this file in [widget.images]
+ final int index;
+
+ /// The current [MediaFilePB] being previewed
+ final MediaFilePB file;
+
+ /// All images in the field, excluding non-image files-
+ final List<MediaFilePB> images;
+
+ /// The [PopoverController] to close the popover
+ final PopoverController controller;
+
+ /// The [TextEditingController] for renaming the file
+ final TextEditingController nameController;
+
+ @override
+ State<_FileMenu> createState() => _FileMenuState();
+}
+
+class _FileMenuState extends State<_FileMenu> {
+ final errorMessage = ValueNotifier<String?>(null);
+
+ @override
+ void dispose() {
+ errorMessage.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return SeparatedColumn(
+ separatorBuilder: () => const VSpace(8),
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (widget.file.fileType == MediaFileTypePB.Image) ...[
+ MediaMenuItem(
+ onTap: () {
+ widget.controller.close();
+ _showInteractiveViewer(context);
+ },
+ icon: FlowySvgs.full_view_s,
+ label: LocaleKeys.grid_media_expand.tr(),
+ ),
+ MediaMenuItem(
+ onTap: () {
+ widget.controller.close();
+ _setCover(context);
+ },
+ icon: FlowySvgs.cover_s,
+ label: LocaleKeys.grid_media_setAsCover.tr(),
+ ),
+ ],
+ MediaMenuItem(
+ onTap: () {
+ widget.controller.close();
+ afLaunchUrlString(widget.file.url);
+ },
+ icon: FlowySvgs.open_in_browser_s,
+ label: LocaleKeys.grid_media_openInBrowser.tr(),
+ ),
+ MediaMenuItem(
+ onTap: () {
+ widget.controller.close();
+ widget.nameController.text = widget.file.name;
+ widget.nameController.selection = TextSelection(
+ baseOffset: 0,
+ extentOffset: widget.nameController.text.length,
+ );
+
+ _showRenameConfirmDialog();
+ },
+ icon: FlowySvgs.rename_s,
+ label: LocaleKeys.grid_media_rename.tr(),
+ ),
+ if (widget.file.uploadType == FileUploadTypePB.CloudFile) ...[
+ MediaMenuItem(
+ onTap: () async => downloadMediaFile(
+ context,
+ widget.file,
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ ),
+ icon: FlowySvgs.save_as_s,
+ label: LocaleKeys.button_download.tr(),
+ ),
+ ],
+ MediaMenuItem(
+ onTap: () {
+ widget.controller.close();
+ showConfirmDeletionDialog(
+ context: context,
+ name: widget.file.name,
+ description: LocaleKeys.grid_media_deleteFileDescription.tr(),
+ onConfirm: () => widget.parentContext
+ .read<MediaCellBloc>()
+ .add(MediaCellEvent.removeFile(fileId: widget.file.id)),
+ );
+ },
+ icon: FlowySvgs.trash_s,
+ label: LocaleKeys.button_delete.tr(),
+ ),
+ ],
+ );
+ }
void _saveName(BuildContext context) {
- final newName = nameController.text.trim();
+ final newName = widget.nameController.text.trim();
if (newName.isEmpty) {
return;
}
context
.read<MediaCellBloc>()
- .add(MediaCellEvent.renameFile(fileId: file.id, name: newName));
+ .add(MediaCellEvent.renameFile(fileId: widget.file.id, name: newName));
Navigator.of(context).pop();
}
-}
-
-class _ShowAllFilesButton extends StatelessWidget {
- const _ShowAllFilesButton({required this.extraCount});
- final int extraCount;
+ void _showRenameConfirmDialog() {
+ showCustomConfirmDialog(
+ context: widget.parentContext,
+ title: LocaleKeys.document_plugins_file_renameFile_title.tr(),
+ description: LocaleKeys.document_plugins_file_renameFile_description.tr(),
+ closeOnConfirm: false,
+ builder: (builderContext) => FileRenameTextField(
+ nameController: widget.nameController,
+ errorMessage: errorMessage,
+ onSubmitted: () => _saveName(widget.parentContext),
+ disposeController: false,
+ ),
+ style: ConfirmPopupStyle.cancelAndOk,
+ confirmLabel: LocaleKeys.button_save.tr(),
+ onConfirm: () => _saveName(widget.parentContext),
+ onCancel: Navigator.of(widget.parentContext).pop,
+ );
+ }
- @override
- Widget build(BuildContext context) {
- final show = context.read<MediaCellBloc>().state.showAllFiles;
-
- final label = show
- ? extraCount == 1
- ? LocaleKeys.grid_media_hideFile.tr()
- : LocaleKeys.grid_media_hideFiles.tr(args: ['$extraCount'])
- : extraCount == 1
- ? LocaleKeys.grid_media_showFile.tr()
- : LocaleKeys.grid_media_showFiles.tr(args: ['$extraCount']);
-
- final quarterTurns = show ? 1 : 3;
-
- return SizedBox(
- height: 30,
- child: FlowyButton(
- text: FlowyText.medium(
- label,
- lineHeight: 1.0,
- color: Theme.of(context).hintColor,
+ void _setCover(BuildContext context) => context.read<RowDetailBloc>().add(
+ RowDetailEvent.setCover(
+ RowCoverPB(
+ data: widget.file.url,
+ uploadType: widget.file.uploadType,
+ coverType: CoverTypePB.FileCover,
+ ),
),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- leftIcon: RotatedBox(
- quarterTurns: quarterTurns,
- child: FlowySvg(
- FlowySvgs.arrow_left_s,
- color: Theme.of(context).hintColor,
+ );
+
+ void _showInteractiveViewer(BuildContext context) => showDialog(
+ context: context,
+ builder: (_) => InteractiveImageViewer(
+ userProfile:
+ widget.parentContext.read<MediaCellBloc>().state.userProfile,
+ imageProvider: AFBlockImageProvider(
+ initialIndex: widget.index,
+ images: widget.images
+ .map(
+ (e) => ImageBlockData(
+ url: e.url,
+ type: e.uploadType.toCustomImageType(),
+ ),
+ )
+ .toList(),
+ onDeleteImage: (index) {
+ final deleteFile = widget.images[index];
+ widget.parentContext
+ .read<MediaCellBloc>()
+ .deleteFile(deleteFile.id);
+ },
),
),
- margin: const EdgeInsets.symmetric(horizontal: 4, vertical: 6),
- onTap: () => context
- .read<MediaCellBloc>()
- .add(const MediaCellEvent.toggleShowAllFiles()),
- ),
- );
- }
+ );
}
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/media_cell_editor.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/media_cell_editor.dart
index 4c0bfb7e17..eba42c1f97 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/media_cell_editor.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/media_cell_editor.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart';
import 'package:flutter/material.dart';
import 'package:appflowy/core/helpers/url_launcher.dart';
@@ -49,144 +50,166 @@ class _MediaCellEditorState extends State<MediaCellEditor> {
.where((file) => file.fileType == MediaFileTypePB.Image)
.toList();
- return Padding(
- padding: const EdgeInsets.all(4),
- child: SingleChildScrollView(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- if (state.files.isNotEmpty) ...[
- ReorderableListView.builder(
- physics: const NeverScrollableScrollPhysics(),
- shrinkWrap: true,
- buildDefaultDragHandles: false,
- itemBuilder: (_, index) => BlocProvider.value(
- key: Key(state.files[index].id),
- value: context.read<MediaCellBloc>(),
- child: RenderMedia(
- file: state.files[index],
- images: images,
- index: index,
- enableReordering: state.files.length > 1,
- mutex: itemMutex,
- ),
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (state.files.isNotEmpty) ...[
+ Flexible(
+ child: ReorderableListView.builder(
+ padding: const EdgeInsets.all(6),
+ physics: const ClampingScrollPhysics(),
+ shrinkWrap: true,
+ buildDefaultDragHandles: false,
+ itemBuilder: (_, index) => BlocProvider.value(
+ key: Key(state.files[index].id),
+ value: context.read<MediaCellBloc>(),
+ child: RenderMedia(
+ file: state.files[index],
+ images: images,
+ index: index,
+ enableReordering: state.files.length > 1,
+ mutex: itemMutex,
),
- itemCount: state.files.length,
- onReorder: (from, to) => context
+ ),
+ itemCount: state.files.length,
+ onReorder: (from, to) {
+ if (from < to) {
+ to--;
+ }
+
+ context
.read<MediaCellBloc>()
- .add(MediaCellEvent.reorderFiles(from: from, to: to)),
- proxyDecorator: (child, index, animation) => Material(
- color: Colors.transparent,
- child: SizeTransition(
- sizeFactor: animation,
- child: child,
- ),
+ .add(MediaCellEvent.reorderFiles(from: from, to: to));
+ },
+ proxyDecorator: (child, index, animation) => Material(
+ color: Colors.transparent,
+ child: SizeTransition(
+ sizeFactor: animation,
+ child: child,
),
),
- const Divider(height: 8),
- ],
- AppFlowyPopover(
- controller: addFilePopoverController,
- direction: PopoverDirection.bottomWithCenterAligned,
- offset: const Offset(0, 10),
- constraints: const BoxConstraints(
- minWidth: 250,
- maxWidth: 250,
- ),
- triggerActions: PopoverTriggerFlags.none,
- popupBuilder: (popoverContext) => FileUploadMenu(
- allowMultipleFiles: true,
- onInsertLocalFile: (files) async => insertLocalFiles(
- context,
- files,
- userProfile:
- context.read<MediaCellBloc>().state.userProfile,
- documentId: context.read<MediaCellBloc>().rowId,
- onUploadSuccess: (file, path, isLocalMode) {
- final mediaCellBloc = context.read<MediaCellBloc>();
- if (mediaCellBloc.isClosed) {
- return;
- }
-
- mediaCellBloc.add(
- MediaCellEvent.addFile(
- url: path,
- name: file.name,
- uploadType: isLocalMode
- ? FileUploadTypePB.LocalFile
- : FileUploadTypePB.CloudFile,
- fileType: file.fileType.toMediaFileTypePB(),
- ),
- );
+ ),
+ ),
+ ],
+ _AddButton(addFilePopoverController: addFilePopoverController),
+ ],
+ );
+ },
+ );
+ }
+}
- addFilePopoverController.close();
- },
- ),
- onInsertNetworkFile: (url) {
- if (url.isEmpty) return;
-
- final uri = Uri.tryParse(url);
- if (uri == null) {
- return;
- }
-
- final fakeFile = XFile(uri.path);
- MediaFileTypePB fileType =
- fakeFile.fileType.toMediaFileTypePB();
- fileType = fileType == MediaFileTypePB.Other
- ? MediaFileTypePB.Link
- : fileType;
-
- String name = uri.pathSegments.isNotEmpty
- ? uri.pathSegments.last
- : "";
- if (name.isEmpty && uri.pathSegments.length > 1) {
- name = uri.pathSegments[uri.pathSegments.length - 2];
- } else if (name.isEmpty) {
- name = uri.host;
- }
-
- context.read<MediaCellBloc>().add(
- MediaCellEvent.addFile(
- url: url,
- name: name,
- uploadType: FileUploadTypePB.NetworkFile,
- fileType: fileType,
- ),
- );
+class _AddButton extends StatelessWidget {
+ const _AddButton({required this.addFilePopoverController});
- addFilePopoverController.close();
- },
- ),
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: addFilePopoverController.show,
- child: FlowyHover(
- resetHoverOnRebuild: false,
- child: Padding(
- padding: const EdgeInsets.all(4.0),
- child: Row(
- children: [
- const FlowySvg(
- FlowySvgs.add_s,
- size: Size.square(18),
- ),
- const HSpace(8),
- FlowyText(
- LocaleKeys.grid_media_addFileOrImage.tr(),
- lineHeight: 1.0,
- ),
- ],
- ),
- ),
+ final PopoverController addFilePopoverController;
+
+ @override
+ Widget build(BuildContext context) {
+ return AppFlowyPopover(
+ controller: addFilePopoverController,
+ direction: PopoverDirection.bottomWithCenterAligned,
+ offset: const Offset(0, 10),
+ constraints: const BoxConstraints(maxWidth: 350),
+ triggerActions: PopoverTriggerFlags.none,
+ popupBuilder: (popoverContext) => FileUploadMenu(
+ allowMultipleFiles: true,
+ onInsertLocalFile: (files) async => insertLocalFiles(
+ context,
+ files,
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ documentId: context.read<MediaCellBloc>().rowId,
+ onUploadSuccess: (file, path, isLocalMode) {
+ final mediaCellBloc = context.read<MediaCellBloc>();
+ if (mediaCellBloc.isClosed) {
+ return;
+ }
+
+ mediaCellBloc.add(
+ MediaCellEvent.addFile(
+ url: path,
+ name: file.name,
+ uploadType: isLocalMode
+ ? FileUploadTypePB.LocalFile
+ : FileUploadTypePB.CloudFile,
+ fileType: file.fileType.toMediaFileTypePB(),
+ ),
+ );
+
+ addFilePopoverController.close();
+ },
+ ),
+ onInsertNetworkFile: (url) {
+ if (url.isEmpty) return;
+
+ final uri = Uri.tryParse(url);
+ if (uri == null) {
+ return;
+ }
+
+ final fakeFile = XFile(uri.path);
+ MediaFileTypePB fileType = fakeFile.fileType.toMediaFileTypePB();
+ fileType = fileType == MediaFileTypePB.Other
+ ? MediaFileTypePB.Link
+ : fileType;
+
+ String name =
+ uri.pathSegments.isNotEmpty ? uri.pathSegments.last : "";
+ if (name.isEmpty && uri.pathSegments.length > 1) {
+ name = uri.pathSegments[uri.pathSegments.length - 2];
+ } else if (name.isEmpty) {
+ name = uri.host;
+ }
+
+ context.read<MediaCellBloc>().add(
+ MediaCellEvent.addFile(
+ url: url,
+ name: name,
+ uploadType: FileUploadTypePB.NetworkFile,
+ fileType: fileType,
+ ),
+ );
+
+ addFilePopoverController.close();
+ },
+ ),
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ border: Border(
+ top: BorderSide(
+ color: Theme.of(context).dividerColor,
+ ),
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: addFilePopoverController.show,
+ child: FlowyHover(
+ resetHoverOnRebuild: false,
+ child: Padding(
+ padding: const EdgeInsets.all(4.0),
+ child: Row(
+ children: [
+ FlowySvg(
+ FlowySvgs.add_thin_s,
+ size: const Size.square(14),
+ color: AFThemeExtension.of(context).lightIconColor,
),
- ),
+ const HSpace(8),
+ FlowyText.regular(
+ LocaleKeys.grid_media_addFileOrImage.tr(),
+ figmaLineHeight: 20,
+ fontSize: 14,
+ ),
+ ],
),
- ],
+ ),
),
),
- );
- },
+ ),
+ ),
);
}
}
@@ -226,6 +249,8 @@ class _RenderMediaState extends State<RenderMedia> {
MediaFilePB get file => widget.file;
+ late final controller = PopoverController();
+
@override
void initState() {
super.initState();
@@ -240,12 +265,12 @@ class _RenderMediaState extends State<RenderMedia> {
@override
Widget build(BuildContext context) {
- return MouseRegion(
- onEnter: (_) => setState(() => isHovering = true),
- onExit: (_) => setState(() => isHovering = false),
- cursor: SystemMouseCursors.click,
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 2),
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 4),
+ child: MouseRegion(
+ onEnter: (_) => setState(() => isHovering = true),
+ onExit: (_) => setState(() => isHovering = false),
+ cursor: SystemMouseCursors.click,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
@@ -253,18 +278,27 @@ class _RenderMediaState extends State<RenderMedia> {
? AFThemeExtension.of(context).greyHover
: Colors.transparent,
),
- child: Padding(
- padding: const EdgeInsets.all(4),
- child: Row(
- children: [
- ReorderableDragStartListener(
- index: widget.index,
- enabled: widget.enableReordering,
- child: const FlowySvg(FlowySvgs.drag_element_s),
+ child: Row(
+ crossAxisAlignment: widget.file.fileType == MediaFileTypePB.Image
+ ? CrossAxisAlignment.start
+ : CrossAxisAlignment.center,
+ children: [
+ ReorderableDragStartListener(
+ index: widget.index,
+ enabled: widget.enableReordering,
+ child: Padding(
+ padding: const EdgeInsets.all(4),
+ child: FlowySvg(
+ FlowySvgs.drag_element_s,
+ color: AFThemeExtension.of(context).lightIconColor,
+ ),
),
- const HSpace(8),
- if (widget.file.fileType == MediaFileTypePB.Image) ...[
- Expanded(
+ ),
+ const HSpace(4),
+ if (widget.file.fileType == MediaFileTypePB.Image) ...[
+ Flexible(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 4),
child: _openInteractiveViewer(
context,
files: widget.images,
@@ -277,54 +311,66 @@ class _RenderMediaState extends State<RenderMedia> {
),
),
),
- ] else ...[
- Expanded(
- child: GestureDetector(
- onTap: () => afLaunchUrlString(file.url),
- child: Row(
- children: [
- FlowySvg(
+ ),
+ ] else ...[
+ Expanded(
+ child: GestureDetector(
+ onTap: () => afLaunchUrlString(file.url),
+ child: Row(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 4),
+ child: FlowySvg(
file.fileType.icon,
color: AFThemeExtension.of(context).strongText,
- size: const Size.square(18),
+ size: const Size.square(12),
),
- const HSpace(8),
- Flexible(
+ ),
+ const HSpace(8),
+ Flexible(
+ child: Padding(
+ padding: const EdgeInsets.only(bottom: 1),
child: FlowyText(
file.name,
overflow: TextOverflow.ellipsis,
+ fontSize: 14,
),
),
- ],
- ),
- ),
- ),
- ],
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: AppFlowyPopover(
- mutex: widget.mutex,
- asBarrier: true,
- constraints: const BoxConstraints(maxWidth: 150),
- direction: PopoverDirection.bottomWithRightAligned,
- popupBuilder: (popoverContext) => BlocProvider.value(
- value: context.read<MediaCellBloc>(),
- child: MediaItemMenu(
- file: file,
- closeContext: popoverContext,
- ),
- ),
- child: FlowyIconButton(
- width: 24,
- icon: FlowySvg(
- FlowySvgs.three_dots_s,
- color: AFThemeExtension.of(context).textColor,
- ),
+ ),
+ ],
),
),
),
],
- ),
+ const HSpace(4),
+ AppFlowyPopover(
+ controller: controller,
+ mutex: widget.mutex,
+ asBarrier: true,
+ offset: const Offset(0, 4),
+ constraints: const BoxConstraints(maxWidth: 240),
+ direction: PopoverDirection.bottomWithLeftAligned,
+ popupBuilder: (popoverContext) => BlocProvider.value(
+ value: context.read<MediaCellBloc>(),
+ child: MediaItemMenu(
+ file: file,
+ images: widget.images,
+ index: imageIndex ?? -1,
+ closeContext: popoverContext,
+ onAction: () => controller.close(),
+ ),
+ ),
+ child: FlowyIconButton(
+ hoverColor: Colors.transparent,
+ width: 24,
+ icon: FlowySvg(
+ FlowySvgs.three_dots_s,
+ size: const Size.square(16),
+ color: AFThemeExtension.of(context).lightIconColor,
+ ),
+ ),
+ ),
+ ],
),
),
),
@@ -357,12 +403,28 @@ class MediaItemMenu extends StatefulWidget {
const MediaItemMenu({
super.key,
required this.file,
+ required this.images,
+ required this.index,
this.closeContext,
+ this.onAction,
});
+ /// The [MediaFilePB] this menu concerns
final MediaFilePB file;
+
+ /// The list of [MediaFilePB] which are images
+ /// This is used to show the [InteractiveImageViewer]
+ final List<MediaFilePB> images;
+
+ /// The index of the [MediaFilePB] in the [images] list
+ final int index;
+
+ /// The [BuildContext] used to show the [InteractiveImageViewer]
final BuildContext? closeContext;
+ /// Callback to be called when an action is performed
+ final VoidCallback? onAction;
+
@override
State<MediaItemMenu> createState() => _MediaItemMenuState();
}
@@ -383,120 +445,109 @@ class _MediaItemMenuState extends State<MediaItemMenu> {
@override
Widget build(BuildContext context) {
return SeparatedColumn(
- separatorBuilder: () => const VSpace(4),
+ separatorBuilder: () => const VSpace(8),
mainAxisSize: MainAxisSize.min,
children: [
if (widget.file.fileType == MediaFileTypePB.Image) ...[
- FlowyButton(
- onTap: () => showDialog(
- context: widget.closeContext ?? context,
- builder: (_) => InteractiveImageViewer(
- userProfile: context.read<MediaCellBloc>().state.userProfile,
- imageProvider: AFBlockImageProvider(
- images: [
- ImageBlockData(
- url: widget.file.url,
- type: widget.file.uploadType.toCustomImageType(),
+ MediaMenuItem(
+ onTap: () {
+ widget.onAction?.call();
+ _showInteractiveViewer();
+ },
+ icon: FlowySvgs.full_view_s,
+ label: LocaleKeys.grid_media_expand.tr(),
+ ),
+ MediaMenuItem(
+ onTap: () {
+ context.read<MediaCellBloc>().add(
+ MediaCellEvent.setCover(
+ RowCoverPB(
+ data: widget.file.url,
+ uploadType: widget.file.uploadType,
+ coverType: CoverTypePB.FileCover,
+ ),
),
- ],
- onDeleteImage: (_) =>
- context.read<MediaCellBloc>().deleteFile(widget.file.id),
- ),
- ),
- ),
- leftIcon: FlowySvg(
- FlowySvgs.full_view_s,
- color: Theme.of(context).iconTheme.color,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.settings_files_open.tr(),
- color: AFThemeExtension.of(context).textColor,
- ),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
+ );
+ widget.onAction?.call();
+ },
+ icon: FlowySvgs.cover_s,
+ label: LocaleKeys.grid_media_setAsCover.tr(),
),
],
- FlowyButton(
- leftIcon: FlowySvg(
- FlowySvgs.edit_s,
- color: Theme.of(context).iconTheme.color,
- size: const Size.square(18),
- ),
- leftIconSize: const Size(18, 18),
- text: FlowyText.regular(
- LocaleKeys.grid_media_rename.tr(),
- color: AFThemeExtension.of(context).textColor,
- ),
+ MediaMenuItem(
onTap: () {
- nameController.selection = TextSelection(
- baseOffset: 0,
- extentOffset: nameController.text.length,
- );
-
- showCustomConfirmDialog(
- context: context,
- title: LocaleKeys.document_plugins_file_renameFile_title.tr(),
- description:
- LocaleKeys.document_plugins_file_renameFile_description.tr(),
- closeOnConfirm: false,
- builder: (dialogContext) {
- renameContext = dialogContext;
- return FileRenameTextField(
- nameController: nameController,
- errorMessage: errorMessage,
- onSubmitted: () => _saveName(context),
- disposeController: false,
- );
- },
- confirmLabel: LocaleKeys.button_save.tr(),
- onConfirm: () => _saveName(context),
- );
+ widget.onAction?.call();
+ afLaunchUrlString(widget.file.url);
},
+ icon: FlowySvgs.open_in_browser_s,
+ label: LocaleKeys.grid_media_openInBrowser.tr(),
),
- FlowyButton(
- onTap: () async => downloadMediaFile(
- context,
- widget.file,
- userProfile: context.read<MediaCellBloc>().state.userProfile,
- ),
- leftIcon: FlowySvg(
- FlowySvgs.download_s,
- color: Theme.of(context).iconTheme.color,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.button_download.tr(),
- color: AFThemeExtension.of(context).textColor,
- ),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
+ MediaMenuItem(
+ onTap: () async {
+ await _showRenameDialog();
+ widget.onAction?.call();
+ },
+ icon: FlowySvgs.rename_s,
+ label: LocaleKeys.grid_media_rename.tr(),
),
- FlowyButton(
- onTap: () => showConfirmDeletionDialog(
- context: context,
- name: widget.file.name,
- description: LocaleKeys.grid_media_deleteFileDescription.tr(),
- onConfirm: () => context
- .read<MediaCellBloc>()
- .add(MediaCellEvent.removeFile(fileId: widget.file.id)),
- ),
- leftIcon: FlowySvg(
- FlowySvgs.delete_s,
- color: Theme.of(context).colorScheme.error,
- size: const Size.square(18),
- ),
- text: FlowyText.regular(
- LocaleKeys.button_delete.tr(),
- color: Theme.of(context).colorScheme.error,
+ if (widget.file.uploadType == FileUploadTypePB.CloudFile) ...[
+ MediaMenuItem(
+ onTap: () async {
+ await downloadMediaFile(
+ context,
+ widget.file,
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ );
+ widget.onAction?.call();
+ },
+ icon: FlowySvgs.save_as_s,
+ label: LocaleKeys.button_download.tr(),
),
- leftIconSize: const Size(18, 18),
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
+ ],
+ MediaMenuItem(
+ onTap: () async {
+ await showConfirmDeletionDialog(
+ context: context,
+ name: widget.file.name,
+ description: LocaleKeys.grid_media_deleteFileDescription.tr(),
+ onConfirm: () => context
+ .read<MediaCellBloc>()
+ .add(MediaCellEvent.removeFile(fileId: widget.file.id)),
+ );
+ widget.onAction?.call();
+ },
+ icon: FlowySvgs.trash_s,
+ label: LocaleKeys.button_delete.tr(),
),
],
);
}
+ Future<void> _showRenameDialog() async {
+ nameController.selection = TextSelection(
+ baseOffset: 0,
+ extentOffset: nameController.text.length,
+ );
+
+ await showCustomConfirmDialog(
+ context: context,
+ title: LocaleKeys.document_plugins_file_renameFile_title.tr(),
+ description: LocaleKeys.document_plugins_file_renameFile_description.tr(),
+ closeOnConfirm: false,
+ builder: (dialogContext) {
+ renameContext = dialogContext;
+ return FileRenameTextField(
+ nameController: nameController,
+ errorMessage: errorMessage,
+ onSubmitted: () => _saveName(context),
+ disposeController: false,
+ );
+ },
+ confirmLabel: LocaleKeys.button_save.tr(),
+ onConfirm: () => _saveName(context),
+ );
+ }
+
void _saveName(BuildContext context) {
if (nameController.text.isEmpty) {
errorMessage.value =
@@ -515,4 +566,57 @@ class _MediaItemMenuState extends State<MediaItemMenu> {
Navigator.of(renameContext!).pop();
}
}
+
+ void _showInteractiveViewer() {
+ showDialog(
+ context: widget.closeContext ?? context,
+ builder: (_) => InteractiveImageViewer(
+ userProfile: context.read<MediaCellBloc>().state.userProfile,
+ imageProvider: AFBlockImageProvider(
+ initialIndex: widget.index,
+ images: widget.images
+ .map(
+ (e) => ImageBlockData(
+ url: e.url,
+ type: e.uploadType.toCustomImageType(),
+ ),
+ )
+ .toList(),
+ onDeleteImage: (index) {
+ final deleteFile = widget.images[index];
+ context.read<MediaCellBloc>().deleteFile(deleteFile.id);
+ },
+ ),
+ ),
+ );
+ }
+}
+
+class MediaMenuItem extends StatelessWidget {
+ const MediaMenuItem({
+ super.key,
+ required this.onTap,
+ required this.icon,
+ required this.label,
+ });
+
+ final VoidCallback onTap;
+ final FlowySvgData icon;
+ final String label;
+
+ @override
+ Widget build(BuildContext context) {
+ return FlowyButton(
+ onTap: onTap,
+ leftIcon: FlowySvg(icon),
+ text: Padding(
+ padding: const EdgeInsets.only(left: 4, top: 1, bottom: 1),
+ child: FlowyText.regular(
+ label,
+ figmaLineHeight: 20,
+ ),
+ ),
+ hoverColor: AFThemeExtension.of(context).lightGreyHover,
+ );
+ }
}
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/mobile_media_cell_editor.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/mobile_media_cell_editor.dart
index 511e56da3e..9420e45e77 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/mobile_media_cell_editor.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/mobile_media_cell_editor.dart
@@ -1,5 +1,3 @@
-import 'package:flutter/material.dart';
-
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dart';
@@ -8,17 +6,14 @@ import 'package:appflowy/plugins/base/drag_handler.dart';
import 'package:appflowy/plugins/database/application/cell/bloc/media_cell_bloc.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/media_cell_editor.dart';
import 'package:appflowy/plugins/database/widgets/media_file_type_ext.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/file/file_upload_menu.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/file/file_util.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/common.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/image_render.dart';
-import 'package:appflowy/util/xfile_ext.dart';
import 'package:appflowy/workspace/presentation/widgets/image_viewer/interactive_image_viewer.dart';
-import 'package:appflowy_backend/protobuf/flowy-database2/file_entities.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/media_entities.pb.dart';
-import 'package:cross_file/cross_file.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
+import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -29,7 +24,11 @@ class MobileMediaCellEditor extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return ConstrainedBox(
+ return Container(
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.primaryContainer,
+ borderRadius: BorderRadius.circular(12),
+ ),
constraints: const BoxConstraints.tightFor(height: 420),
child: BlocProvider.value(
value: context.read<MediaCellBloc>(),
@@ -39,12 +38,21 @@ class MobileMediaCellEditor extends StatelessWidget {
children: [
const DragHandle(),
SizedBox(
- height: 44.0,
- child: Align(
- child: FlowyText.medium(
- LocaleKeys.grid_field_mediaFieldName.tr(),
- fontSize: 18,
- ),
+ height: 46.0,
+ child: Stack(
+ children: [
+ Align(
+ child: FlowyText.medium(
+ LocaleKeys.grid_field_mediaFieldName.tr(),
+ fontSize: 18,
+ ),
+ ),
+ const Positioned(
+ top: 8,
+ right: 18,
+ child: FlowySvg(FlowySvgs.add_m, size: Size.square(28)),
+ ),
+ ],
),
),
const Divider(height: 0.5),
@@ -52,80 +60,39 @@ class MobileMediaCellEditor extends StatelessWidget {
child: SingleChildScrollView(
child: Column(
children: [
- Padding(
- padding: const EdgeInsets.all(8),
- child: FlowyButton(
- margin: const EdgeInsets.all(12),
- onTap: () => showMobileBottomSheet(
- context,
- title: LocaleKeys.grid_media_addFileMobile.tr(),
- showHeader: true,
- showCloseButton: true,
- showDragHandle: true,
- builder: (dialogContext) => Container(
- margin: const EdgeInsets.only(top: 12),
- constraints: const BoxConstraints(
- maxHeight: 340,
- minHeight: 80,
- ),
- child: FileUploadMenu(
- onInsertLocalFile: (files) async {
- dialogContext.pop();
-
- await insertLocalFiles(
- context,
- files,
- userProfile: context
- .read<MediaCellBloc>()
- .state
- .userProfile,
- documentId:
- context.read<MediaCellBloc>().rowId,
- onUploadSuccess: (file, path, isLocalMode) {
- final mediaCellBloc =
- context.read<MediaCellBloc>();
- if (mediaCellBloc.isClosed) {
- return;
- }
-
- mediaCellBloc.add(
- MediaCellEvent.addFile(
- url: path,
- name: file.name,
- uploadType: isLocalMode
- ? FileUploadTypePB.LocalFile
- : FileUploadTypePB.CloudFile,
- fileType:
- file.fileType.toMediaFileTypePB(),
- ),
- );
- },
- );
- },
- onInsertNetworkFile: (url) async =>
- _onInsertNetworkFile(
- url,
- dialogContext,
- context,
- ),
- ),
- ),
- ),
- text: const Row(
- children: [
- FlowySvg(
- FlowySvgs.add_s,
- size: Size.square(20),
- ),
- HSpace(8),
- FlowyText('Add a file or image', fontSize: 15),
- ],
- ),
- ),
- ),
+ // Padding(
+ // padding: const EdgeInsets.all(8),
+ // child: FlowyButton(
+ // margin: const EdgeInsets.all(12),
+ // onTap: () => showMobileBottomSheet(
+ // context,
+ // title: LocaleKeys.grid_media_addFileMobile.tr(),
+ // showHeader: true,
+ // showCloseButton: true,
+ // showDragHandle: true,
+ // builder: (dContext) =>
+ // MobileMediaUploadSheetContent(
+ // dialogContext: dContext,
+ // ),
+ // ),
+ // text: const Row(
+ // children: [
+ // FlowySvg(
+ // FlowySvgs.add_s,
+ // size: Size.square(20),
+ // ),
+ // HSpace(8),
+ // FlowyText('Add a file or image', fontSize: 15),
+ // ],
+ // ),
+ // ),
+ // ),
if (state.files.isNotEmpty) const Divider(height: .5),
...state.files.map(
- (file) => _FileItem(key: Key(file.id), file: file),
+ (file) => Padding(
+ padding: const EdgeInsets.only(bottom: 2),
+ child: _FileItem(key: Key(file.id), file: file),
+ ),
),
],
),
@@ -137,41 +104,6 @@ class MobileMediaCellEditor extends StatelessWidget {
),
);
}
-
- Future<void> _onInsertNetworkFile(
- String url,
- BuildContext dialogContext,
- BuildContext context,
- ) async {
- dialogContext.pop();
-
- if (url.isEmpty) return;
- final uri = Uri.tryParse(url);
- if (uri == null) {
- return;
- }
-
- final fakeFile = XFile(uri.path);
- MediaFileTypePB fileType = fakeFile.fileType.toMediaFileTypePB();
- fileType =
- fileType == MediaFileTypePB.Other ? MediaFileTypePB.Link : fileType;
-
- String name = uri.pathSegments.isNotEmpty ? uri.pathSegments.last : "";
- if (name.isEmpty && uri.pathSegments.length > 1) {
- name = uri.pathSegments[uri.pathSegments.length - 2];
- } else if (name.isEmpty) {
- name = uri.host;
- }
-
- context.read<MediaCellBloc>().add(
- MediaCellEvent.addFile(
- url: url,
- name: name,
- uploadType: FileUploadTypePB.NetworkFile,
- fileType: fileType,
- ),
- );
- }
}
class _FileItem extends StatelessWidget {
@@ -181,61 +113,64 @@ class _FileItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return Column(
- children: [
- ListTile(
- title: Row(
- children: [
- if (file.fileType != MediaFileTypePB.Image) ...[
- FlowySvg(file.fileType.icon, size: const Size.square(24)),
- const HSpace(12),
- Expanded(
- child: FlowyText(
- file.name,
- overflow: TextOverflow.ellipsis,
- ),
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.secondaryContainer,
+ ),
+ child: ListTile(
+ title: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ if (file.fileType != MediaFileTypePB.Image) ...[
+ FlowySvg(file.fileType.icon, size: const Size.square(24)),
+ const HSpace(12),
+ Expanded(
+ child: FlowyText(
+ file.name,
+ overflow: TextOverflow.ellipsis,
),
- ] else ...[
- Expanded(
- child: Container(
- alignment: Alignment.centerLeft,
- constraints: const BoxConstraints(maxHeight: 125),
- child: GestureDetector(
- onTap: () => openInteractiveViewer(context),
- child: ImageRender(
- userProfile:
- context.read<MediaCellBloc>().state.userProfile,
- fit: BoxFit.fitHeight,
- image: ImageBlockData(
- url: file.url,
- type: file.uploadType.toCustomImageType(),
- ),
+ ),
+ ] else ...[
+ Expanded(
+ child: Container(
+ margin: const EdgeInsets.symmetric(vertical: 12),
+ alignment: Alignment.centerLeft,
+ constraints: const BoxConstraints(maxHeight: 125),
+ child: GestureDetector(
+ onTap: () => openInteractiveViewer(context),
+ child: ImageRender(
+ userProfile:
+ context.read<MediaCellBloc>().state.userProfile,
+ fit: BoxFit.fitHeight,
+ borderRadius: BorderRadius.zero,
+ image: ImageBlockData(
+ url: file.url,
+ type: file.uploadType.toCustomImageType(),
),
),
),
),
- ],
- FlowyIconButton(
- width: 40,
- icon: const FlowySvg(
- FlowySvgs.three_dots_s,
- size: Size.square(20),
- ),
- onPressed: () => showMobileBottomSheet(
- context,
- showDragHandle: true,
- builder: (_) => BlocProvider.value(
- value: context.read<MediaCellBloc>(),
- child: _EditFileSheet(file: file),
- ),
- ),
),
- const HSpace(6),
],
- ),
+ FlowyIconButton(
+ width: 40,
+ icon: const FlowySvg(
+ FlowySvgs.three_dots_s,
+ size: Size.square(20),
+ ),
+ onPressed: () => showMobileBottomSheet(
+ context,
+ showDragHandle: true,
+ builder: (_) => BlocProvider.value(
+ value: context.read<MediaCellBloc>(),
+ child: _EditFileSheet(file: file),
+ ),
+ ),
+ ),
+ const HSpace(6),
+ ],
),
- const Divider(height: .5),
- ],
+ ),
);
}
@@ -276,16 +211,16 @@ class __EditFileSheetState extends State<_EditFileSheet> {
child: Column(
children: [
const VSpace(16),
- _FileTextField(
- file: file,
- controller: controller,
- onChanged: (name) =>
- context.read<MediaCellBloc>().renameFile(file.id, name),
- ),
+ // _FileTextField(
+ // file: file,
+ // controller: controller,
+ // onChanged: (name) =>
+ // context.read<MediaCellBloc>().renameFile(file.id, name),
+ // ),
const VSpace(20),
if (file.fileType == MediaFileTypePB.Image)
FlowyOptionTile.text(
- text: LocaleKeys.grid_media_open.tr(),
+ text: LocaleKeys.grid_media_expand.tr(),
leftIcon: const FlowySvg(
FlowySvgs.full_view_s,
size: Size.square(20),
@@ -294,7 +229,7 @@ class __EditFileSheetState extends State<_EditFileSheet> {
),
FlowyOptionTile.text(
text: file.fileType == MediaFileTypePB.Link
- ? LocaleKeys.grid_media_open.tr()
+ ? LocaleKeys.grid_media_expand.tr()
: LocaleKeys.grid_media_download.tr(),
leftIcon: FlowySvg(
file.fileType == MediaFileTypePB.Link
@@ -340,38 +275,3 @@ class __EditFileSheetState extends State<_EditFileSheet> {
userProfile: context.read<MediaCellBloc>().state.userProfile,
);
}
-
-class _FileTextField extends StatelessWidget {
- const _FileTextField({
- required this.file,
- required this.controller,
- required this.onChanged,
- });
-
- final MediaFilePB file;
- final TextEditingController controller;
- final void Function(String) onChanged;
-
- @override
- Widget build(BuildContext context) {
- return FlowyOptionTile.textField(
- controller: controller,
- textFieldPadding: const EdgeInsets.symmetric(horizontal: 12),
- onTextChanged: onChanged,
- leftIcon: Container(
- height: 38,
- width: 38,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(12),
- color: file.fileType.color,
- ),
- child: Center(
- child: FlowySvg(
- file.fileType.icon,
- size: const Size.square(22),
- ),
- ),
- ),
- );
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/field_type_list.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/field_type_list.dart
index fa5c45f0b2..6661d5cd2d 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/field_type_list.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/field_type_list.dart
@@ -14,16 +14,16 @@ const List<FieldType> _supportedFieldTypes = [
FieldType.SingleSelect,
FieldType.MultiSelect,
FieldType.DateTime,
+ FieldType.Media,
+ FieldType.URL,
FieldType.Checkbox,
FieldType.Checklist,
- FieldType.URL,
FieldType.LastEditedTime,
FieldType.CreatedTime,
FieldType.Relation,
FieldType.Summary,
- // FieldType.Time,
FieldType.Translate,
- FieldType.Media,
+ // FieldType.Time,
];
class FieldTypeList extends StatelessWidget with FlowyOverlayDelegate {
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/media.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/media.dart
index ba4fe5736a..07dc2bafd0 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/media.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/media.dart
@@ -33,17 +33,15 @@ class MediaTypeOptionEditorFactory implements TypeOptionEditorFactory {
child: FlowyButton(
resetHoverOnRebuild: false,
text: FlowyText(
- LocaleKeys.grid_media_hideFileNames.tr(),
+ LocaleKeys.grid_media_showFileNames.tr(),
lineHeight: 1.0,
),
onHover: (_) => popoverMutex.close(),
rightIcon: Toggle(
- value: typeOption.hideFileNames,
- onChanged: (value) {
- onTypeOptionUpdated(
- _toggleHideFiles(typeOption, value).writeToBuffer(),
- );
- },
+ value: !typeOption.hideFileNames,
+ onChanged: (val) => onTypeOptionUpdated(
+ _toggleHideFiles(typeOption, !val).writeToBuffer(),
+ ),
padding: EdgeInsets.zero,
),
),
@@ -59,7 +57,6 @@ class MediaTypeOptionEditorFactory implements TypeOptionEditorFactory {
bool hideFileNames,
) {
typeOption.freeze();
- return typeOption
- .rebuild((typeOption) => typeOption.hideFileNames = hideFileNames);
+ return typeOption.rebuild((to) => to.hideFileNames = hideFileNames);
}
}
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/media_file_type_ext.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/media_file_type_ext.dart
index d4ae050dfa..059fe9bfb7 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/media_file_type_ext.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/media_file_type_ext.dart
@@ -17,12 +17,14 @@ extension FileTypeDisplay on MediaFileTypePB {
Color get color => switch (this) {
MediaFileTypePB.Image => const Color(0xFF5465A1),
- MediaFileTypePB.Link => const Color(0xFFA35F94),
- MediaFileTypePB.Document => const Color(0xFFBAAC74),
- MediaFileTypePB.Archive => const Color(0xFF40AAB8),
- MediaFileTypePB.Video => const Color(0xFF5465A1),
- MediaFileTypePB.Audio => const Color(0xFF5465A1),
- MediaFileTypePB.Text => const Color(0xFF87B3A8),
+ MediaFileTypePB.Link => const Color(0xFFEBE4FF),
+ MediaFileTypePB.Audio => const Color(0xFFE4FFDE),
+ MediaFileTypePB.Video => const Color(0xFFE0F8FF),
+ MediaFileTypePB.Archive => const Color(0xFFFFE7EE),
+ MediaFileTypePB.Text ||
+ MediaFileTypePB.Document ||
+ MediaFileTypePB.Other =>
+ const Color(0xFFF5FFDC),
_ => const Color(0xFF87B3A8),
};
}
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_detail.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_detail.dart
index 920180ad0f..7b39335ec7 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_detail.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_detail.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy/plugins/document/presentation/editor_drop_manager.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -17,6 +18,7 @@ import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:provider/provider.dart';
import '../cell/editable_cell_builder.dart';
@@ -42,8 +44,12 @@ class RowDetailPage extends StatefulWidget with FlowyOverlayDelegate {
}
class _RowDetailPageState extends State<RowDetailPage> {
- late final cellBuilder =
- EditableCellBuilder(databaseController: widget.databaseController);
+ // To allow blocking drop target in RowDocument from Field dialogs
+ final dropManagerState = EditorDropManagerState();
+
+ late final cellBuilder = EditableCellBuilder(
+ databaseController: widget.databaseController,
+ );
late final ScrollController scrollController;
double scrollOffset = 0;
@@ -67,60 +73,63 @@ class _RowDetailPageState extends State<RowDetailPage> {
@override
Widget build(BuildContext context) {
return FlowyDialog(
- child: MultiBlocProvider(
- providers: [
- BlocProvider(
- create: (context) => RowDetailBloc(
- fieldController: widget.databaseController.fieldController,
- rowController: widget.rowController,
+ child: ChangeNotifierProvider.value(
+ value: dropManagerState,
+ child: MultiBlocProvider(
+ providers: [
+ BlocProvider(
+ create: (_) => RowDetailBloc(
+ fieldController: widget.databaseController.fieldController,
+ rowController: widget.rowController,
+ ),
),
- ),
- BlocProvider.value(value: getIt<ReminderBloc>()),
- ],
- child: BlocBuilder<RowDetailBloc, RowDetailState>(
- builder: (context, state) => Stack(
- children: [
- ListView(
- controller: scrollController,
- physics: const ClampingScrollPhysics(),
- children: [
- RowBanner(
- databaseController: widget.databaseController,
- rowController: widget.rowController,
- cellBuilder: cellBuilder,
- allowOpenAsFullPage: widget.allowOpenAsFullPage,
- userProfile: widget.userProfile,
- ),
- const VSpace(16),
- Padding(
- padding: const EdgeInsets.only(left: 40, right: 60),
- child: RowPropertyList(
+ BlocProvider.value(value: getIt<ReminderBloc>()),
+ ],
+ child: BlocBuilder<RowDetailBloc, RowDetailState>(
+ builder: (context, state) => Stack(
+ children: [
+ ListView(
+ controller: scrollController,
+ physics: const ClampingScrollPhysics(),
+ children: [
+ RowBanner(
+ databaseController: widget.databaseController,
+ rowController: widget.rowController,
cellBuilder: cellBuilder,
- viewId: widget.databaseController.viewId,
- fieldController:
- widget.databaseController.fieldController,
+ allowOpenAsFullPage: widget.allowOpenAsFullPage,
+ userProfile: widget.userProfile,
),
+ const VSpace(16),
+ Padding(
+ padding: const EdgeInsets.only(left: 40, right: 60),
+ child: RowPropertyList(
+ cellBuilder: cellBuilder,
+ viewId: widget.databaseController.viewId,
+ fieldController:
+ widget.databaseController.fieldController,
+ ),
+ ),
+ const VSpace(20),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 60),
+ child: Divider(height: 1.0),
+ ),
+ const VSpace(20),
+ RowDocument(
+ viewId: widget.rowController.viewId,
+ rowId: widget.rowController.rowId,
+ ),
+ ],
+ ),
+ Positioned(
+ top: calculateActionsOffset(
+ state.rowMeta.cover.data.isNotEmpty,
),
- const VSpace(20),
- const Padding(
- padding: EdgeInsets.symmetric(horizontal: 60),
- child: Divider(height: 1.0),
- ),
- const VSpace(20),
- RowDocument(
- viewId: widget.rowController.viewId,
- rowId: widget.rowController.rowId,
- ),
- ],
- ),
- Positioned(
- top: calculateActionsOffset(
- state.rowMeta.cover.data.isNotEmpty,
+ right: 12,
+ child: Row(children: actions(context)),
),
- right: 12,
- child: Row(children: actions(context)),
- ),
- ],
+ ],
+ ),
),
),
),
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart
index 0d182c4aef..757ec3a37d 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy/plugins/document/presentation/editor_drop_manager.dart';
import 'package:flutter/material.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
@@ -106,6 +107,7 @@ class _RowEditor extends StatelessWidget {
viewId: view.id,
editorState: editorState,
isLocalMode: context.read<DocumentBloc>().isLocalMode,
+ dropManagerState: context.read<EditorDropManagerState>(),
child: AppFlowyEditorPage(
shrinkWrap: true,
autoFocus: false,
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_drop_handler.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_drop_handler.dart
index 0f16938d71..af5031f5cc 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_drop_handler.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_drop_handler.dart
@@ -25,36 +25,46 @@ class EditorDropHandler extends StatelessWidget {
required this.editorState,
required this.isLocalMode,
required this.child,
+ this.dropManagerState,
});
final String viewId;
final EditorState editorState;
final bool isLocalMode;
final Widget child;
+ final EditorDropManagerState? dropManagerState;
@override
Widget build(BuildContext context) {
+ final childWidget = Consumer<EditorDropManagerState>(
+ builder: (context, dropState, _) => DropTarget(
+ enable: dropState.isDropEnabled,
+ onDragExited: (_) => editorState.selectionService.removeDropTarget(),
+ onDragUpdated: _onDragUpdated,
+ onDragDone: _onDragDone,
+ child: child,
+ ),
+ );
+
+ // Due to how DropTarget works, there is no way to differentiate if an overlay is
+ // blocking the target visibly, so when we have an overlay with a drop target,
+ // we should disable the drop target for the Editor, until it is closed.
+ //
+ // See FileBlockComponent for sample use.
+ //
+ // Relates to:
+ // - https://github.com/MixinNetwork/flutter-plugins/issues/2
+ // - https://github.com/MixinNetwork/flutter-plugins/issues/331
+ if (dropManagerState != null) {
+ return ChangeNotifierProvider.value(
+ value: dropManagerState!,
+ child: childWidget,
+ );
+ }
+
return ChangeNotifierProvider(
- // Due to how DropTarget works, there is no way to differentiate if an overlay is
- // blocking the target visibly, so when we have an overlay with a drop target,
- // we should disable the drop target for the Editor, until it is closed.
- //
- // See FileBlockComponent for sample use.
- //
- // Relates to:
- // - https://github.com/MixinNetwork/flutter-plugins/issues/2
- // - https://github.com/MixinNetwork/flutter-plugins/issues/331
- //
create: (_) => EditorDropManagerState(),
- child: Consumer<EditorDropManagerState>(
- builder: (context, dropState, _) => DropTarget(
- enable: dropState.isDropEnabled,
- onDragExited: (_) => editorState.selectionService.removeDropTarget(),
- onDragUpdated: _onDragUpdated,
- onDragDone: _onDragDone,
- child: child,
- ),
- ),
+ child: childWidget,
);
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_upload_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_upload_menu.dart
index f86916a39f..af00faee88 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_upload_menu.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_upload_menu.dart
@@ -6,6 +6,7 @@ import 'package:desktop_drop/desktop_drop.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
+import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
@@ -35,52 +36,63 @@ class _FileUploadMenuState extends State<FileUploadMenu> {
@override
Widget build(BuildContext context) {
- return DefaultTabController(
- length: 2,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- TabBar(
- onTap: (value) => setState(() => currentTab = value),
- isScrollable: true,
- padding: EdgeInsets.zero,
- overlayColor: WidgetStatePropertyAll(
- UniversalPlatform.isDesktop
- ? Theme.of(context).colorScheme.secondary
- : Colors.transparent,
- ),
- tabs: [
- _Tab(
- title: LocaleKeys.document_plugins_file_uploadTab.tr(),
+ // ClipRRect is used to clip the tab indicator, so the animation doesn't overflow the dialog
+ return ClipRRect(
+ child: DefaultTabController(
+ length: 2,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ TabBar(
+ onTap: (value) => setState(() => currentTab = value),
+ isScrollable: true,
+ indicatorWeight: 3,
+ tabAlignment: TabAlignment.start,
+ indicatorSize: TabBarIndicatorSize.label,
+ labelPadding: EdgeInsets.zero,
+ padding: EdgeInsets.zero,
+ overlayColor: WidgetStatePropertyAll(
+ UniversalPlatform.isDesktop
+ ? Theme.of(context).colorScheme.secondary
+ : Colors.transparent,
),
- _Tab(
- title: LocaleKeys.document_plugins_file_networkTab.tr(),
+ tabs: [
+ _Tab(
+ title: LocaleKeys.document_plugins_file_uploadTab.tr(),
+ isSelected: currentTab == 0,
+ ),
+ _Tab(
+ title: LocaleKeys.document_plugins_file_networkTab.tr(),
+ isSelected: currentTab == 1,
+ ),
+ ],
+ ),
+ const Divider(height: 0),
+ if (currentTab == 0) ...[
+ _FileUploadLocal(
+ allowMultipleFiles: widget.allowMultipleFiles,
+ onFilesPicked: (files) {
+ if (files.isNotEmpty) {
+ widget.onInsertLocalFile(files);
+ }
+ },
),
+ ] else ...[
+ _FileUploadNetwork(onSubmit: widget.onInsertNetworkFile),
],
- ),
- const Divider(height: 4),
- if (currentTab == 0) ...[
- _FileUploadLocal(
- allowMultipleFiles: widget.allowMultipleFiles,
- onFilesPicked: (files) {
- if (files.isNotEmpty) {
- widget.onInsertLocalFile(files);
- }
- },
- ),
- ] else ...[
- _FileUploadNetwork(onSubmit: widget.onInsertNetworkFile),
],
- ],
+ ),
),
);
}
}
class _Tab extends StatelessWidget {
- const _Tab({required this.title});
+ const _Tab({required this.title, this.isSelected = false});
final String title;
+ final bool isSelected;
@override
Widget build(BuildContext context) {
@@ -91,7 +103,12 @@ class _Tab extends StatelessWidget {
bottom: 8.0,
top: UniversalPlatform.isMobile ? 0 : 8.0,
),
- child: FlowyText(title),
+ child: FlowyText.semibold(
+ title,
+ color: isSelected
+ ? AFThemeExtension.of(context).strongText
+ : Theme.of(context).hintColor,
+ ),
);
}
}
@@ -140,7 +157,7 @@ class _FileUploadLocalState extends State<_FileUploadLocal> {
}
return Padding(
- padding: const EdgeInsets.all(4),
+ padding: const EdgeInsets.all(16),
child: DropTarget(
onDragEntered: (_) => setState(() => isDragging = true),
onDragExited: (_) => setState(() => isDragging = false),
@@ -154,18 +171,16 @@ class _FileUploadLocalState extends State<_FileUploadLocal> {
resetHoverOnRebuild: false,
isSelected: () => isDragging,
style: HoverStyle(
- borderRadius: BorderRadius.circular(12),
+ borderRadius: BorderRadius.circular(10),
+ hoverColor:
+ isDragging ? AFThemeExtension.of(context).tint9 : null,
),
child: Container(
- padding: const EdgeInsets.all(8),
+ height: 172,
constraints: constraints,
child: DottedBorder(
dashPattern: const [3, 3],
radius: const Radius.circular(8),
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 32,
- ),
borderType: BorderType.RRect,
color: isDragging
? Theme.of(context).colorScheme.primary
@@ -175,23 +190,40 @@ class _FileUploadLocalState extends State<_FileUploadLocal> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isDragging) ...[
- const VSpace(13.5),
FlowyText(
LocaleKeys.document_plugins_file_dropFileToUpload
.tr(),
- fontSize: 16,
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
color: Theme.of(context).hintColor,
),
- const VSpace(13.5),
] else ...[
- FlowyText(
- LocaleKeys.document_plugins_file_fileUploadHint
- .tr(),
- fontSize: 16,
- maxLines: 2,
- lineHeight: 1.5,
- textAlign: TextAlign.center,
- color: Theme.of(context).hintColor,
+ RichText(
+ text: TextSpan(
+ children: [
+ TextSpan(
+ text: LocaleKeys
+ .document_plugins_file_fileUploadHint
+ .tr(),
+ style: TextStyle(
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ color: Theme.of(context).hintColor,
+ ),
+ ),
+ TextSpan(
+ text: LocaleKeys
+ .document_plugins_file_fileUploadHintSuffix
+ .tr(),
+ style: TextStyle(
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ color:
+ Theme.of(context).colorScheme.primary,
+ ),
+ ),
+ ],
+ ),
),
],
],
@@ -239,28 +271,28 @@ class _FileUploadNetworkState extends State<_FileUploadNetwork> {
UniversalPlatform.isMobile ? const BoxConstraints(minHeight: 92) : null;
return Container(
- padding: const EdgeInsets.all(8),
+ padding: const EdgeInsets.all(16),
constraints: constraints,
- alignment: Alignment.center,
child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
- const VSpace(12),
FlowyTextField(
hintText: LocaleKeys.document_plugins_file_networkHint.tr(),
onChanged: (value) => inputText = value,
onEditingComplete: submit,
),
if (!isUrlValid) ...[
- const VSpace(8),
+ const VSpace(4),
FlowyText(
LocaleKeys.document_plugins_file_networkUrlInvalid.tr(),
color: Theme.of(context).colorScheme.error,
+ maxLines: 3,
+ textAlign: TextAlign.start,
),
],
- const VSpace(20),
+ const VSpace(16),
SizedBox(
height: 32,
- width: 300,
child: FlowyButton(
backgroundColor: Theme.of(context).colorScheme.primary,
hoverColor:
@@ -275,7 +307,6 @@ class _FileUploadNetworkState extends State<_FileUploadNetwork> {
onTap: submit,
),
),
- const VSpace(8),
],
),
);
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart
index 579bd54ab4..f09aa1ca5e 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart
@@ -22,7 +22,6 @@ import 'package:cross_file/cross_file.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_impl.dart';
import 'package:flowy_infra/uuid.dart';
-import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
import 'package:http/http.dart' as http;
import 'package:path/path.dart' as p;
import 'package:universal_platform/universal_platform.dart';
@@ -91,8 +90,6 @@ Future<(String? path, String? errorMessage)> saveFileToCloudStorage(
/// On Mobile the file is fetched first using HTTP, and then saved using FilePicker.
/// On Desktop the files location is picked first using FilePicker, and then the file is saved.
///
-/// [onDownloadBegin] and [onDownloadEnd] are only used for Mobile.
-///
Future<void> downloadMediaFile(
BuildContext context,
MediaFilePB file, {
@@ -108,9 +105,9 @@ Future<void> downloadMediaFile(
await afLaunchUrl(Uri.parse(file.url));
} else {
if (userProfile == null) {
- return showSnapBar(
+ return showToastNotification(
context,
- LocaleKeys.grid_media_downloadFailedToken.tr(),
+ message: LocaleKeys.grid_media_downloadFailedToken.tr(),
);
}
@@ -152,6 +149,8 @@ Future<void> downloadMediaFile(
return;
}
+ onDownloadBegin?.call();
+
final response =
await http.get(uri, headers: {'Authorization': 'Bearer $token'});
@@ -160,17 +159,20 @@ Future<void> downloadMediaFile(
await imgFile.writeAsBytes(response.bodyBytes);
if (context.mounted) {
- showSnapBar(
+ showToastNotification(
context,
- LocaleKeys.grid_media_downloadSuccess.tr(),
+ message: LocaleKeys.grid_media_downloadSuccess.tr(),
);
}
} else if (context.mounted) {
- showSnapBar(
+ showToastNotification(
context,
- LocaleKeys.document_plugins_image_imageDownloadFailed.tr(),
+ type: ToastificationType.error,
+ message: LocaleKeys.document_plugins_image_imageDownloadFailed.tr(),
);
}
+
+ onDownloadEnd?.call();
}
}
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/mobile_file_upload_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/mobile_file_upload_menu.dart
new file mode 100644
index 0000000000..f716c107df
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/mobile_file_upload_menu.dart
@@ -0,0 +1,269 @@
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/shared/patterns/common_patterns.dart';
+import 'package:appflowy/shared/permission/permission_checker.dart';
+import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy_backend/log.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flowy_infra/file_picker/file_picker_service.dart';
+import 'package:flowy_infra/size.dart';
+import 'package:flowy_infra/theme_extension.dart';
+import 'package:flowy_infra_ui/style_widget/button.dart';
+import 'package:flowy_infra_ui/style_widget/text.dart';
+import 'package:flowy_infra_ui/style_widget/text_field.dart';
+import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flutter/material.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:universal_platform/universal_platform.dart';
+
+class MobileFileUploadMenu extends StatefulWidget {
+ const MobileFileUploadMenu({
+ super.key,
+ required this.onInsertLocalFile,
+ required this.onInsertNetworkFile,
+ this.allowMultipleFiles = false,
+ });
+
+ final void Function(List<XFile> files) onInsertLocalFile;
+ final void Function(String url) onInsertNetworkFile;
+ final bool allowMultipleFiles;
+
+ @override
+ State<MobileFileUploadMenu> createState() => _MobileFileUploadMenuState();
+}
+
+class _MobileFileUploadMenuState extends State<MobileFileUploadMenu> {
+ int currentTab = 0;
+
+ @override
+ Widget build(BuildContext context) {
+ // ClipRRect is used to clip the tab indicator, so the animation doesn't overflow the dialog
+ return ClipRRect(
+ child: DefaultTabController(
+ length: 2,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ TabBar(
+ onTap: (value) => setState(() => currentTab = value),
+ indicatorWeight: 3,
+ labelPadding: EdgeInsets.zero,
+ padding: EdgeInsets.zero,
+ overlayColor: WidgetStatePropertyAll(
+ UniversalPlatform.isDesktop
+ ? Theme.of(context).colorScheme.secondary
+ : Colors.transparent,
+ ),
+ tabs: [
+ _Tab(
+ title: LocaleKeys.document_plugins_file_uploadTab.tr(),
+ isSelected: currentTab == 0,
+ ),
+ _Tab(
+ title: LocaleKeys.document_plugins_file_networkTab.tr(),
+ isSelected: currentTab == 1,
+ ),
+ ],
+ ),
+ const Divider(height: 0),
+ if (currentTab == 0) ...[
+ _FileUploadLocal(
+ allowMultipleFiles: widget.allowMultipleFiles,
+ onFilesPicked: (files) {
+ if (files.isNotEmpty) {
+ widget.onInsertLocalFile(files);
+ }
+ },
+ ),
+ ] else ...[
+ _FileUploadNetwork(onSubmit: widget.onInsertNetworkFile),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class _Tab extends StatelessWidget {
+ const _Tab({required this.title, this.isSelected = false});
+
+ final String title;
+ final bool isSelected;
+
+ @override
+ Widget build(BuildContext context) {
+ return Padding(
+ padding: EdgeInsets.only(
+ left: 12.0,
+ right: 12.0,
+ bottom: 8.0,
+ top: UniversalPlatform.isMobile ? 0 : 8.0,
+ ),
+ child: FlowyText.semibold(
+ title,
+ color: isSelected
+ ? AFThemeExtension.of(context).strongText
+ : Theme.of(context).hintColor,
+ ),
+ );
+ }
+}
+
+class _FileUploadLocal extends StatefulWidget {
+ const _FileUploadLocal({
+ required this.onFilesPicked,
+ this.allowMultipleFiles = false,
+ });
+
+ final void Function(List<XFile>) onFilesPicked;
+ final bool allowMultipleFiles;
+
+ @override
+ State<_FileUploadLocal> createState() => _FileUploadLocalState();
+}
+
+class _FileUploadLocalState extends State<_FileUploadLocal> {
+ bool isDragging = false;
+
+ @override
+ Widget build(BuildContext context) {
+ return Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ children: [
+ SizedBox(
+ height: 36,
+ child: FlowyButton(
+ radius: Corners.s8Border,
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ hoverColor:
+ Theme.of(context).colorScheme.primary.withOpacity(0.9),
+ margin: const EdgeInsets.all(5),
+ text: FlowyText(
+ LocaleKeys.document_plugins_file_uploadMobileGallery.tr(),
+ textAlign: TextAlign.center,
+ color: Theme.of(context).colorScheme.onPrimary,
+ ),
+ onTap: () => _uploadFileFromGallery(context),
+ ),
+ ),
+ const VSpace(16),
+ SizedBox(
+ height: 36,
+ child: FlowyButton(
+ radius: Corners.s8Border,
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ hoverColor:
+ Theme.of(context).colorScheme.primary.withOpacity(0.9),
+ margin: const EdgeInsets.all(5),
+ text: FlowyText(
+ LocaleKeys.document_plugins_file_uploadMobile.tr(),
+ textAlign: TextAlign.center,
+ color: Theme.of(context).colorScheme.onPrimary,
+ ),
+ onTap: () => _uploadFile(context),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Future<void> _uploadFileFromGallery(BuildContext context) async {
+ final photoPermission =
+ await PermissionChecker.checkPhotoPermission(context);
+ if (!photoPermission) {
+ Log.error('Has no permission to access the photo library');
+ return;
+ }
+ // on mobile, the users can pick a image file from camera or image library
+ final files = await ImagePicker().pickMultiImage();
+
+ widget.onFilesPicked(files);
+ }
+
+ Future<void> _uploadFile(BuildContext context) async {
+ final result = await getIt<FilePickerService>().pickFiles(
+ dialogTitle: '',
+ allowMultiple: widget.allowMultipleFiles,
+ );
+
+ final List<XFile> files = result?.files.isNotEmpty ?? false
+ ? result!.files.map((f) => f.xFile).toList()
+ : const [];
+
+ widget.onFilesPicked(files);
+ }
+}
+
+class _FileUploadNetwork extends StatefulWidget {
+ const _FileUploadNetwork({required this.onSubmit});
+
+ final void Function(String url) onSubmit;
+
+ @override
+ State<_FileUploadNetwork> createState() => _FileUploadNetworkState();
+}
+
+class _FileUploadNetworkState extends State<_FileUploadNetwork> {
+ bool isUrlValid = true;
+ String inputText = '';
+
+ @override
+ Widget build(BuildContext context) {
+ final constraints =
+ UniversalPlatform.isMobile ? const BoxConstraints(minHeight: 92) : null;
+
+ return Container(
+ padding: const EdgeInsets.all(16),
+ constraints: constraints,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ FlowyTextField(
+ hintText: LocaleKeys.document_plugins_file_networkHint.tr(),
+ onChanged: (value) => inputText = value,
+ onEditingComplete: submit,
+ ),
+ if (!isUrlValid) ...[
+ const VSpace(4),
+ FlowyText(
+ LocaleKeys.document_plugins_file_networkUrlInvalid.tr(),
+ color: Theme.of(context).colorScheme.error,
+ maxLines: 3,
+ textAlign: TextAlign.start,
+ ),
+ ],
+ const VSpace(16),
+ SizedBox(
+ height: 36,
+ child: FlowyButton(
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ hoverColor:
+ Theme.of(context).colorScheme.primary.withOpacity(0.9),
+ radius: Corners.s8Border,
+ margin: const EdgeInsets.all(5),
+ text: FlowyText(
+ LocaleKeys.grid_media_embedLink.tr(),
+ textAlign: TextAlign.center,
+ color: Theme.of(context).colorScheme.onPrimary,
+ ),
+ onTap: submit,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ void submit() {
+ if (checkUrlValidity(inputText)) {
+ return widget.onSubmit(inputText);
+ }
+
+ setState(() => isUrlValid = false);
+ }
+
+ bool checkUrlValidity(String url) => hrefRegex.hasMatch(url);
+}
diff --git a/frontend/appflowy_flutter/lib/shared/af_image.dart b/frontend/appflowy_flutter/lib/shared/af_image.dart
index 9ac6f4bb70..702c0f7764 100644
--- a/frontend/appflowy_flutter/lib/shared/af_image.dart
+++ b/frontend/appflowy_flutter/lib/shared/af_image.dart
@@ -15,6 +15,7 @@ class AFImage extends StatelessWidget {
this.width,
this.fit = BoxFit.cover,
this.userProfile,
+ this.borderRadius,
}) : assert(
uploadType != FileUploadTypePB.CloudFile || userProfile != null,
'userProfile must be provided for accessing files from AF Cloud',
@@ -26,6 +27,7 @@ class AFImage extends StatelessWidget {
final double? width;
final BoxFit fit;
final UserProfilePB? userProfile;
+ final BorderRadius? borderRadius;
@override
Widget build(BuildContext context) {
@@ -40,6 +42,7 @@ class AFImage extends StatelessWidget {
height: height,
width: width,
fit: fit,
+ isAntiAlias: true,
errorBuilder: (context, error, stackTrace) {
return const SizedBox.shrink();
},
@@ -50,6 +53,7 @@ class AFImage extends StatelessWidget {
height: height,
width: width,
fit: fit,
+ isAntiAlias: true,
errorBuilder: (context, error, stackTrace) {
return const SizedBox.shrink();
},
@@ -66,6 +70,14 @@ class AFImage extends StatelessWidget {
);
}
+ if (borderRadius != null) {
+ child = ClipRRect(
+ clipBehavior: Clip.antiAliasWithSaveLayer,
+ borderRadius: borderRadius!,
+ child: child,
+ );
+ }
+
return child;
}
}
diff --git a/frontend/appflowy_flutter/lib/util/field_type_extension.dart b/frontend/appflowy_flutter/lib/util/field_type_extension.dart
index 11b55a6cc7..4ef11bf5c6 100644
--- a/frontend/appflowy_flutter/lib/util/field_type_extension.dart
+++ b/frontend/appflowy_flutter/lib/util/field_type_extension.dart
@@ -69,7 +69,7 @@ extension FieldTypeExtension on FieldType {
FieldType.Summary => const Color(0xFFBECCFF),
FieldType.Time => const Color(0xFFFDEDA7),
FieldType.Translate => const Color(0xFFBECCFF),
- FieldType.Media => const Color(0xFFFCBEBE),
+ FieldType.Media => const Color(0xFF91EBF5),
_ => throw UnimplementedError(),
};
@@ -89,7 +89,7 @@ extension FieldTypeExtension on FieldType {
FieldType.Summary => const Color(0xFF6859A7),
FieldType.Time => const Color(0xFFFDEDA7),
FieldType.Translate => const Color(0xFF6859A7),
- FieldType.Media => const Color(0xFFBE9090),
+ FieldType.Media => const Color(0xFF91EBF5),
_ => throw UnimplementedError(),
};
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart
index 904cc07efb..e1ea22a6eb 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart
@@ -149,6 +149,7 @@ class DesktopAppearance extends BaseAppearance {
borderColor: theme.borderColor,
scrollbarColor: theme.scrollbarColor,
scrollbarHoverColor: theme.scrollbarHoverColor,
+ lightIconColor: theme.lightIconColor,
),
],
);
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart
index b1ea4fa789..0f6a42b563 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart
@@ -278,6 +278,7 @@ class MobileAppearance extends BaseAppearance {
borderColor: theme.borderColor,
scrollbarColor: theme.scrollbarColor,
scrollbarHoverColor: theme.scrollbarHoverColor,
+ lightIconColor: theme.lightIconColor,
),
ToolbarColorExtension.fromBrightness(brightness),
],
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart
index 651f50756e..541b92a497 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart
@@ -556,6 +556,7 @@ Future<void> showCustomConfirmDialog({
required String description,
required Widget Function(BuildContext) builder,
VoidCallback? onConfirm,
+ VoidCallback? onCancel,
String? confirmLabel,
ConfirmPopupStyle style = ConfirmPopupStyle.onlyOk,
bool closeOnConfirm = true,
@@ -573,7 +574,9 @@ Future<void> showCustomConfirmDialog({
title: title,
description: description,
onConfirm: () => onConfirm?.call(),
+ onCancel: onCancel,
confirmLabel: confirmLabel,
+ confirmButtonColor: Theme.of(context).colorScheme.primary,
style: style,
closeOnAction: closeOnConfirm,
child: builder(context),
diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/colorscheme.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/colorscheme.dart
index 0155e73240..9cd3a06313 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/colorscheme.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/colorscheme.dart
@@ -89,6 +89,7 @@ class FlowyColorScheme {
required this.borderColor,
required this.scrollbarColor,
required this.scrollbarHoverColor,
+ required this.lightIconColor,
});
final Color surface;
@@ -152,6 +153,8 @@ class FlowyColorScheme {
final Color scrollbarColor;
final Color scrollbarHoverColor;
+ final Color lightIconColor;
+
factory FlowyColorScheme.fromJson(Map<String, dynamic> json) =>
_$FlowyColorSchemeFromJson(json);
diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/dandelion.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/dandelion.dart
index ddb64c70ec..ce01205129 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/dandelion.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/dandelion.dart
@@ -85,6 +85,8 @@ class DandelionColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.lightBorderColor,
scrollbarColor: const Color(0x3F171717),
scrollbarHoverColor: const Color(0x7F171717),
+ lightIconColor: const Color(0xFF8F959E),
+
);
const DandelionColorScheme.dark()
@@ -142,5 +144,7 @@ class DandelionColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.darkBorderColor,
scrollbarColor: const Color(0x40FFFFFF),
scrollbarHoverColor: const Color(0x80FFFFFF),
+ lightIconColor: const Color(0xFF8F959E),
+
);
}
diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/default_colorscheme.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/default_colorscheme.dart
index 20d953de47..f829d3a67e 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/default_colorscheme.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/default_colorscheme.dart
@@ -82,6 +82,7 @@ class DefaultColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.lightBorderColor,
scrollbarColor: const Color(0x3F171717),
scrollbarHoverColor: const Color(0x7F171717),
+ lightIconColor: const Color(0xFF8F959E),
);
const DefaultColorScheme.dark()
@@ -139,5 +140,6 @@ class DefaultColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.darkBorderColor,
scrollbarColor: const Color(0x40FFFFFF),
scrollbarHoverColor: const Color(0x80FFFFFF),
+ lightIconColor: const Color(0xFF8F959E),
);
}
diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lavender.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lavender.dart
index ddadc7302e..97ff5221de 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lavender.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lavender.dart
@@ -81,6 +81,7 @@ class LavenderColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.lightBorderColor,
scrollbarColor: const Color(0x3F171717),
scrollbarHoverColor: const Color(0x7F171717),
+ lightIconColor: const Color(0xFF8F959E),
);
const LavenderColorScheme.dark()
@@ -138,5 +139,6 @@ class LavenderColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.darkBorderColor,
scrollbarColor: const Color(0x40FFFFFF),
scrollbarHoverColor: const Color(0x80FFFFFF),
+ lightIconColor: const Color(0xFF8F959E),
);
}
diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lemonade.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lemonade.dart
index 2bb6cb68c5..5d9ff8b97c 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lemonade.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/colorscheme/lemonade.dart
@@ -87,6 +87,7 @@ class LemonadeColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.lightBorderColor,
scrollbarColor: const Color(0x3F171717),
scrollbarHoverColor: const Color(0x7F171717),
+ lightIconColor: const Color(0xFF8F959E),
);
const LemonadeColorScheme.dark()
@@ -144,5 +145,6 @@ class LemonadeColorScheme extends FlowyColorScheme {
borderColor: ColorSchemeConstants.darkBorderColor,
scrollbarColor: const Color(0x40FFFFFF),
scrollbarHoverColor: const Color(0x80FFFFFF),
+ lightIconColor: const Color(0xFF8F959E),
);
}
diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension.dart
index 49195f2011..bb44933990 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension.dart
@@ -41,6 +41,7 @@ class AFThemeExtension extends ThemeExtension<AFThemeExtension> {
required this.borderColor,
required this.scrollbarColor,
required this.scrollbarHoverColor,
+ required this.lightIconColor,
});
final Color? warning;
@@ -85,6 +86,8 @@ class AFThemeExtension extends ThemeExtension<AFThemeExtension> {
final Color scrollbarColor;
final Color scrollbarHoverColor;
+ final Color lightIconColor;
+
@override
AFThemeExtension copyWith({
Color? warning,
@@ -119,6 +122,7 @@ class AFThemeExtension extends ThemeExtension<AFThemeExtension> {
Color? borderColor,
Color? scrollbarColor,
Color? scrollbarHoverColor,
+ Color? lightIconColor,
}) =>
AFThemeExtension(
warning: warning ?? this.warning,
@@ -154,6 +158,7 @@ class AFThemeExtension extends ThemeExtension<AFThemeExtension> {
borderColor: borderColor ?? this.borderColor,
scrollbarColor: scrollbarColor ?? this.scrollbarColor,
scrollbarHoverColor: scrollbarHoverColor ?? this.scrollbarHoverColor,
+ lightIconColor: lightIconColor ?? this.lightIconColor,
);
@override
@@ -209,6 +214,7 @@ class AFThemeExtension extends ThemeExtension<AFThemeExtension> {
scrollbarColor: Color.lerp(scrollbarColor, other.scrollbarColor, t)!,
scrollbarHoverColor:
Color.lerp(scrollbarHoverColor, other.scrollbarHoverColor, t)!,
+ lightIconColor: Color.lerp(lightIconColor, other.lightIconColor, t)!,
);
}
}
diff --git a/frontend/appflowy_flutter/test/widget_test/test_material_app.dart b/frontend/appflowy_flutter/test/widget_test/test_material_app.dart
index be7b2001f0..ecb06b97e2 100644
--- a/frontend/appflowy_flutter/test/widget_test/test_material_app.dart
+++ b/frontend/appflowy_flutter/test/widget_test/test_material_app.dart
@@ -61,6 +61,7 @@ class WidgetTestApp extends StatelessWidget {
borderColor: Colors.transparent,
scrollbarColor: Colors.transparent,
scrollbarHoverColor: Colors.transparent,
+ lightIconColor: Colors.transparent,
),
],
),
diff --git a/frontend/resources/flowy_icons/16x/add_thin.svg b/frontend/resources/flowy_icons/16x/add_thin.svg
new file mode 100644
index 0000000000..56520cf3cf
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/add_thin.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="#000000" id="Plus-Light--Streamline-Phosphor.svg" height="16" width="16"><desc>Plus Light Streamline Icon: https://streamlinehq.com</desc><path d="M14.85 7.5c0 0.2591015625 -0.210046875 0.4691484375 -0.4691484375 0.4691484375H7.9691484374999995v6.411703125c0 0.3611484375 -0.39095507812499997 0.5868691406250001 -0.70372265625 0.406294921875 -0.145154296875 -0.083806640625 -0.23457421875 -0.2386875 -0.23457421875 -0.406294921875V7.9691484374999995H0.6191484375c-0.3611484375 0 -0.5868691406250001 -0.39095507812499997 -0.406294921875 -0.70372265625 0.083806640625 -0.145154296875 0.238681640625 -0.23457421875 0.406294921875 -0.23457421875h6.411703125V0.6191484375c0 -0.3611484375 0.39095507812499997 -0.5868691406250001 0.70372265625 -0.406294921875 0.145154296875 0.083806640625 0.23457421875 0.238681640625 0.23457421875 0.406294921875v6.411703125h6.411703125c0.259095703125 0.00001171875 0.4691484375 0.21005273437500002 0.4691484375 0.4691484375Z" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/cover.svg b/frontend/resources/flowy_icons/16x/cover.svg
new file mode 100644
index 0000000000..84749fbc30
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/cover.svg
@@ -0,0 +1,12 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3228_21314)">
+<path d="M1.16284 7.99979C1.16284 4.77666 1.16284 3.16516 2.16409 2.16385C3.1654 1.1626 4.7769 1.1626 8.00003 1.1626C11.2231 1.1626 12.8347 1.1626 13.8359 2.16385C14.8372 3.16516 14.8372 4.77666 14.8372 7.99979C14.8372 11.2228 14.8372 12.8344 13.8359 13.8357C12.8347 14.837 11.2231 14.837 8.00003 14.837C4.7769 14.837 3.1654 14.837 2.16409 13.8357C1.16284 12.8345 1.16284 11.2228 1.16284 7.99979Z" stroke="#171717"/>
+<path d="M9.36743 5.26499C9.36518 6.31762 10.5033 6.97799 11.4161 6.45362C11.8415 6.20918 12.1034 5.75562 12.1023 5.26499C12.1046 4.21231 10.9664 3.55199 10.0537 4.07637C9.62825 4.32074 9.36637 4.77437 9.36743 5.26499Z" stroke="#171717"/>
+<path d="M1.16284 8.34172L2.3604 7.29385C2.98347 6.74872 3.92253 6.77997 4.5079 7.36535L7.4409 10.2983C7.91072 10.7682 8.6504 10.8323 9.19409 10.4502L9.39797 10.3069C10.1803 9.7571 11.2388 9.82079 11.9495 10.4605L14.1535 12.444" stroke="#171717" stroke-linecap="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3228_21314">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ft_archive.svg b/frontend/resources/flowy_icons/16x/ft_archive.svg
index 2cce4f3e42..64f1b3b039 100644
--- a/frontend/resources/flowy_icons/16x/ft_archive.svg
+++ b/frontend/resources/flowy_icons/16x/ft_archive.svg
@@ -1 +1,11 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" id="Folder-Closed--Streamline-Lucide.svg" height="16" width="16"><desc>Folder Closed Streamline Icon: https://streamlinehq.com</desc><path d="M12.845437500000001 13.1795625C13.583499999999999 13.179499999999999 14.1818125 12.581187499999999 14.1818125 11.8431875V5.1613750000000005C14.1818125 4.4233125 13.583499999999999 3.825 12.845437500000001 3.825H7.566812499999999C7.1126875 3.8294375 6.687374999999999 3.6029375000000003 6.4375625 3.223625L5.896375000000001 2.4218124999999997C5.6491875 2.0465 5.2299375 1.8205 4.7805 1.8204375000000002H2.1545625C1.4164375000000002 1.8204375000000002 0.8181875 2.41875 0.8181875 3.1568125V11.8431875C0.8181875 12.581249999999999 1.4165 13.1795625 2.1545625 13.1795625Z" stroke-width="1"></path><path d="M0.8181875 6.49775H14.1818125" stroke-width="1"></path></svg>
\ No newline at end of file
+<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3449_43627)">
+<path d="M15.1394 7.30103H1.16113" stroke="#666D76" stroke-linecap="round"/>
+<path d="M1.16113 4.47032C1.16113 3.85347 1.16113 3.54508 1.20956 3.28818C1.42295 2.15729 2.30755 1.27268 3.43845 1.05929C3.69535 1.01086 4.00374 1.01086 4.62059 1.01086C4.89084 1.01086 5.02596 1.01086 5.15579 1.023C5.71571 1.07533 6.24675 1.2953 6.67966 1.65423C6.7801 1.73741 6.87561 1.83299 7.0667 2.02408L7.45131 2.40869C8.02152 2.97883 8.30659 3.26391 8.64795 3.45385C8.83547 3.55818 9.03448 3.64059 9.24084 3.69944C9.61651 3.80651 10.0196 3.80651 10.826 3.80651H11.0872C12.927 3.80651 13.8468 3.80651 14.4448 4.34427C14.4998 4.39378 14.5522 4.44611 14.6016 4.50111C15.1394 5.09905 15.1394 6.01892 15.1394 7.85873V9.39781C15.1394 12.0336 15.1394 13.3515 14.3206 14.1703C13.5018 14.9891 12.1838 14.9891 9.54808 14.9891H6.75243C4.11663 14.9891 2.7988 14.9891 1.97993 14.1703C1.16113 13.3515 1.16113 12.0336 1.16113 9.39781V4.47032Z" stroke="#666D76"/>
+</g>
+<defs>
+<clipPath id="clip0_3449_43627">
+<rect width="16" height="16" fill="white" transform="translate(0.150391)"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ft_audio.svg b/frontend/resources/flowy_icons/16x/ft_audio.svg
index 6db8f1c5ff..a7d541d7d0 100644
--- a/frontend/resources/flowy_icons/16x/ft_audio.svg
+++ b/frontend/resources/flowy_icons/16x/ft_audio.svg
@@ -1 +1,5 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" id="File-Audio--Streamline-Lucide.svg" height="16" width="16"><desc>File Audio Streamline Icon: https://streamlinehq.com</desc><path d="M11.8431875 14.1818125H12.177249999999999C12.9153125 14.1818125 13.513625000000001 13.583499999999999 13.513625000000001 12.845437500000001V4.1590625L10.172749999999999 0.8181875H4.159125C3.4210625 0.8181875 2.82275 1.4165 2.82275 2.1545625V4.1590625" stroke-width="1"></path><path d="M9.5045625 0.8181875V3.490875C9.5045625 4.2289375 10.102875000000001 4.82725 10.8409375 4.82725H13.513625000000001" stroke-width="1"></path><path d="M1.486375 12.177249999999999C1.486375 11.1485625 2.6 10.5055625 3.4909375 11.019937500000001C3.904375 11.2586875 4.1590625 11.6998125 4.1590625 12.177249999999999V12.845437500000001C4.1590625 13.8741875 3.0454375000000002 14.517125 2.1545625 14.002749999999999C1.7410625 13.764062500000001 1.486375 13.322875 1.486375 12.845437500000001V10.172749999999999C1.4901875 7.086562499999999 4.8335625 5.1618125 7.5043125 6.70825C8.74075 7.4241875 9.502749999999999 8.744 9.5045625 10.172749999999999V12.845437500000001C9.5045625 13.8741875 8.3909375 14.517125 7.5 14.002749999999999C7.0865 13.764062500000001 6.8318125 13.322875 6.8318125 12.845437500000001V12.177249999999999C6.8318125 11.1485625 7.9454375 10.5055625 8.836375 11.019937500000001C9.249812499999999 11.2586875 9.5045625 11.6998125 9.5045625 12.177249999999999" stroke-width="1"></path></svg>
\ No newline at end of file
+<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M8.20011 11.9042C8.20011 13.5068 6.90092 14.8059 5.29836 14.8059C3.69579 14.8059 2.39661 13.5068 2.39661 11.9042C2.39661 10.3016 3.69579 9.00244 5.29836 9.00244C6.90092 9.00244 8.20011 10.3016 8.20011 11.9042Z" stroke="#666D76"/>
+<path d="M8.20007 11.904V3.19873" stroke="#666D76"/>
+<path d="M11.1864 6.14349L9.27614 5.1883C9.01139 5.05599 8.87901 4.9898 8.7697 4.90618C8.48657 4.68968 8.29295 4.37649 8.22595 4.02637C8.20007 3.89124 8.20007 3.74324 8.20007 3.4473C8.20007 2.7428 8.20007 2.39055 8.28682 2.15112C8.51607 1.51824 9.15045 1.12618 9.81901 1.20418C10.072 1.23368 10.3871 1.39118 11.0171 1.70624L12.9275 2.66143C13.1923 2.7938 13.3246 2.85999 13.4339 2.94355C13.7171 3.16005 13.9107 3.47324 13.9776 3.82337C14.0036 3.95855 14.0036 4.10649 14.0036 4.40249C14.0036 5.10693 14.0036 5.45918 13.9168 5.69862C13.6876 6.33149 13.0531 6.72355 12.3846 6.64562C12.1316 6.61605 11.8166 6.45855 11.1864 6.14349Z" stroke="#666D76" stroke-linecap="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ft_link.svg b/frontend/resources/flowy_icons/16x/ft_link.svg
index 8b836bfadb..f8dd8460b9 100644
--- a/frontend/resources/flowy_icons/16x/ft_link.svg
+++ b/frontend/resources/flowy_icons/16x/ft_link.svg
@@ -1 +1,12 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" id="Link--Streamline-Lucide.svg" height="16" width="16"><desc>Link Streamline Icon: https://streamlinehq.com</desc><path d="M6.25 8.125a3.125 3.125 0 0 0 4.7125 0.3375l1.875 -1.875a3.125 3.125 0 0 0 -4.41875 -4.41875l-1.075 1.06875" stroke-width="1"></path><path d="M8.75 6.875a3.125 3.125 0 0 0 -4.7125 -0.3375l-1.875 1.875a3.125 3.125 0 0 0 4.41875 4.41875l1.06875 -1.06875" stroke-width="1"></path></svg>
\ No newline at end of file
+<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3449_39572)">
+<path d="M9.86652 12.9993L9.31107 13.5548C7.4703 15.3956 4.48593 15.3956 2.64522 13.5548C0.804457 11.7142 0.804457 8.72971 2.64522 6.88901L3.20067 6.3335" stroke="#666D76" stroke-linecap="round"/>
+<path d="M6.53357 9.66645L9.86652 6.3335" stroke="#666D76" stroke-linecap="round"/>
+<path d="M6.53357 3.00048L7.08908 2.44503C8.92979 0.604261 11.9142 0.604261 13.7549 2.44503C15.5956 4.28573 15.5956 7.27011 13.7549 9.11088L13.1994 9.66633" stroke="#666D76" stroke-linecap="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3449_39572">
+<rect width="16" height="16" fill="white" transform="translate(0.200073)"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ft_text.svg b/frontend/resources/flowy_icons/16x/ft_text.svg
index 8be97325f2..0b82109141 100644
--- a/frontend/resources/flowy_icons/16x/ft_text.svg
+++ b/frontend/resources/flowy_icons/16x/ft_text.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" id="File-Text--Streamline-Lucide.svg" height="16" width="16"><desc>File Text Streamline Icon: https://streamlinehq.com</desc><path d="M9.375 1.25H3.75a1.25 1.25 0 0 0 -1.25 1.25v10a1.25 1.25 0 0 0 1.25 1.25h7.5a1.25 1.25 0 0 0 1.25 -1.25V4.375Z" stroke-width="1"></path><path d="M8.75 1.25v2.5a1.25 1.25 0 0 0 1.25 1.25h2.5" stroke-width="1"></path><path d="M6.25 5.625H5" stroke-width="1"></path><path d="M10 8.125H5" stroke-width="1"></path><path d="M10 10.625H5" stroke-width="1"></path></svg>
\ No newline at end of file
+<svg viewBox="-0.5 -0.5 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" id="Document-Text--Streamline-Solar-Ar.svg" height="16" width="16"><desc>Document Text Streamline Icon: https://streamlinehq.com</desc><path d="M1.875 6.25c0 -2.357025 0 -3.53553125 0.73223125 -4.26776875C3.33946875 1.25 4.517975 1.25 6.875 1.25h1.25c2.3569999999999998 0 3.5355625 0 4.26775 0.73223125C13.125 2.71446875 13.125 3.8929750000000003 13.125 6.25v2.5c0 2.3569999999999998 0 3.5355625 -0.73225 4.26775C11.660562500000001 13.75 10.482 13.75 8.125 13.75h-1.25c-2.357025 0 -3.53553125 0 -4.26776875 -0.73225C1.875 12.285562500000001 1.875 11.107 1.875 8.75v-2.5Z" stroke="#000000" stroke-width="1"></path><path d="M5 7.5h5" stroke="#000000" stroke-linecap="round" stroke-width="1"></path><path d="M5 5h5" stroke="#000000" stroke-linecap="round" stroke-width="1"></path><path d="M5 10h3.125" stroke="#000000" stroke-linecap="round" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/ft_video.svg b/frontend/resources/flowy_icons/16x/ft_video.svg
index 7d15bf78b8..1065c0ea08 100644
--- a/frontend/resources/flowy_icons/16x/ft_video.svg
+++ b/frontend/resources/flowy_icons/16x/ft_video.svg
@@ -1 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" id="Video--Streamline-Lucide.svg" height="16" width="16"><desc>Video Streamline Icon: https://streamlinehq.com</desc><path d="m10 8.125 3.264375 2.17625a0.3125 0.3125 0 0 0 0.48562500000000003 -0.26V4.91875a0.3125 0.3125 0 0 0 -0.47 -0.27L10 6.5625" stroke-width="1"></path><path d="M2.5 3.75h6.25s1.25 0 1.25 1.25v5s0 1.25 -1.25 1.25H2.5s-1.25 0 -1.25 -1.25V5s0 -1.25 1.25 -1.25" stroke-width="1"></path></svg>
\ No newline at end of file
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M1.16284 7.65815C1.16284 5.41046 1.16284 4.28659 1.78359 3.53015C1.89728 3.39165 2.02422 3.26471 2.16272 3.15102C2.91915 2.53027 4.04303 2.53027 6.29072 2.53027C8.53847 2.53027 9.66228 2.53027 10.4188 3.15102C10.5572 3.26471 10.6842 3.39165 10.7978 3.53015C11.4187 4.28659 11.4187 5.41046 11.4187 7.65815V8.3419C11.4187 10.5896 11.4187 11.7135 10.7978 12.4699C10.6842 12.6084 10.5572 12.7353 10.4188 12.849C9.66228 13.4698 8.53847 13.4698 6.29072 13.4698C4.04303 13.4698 2.91915 13.4698 2.16272 12.849C2.02422 12.7353 1.89728 12.6084 1.78359 12.4699C1.16284 11.7135 1.16284 10.5896 1.16284 8.3419V7.65815Z" stroke="#666D76"/>
+<path d="M11.4186 6.29102L11.8688 6.06595C13.1991 5.40077 13.8645 5.06814 14.3508 5.36877C14.8372 5.66933 14.8372 6.41308 14.8372 7.90058V8.10008C14.8372 9.58758 14.8372 10.3313 14.3508 10.6319C13.8645 10.9325 13.1991 10.5999 11.8688 9.9347L11.4186 9.70964V6.29102Z" stroke="#666D76"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/media.svg b/frontend/resources/flowy_icons/16x/media.svg
index 74356ae6dc..a56903e5da 100644
--- a/frontend/resources/flowy_icons/16x/media.svg
+++ b/frontend/resources/flowy_icons/16x/media.svg
@@ -1 +1,3 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" id="Paperclip--Streamline-Lucide.svg" height="16" width="16"><desc>Paperclip Streamline Icon: https://streamlinehq.com</desc><path d="m13.4 6.90625 -5.7437499999999995 5.7437499999999995a3.75 3.75 0 0 1 -5.30625 -5.30625l5.35625 -5.35625A2.5 2.5 0 1 1 11.25 5.525l-5.36875 5.35625a1.25 1.25 0 0 1 -1.76875 -1.76875l5.30625 -5.300000000000001" stroke-width="1"></path></svg>
\ No newline at end of file
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M5.44844 11.6292L10.3802 6.90844C10.9724 6.34167 10.9724 5.42273 10.3802 4.85594C9.78812 4.28915 8.82813 4.28915 8.236 4.85594L3.33992 9.54256C2.21489 10.6194 2.21489 12.3654 3.33992 13.4423C4.46494 14.5192 6.28898 14.5192 7.414 13.4423L12.3816 8.68731C14.0395 7.10031 14.0395 4.52726 12.3816 2.94025C10.7236 1.35325 8.03556 1.35325 6.37762 2.94025L2.375 6.77162" stroke="#333333" stroke-linecap="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/open_in_browser.svg b/frontend/resources/flowy_icons/16x/open_in_browser.svg
new file mode 100644
index 0000000000..8c2964aa95
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/open_in_browser.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3228_23979)">
+<path d="M8.68378 7.31604L14.8372 1.1626M14.8372 1.1626H11.1836M14.8372 1.1626V4.81622" stroke="#171717" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M14.8372 7.99979C14.8372 11.2228 14.8372 12.8344 13.8359 13.8357C12.8347 14.837 11.2231 14.837 8.00003 14.837C4.7769 14.837 3.1654 14.837 2.16409 13.8357C1.16284 12.8345 1.16284 11.2228 1.16284 7.99979C1.16284 4.77666 1.16284 3.16516 2.16409 2.16385C3.1654 1.1626 4.7769 1.1626 8.00003 1.1626" stroke="#171717" stroke-linecap="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3228_23979">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/rename.svg b/frontend/resources/flowy_icons/16x/rename.svg
new file mode 100644
index 0000000000..6a820cf5fc
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/rename.svg
@@ -0,0 +1,5 @@
+<svg width="14" height="16" viewBox="0 0 14 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7.83958 2.40031L2.36624 8.19364C2.15958 8.41364 1.95958 8.84697 1.91958 9.14697L1.67291 11.307C1.58624 12.087 2.14624 12.6203 2.91958 12.487L5.06624 12.1203C5.36624 12.067 5.78624 11.847 5.99291 11.6203L11.4662 5.82697C12.4129 4.82697 12.8396 3.68697 11.3662 2.29364C9.89958 0.913641 8.78624 1.40031 7.83958 2.40031Z" stroke="#171717" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M6.92706 3.3667C7.21373 5.2067 8.70706 6.61337 10.5604 6.80003" stroke="#171717" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M1 14.6665H13" stroke="#171717" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/save_as.svg b/frontend/resources/flowy_icons/16x/save_as.svg
new file mode 100644
index 0000000000..f82938f6db
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/save_as.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3228_20949)">
+<path d="M1.21539 10.2617C1.21539 12.3939 1.21539 13.46 1.87777 14.1223C2.54021 14.7848 3.60627 14.7848 5.73846 14.7848H10.2616C12.3937 14.7848 13.4598 14.7848 14.1222 14.1223C14.7846 13.46 14.7846 12.3938 14.7846 10.2617" stroke="#1F2329" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M7.99999 1.21533V11.0153M7.99999 11.0153L11.0154 7.71727M7.99999 11.0153L4.98462 7.71727" stroke="#1F2329" stroke-linecap="round" stroke-linejoin="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3228_20949">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json
index e1f3f5fb62..8b7b19bbc9 100644
--- a/frontend/resources/translations/en.json
+++ b/frontend/resources/translations/en.json
@@ -1396,8 +1396,8 @@
},
"field": {
"label": "Property",
- "hide": "Hide",
- "show": "Show",
+ "hide": "Hide property",
+ "show": "Show property",
"insertLeft": "Insert left",
"insertRight": "Insert right",
"duplicate": "Duplicate",
@@ -1570,21 +1570,20 @@
"media": {
"rename": "Rename",
"download": "Download",
- "open": "Open",
+ "expand": "Expand",
"delete": "Delete",
"moreFilesHint": "+{}",
- "addFileOrImage": "Add a file, image, or link",
+ "addFileOrImage": "Add file or link",
"attachmentsHint": "{}",
"addFileMobile": "Add file",
- "showFile": "Show 1 file",
- "showFiles": "Show {} files",
- "hideFile": "Hide 1 file",
- "hideFiles": "Hide {} files",
+ "extraCount": "+{}",
"deleteFileDescription": "Are you sure you want to delete this file? This action is irreversible.",
- "hideFileNames": "Hide file names",
- "downloadSuccess": "Successfully saved file",
+ "showFileNames": "Show file name",
+ "downloadSuccess": "File downloaded",
"downloadFailedToken": "Failed to download file, user token unavailable",
- "setAsCover": "Set as cover"
+ "setAsCover": "Set as cover",
+ "openInBrowser": "Open in browser",
+ "embedLink": "Embed file link"
}
},
"document": {
@@ -1813,15 +1812,17 @@
"file": {
"name": "File",
"uploadTab": "Upload",
- "uploadMobile": "Pick from files",
+ "uploadMobile": "Choose a file",
+ "uploadMobileGallery": "From Photo Gallery",
"networkTab": "Embed link",
"placeholderText": "Upload or embed a file",
"placeholderDragging": "Drop the file to upload",
- "dropFileToUpload": "Drop the file to upload",
- "fileUploadHint": "Drop a file here to upload\nor click to browse",
+ "dropFileToUpload": "Drop a file to upload",
+ "fileUploadHint": "Drag & drop a file or click to ",
+ "fileUploadHintSuffix": "Browse",
"networkHint": "Paste a file link",
- "networkUrlInvalid": "Invalid URL, please correct the URL and try again",
- "networkAction": "Embed file link",
+ "networkUrlInvalid": "Invalid URL. Check the URL and try again.",
+ "networkAction": "Embed",
"fileTooBigError": "File size is too big, please upload a file with size less than 10MB",
"renameFile": {
"title": "Rename file",
@@ -2819,4 +2820,4 @@
"many": "{count} members",
"other": "{count} members"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs
index 293a5157c2..a56d0faad2 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs
@@ -160,7 +160,7 @@ pub fn make_test_grid() -> DatabaseData {
},
FieldType::Media => {
let type_option = MediaTypeOption {
- hide_file_names: false,
+ hide_file_names: true,
};
let media_field = FieldBuilder::new(field_type, type_option)