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.

fix: mobile file upload menu (#6786)

Mathias Mogensen76009613feae
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_block_component.dart
index 94a4361dda..7077352c59 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_block_component.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_block_component.dart
@@ -160,8 +160,9 @@ class FileBlockComponentState extends State<FileBlockComponent>
RenderBox? get _renderBox => context.findRenderObject() as RenderBox?;
- late EditorDropManagerState dropManagerState =
- context.read<EditorDropManagerState>();
+ late EditorDropManagerState? dropManagerState = UniversalPlatform.isMobile
+ ? null
+ : context.read<EditorDropManagerState>();
final fileKey = GlobalKey();
final showActionsNotifier = ValueNotifier<bool>(false);
@@ -176,7 +177,9 @@ class FileBlockComponentState extends State<FileBlockComponent>
@override
void didChangeDependencies() {
- dropManagerState = context.read<EditorDropManagerState>();
+ if (!UniversalPlatform.isMobile) {
+ dropManagerState = context.read<EditorDropManagerState>();
+ }
super.didChangeDependencies();
}
@@ -240,17 +243,17 @@ class FileBlockComponentState extends State<FileBlockComponent>
if (url == null || url.isEmpty) {
child = DropTarget(
onDragEntered: (_) {
- if (dropManagerState.isDropEnabled) {
+ if (dropManagerState?.isDropEnabled == true) {
setState(() => isDragging = true);
}
},
onDragExited: (_) {
- if (dropManagerState.isDropEnabled) {
+ if (dropManagerState?.isDropEnabled == true) {
setState(() => isDragging = false);
}
},
onDragDone: (details) {
- if (dropManagerState.isDropEnabled) {
+ if (dropManagerState?.isDropEnabled == true) {
insertFileFromLocal(details.files);
}
},
@@ -263,8 +266,8 @@ class FileBlockComponentState extends State<FileBlockComponent>
minHeight: 80,
),
clickHandler: PopoverClickHandler.gestureDetector,
- onOpen: () => dropManagerState.add(FileBlockKeys.type),
- onClose: () => dropManagerState.remove(FileBlockKeys.type),
+ onOpen: () => dropManagerState?.add(FileBlockKeys.type),
+ onClose: () => dropManagerState?.remove(FileBlockKeys.type),
popupBuilder: (_) => FileUploadMenu(
onInsertLocalFile: insertFileFromLocal,
onInsertNetworkFile: insertNetworkFile,
@@ -342,7 +345,7 @@ class FileBlockComponentState extends State<FileBlockComponent>
void _openMenu() {
if (UniversalPlatform.isDesktopOrWeb) {
controller.show();
- dropManagerState.add(FileBlockKeys.type);
+ dropManagerState?.add(FileBlockKeys.type);
} else {
showUploadFileMobileMenu();
}
@@ -502,7 +505,7 @@ class FileBlockComponentState extends State<FileBlockComponent>
}
// Remove the file block from the drop state manager
- dropManagerState.remove(FileBlockKeys.type);
+ dropManagerState?.remove(FileBlockKeys.type);
final transaction = editorState.transaction;
transaction.updateNode(widget.node, {
@@ -524,7 +527,7 @@ class FileBlockComponentState extends State<FileBlockComponent>
}
// Remove the file block from the drop state manager
- dropManagerState.remove(FileBlockKeys.type);
+ dropManagerState?.remove(FileBlockKeys.type);
final uri = Uri.tryParse(url);
if (uri == null) {
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 af00faee88..75f02f5079 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
@@ -136,10 +136,9 @@ class _FileUploadLocalState extends State<_FileUploadLocal> {
if (UniversalPlatform.isMobile) {
return Padding(
- padding: const EdgeInsets.symmetric(vertical: 12),
+ padding: const EdgeInsets.all(12),
child: SizedBox(
height: 32,
- width: 300,
child: FlowyButton(
backgroundColor: Theme.of(context).colorScheme.primary,
hoverColor: Theme.of(context).colorScheme.primary.withOpacity(0.9),