mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 22:57:12 -04:00
fix: legacy bugs on mobile (#4927)
This commit is contained in:
parent
fdc105a3e8
commit
7375349626
15 changed files with 286 additions and 85 deletions
|
@ -1,8 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||
import 'package:appflowy/plugins/document/application/doc_bloc.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/banner.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/editor_notification.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/editor_page.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
|
||||
|
@ -15,24 +14,9 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
|||
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
enum EditorNotificationType {
|
||||
undo,
|
||||
redo,
|
||||
}
|
||||
|
||||
class EditorNotification extends Notification {
|
||||
const EditorNotification({
|
||||
required this.type,
|
||||
});
|
||||
|
||||
EditorNotification.undo() : type = EditorNotificationType.undo;
|
||||
EditorNotification.redo() : type = EditorNotificationType.redo;
|
||||
|
||||
final EditorNotificationType type;
|
||||
}
|
||||
|
||||
class DocumentPage extends StatefulWidget {
|
||||
const DocumentPage({
|
||||
super.key,
|
||||
|
@ -50,12 +34,23 @@ class DocumentPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _DocumentPageState extends State<DocumentPage> {
|
||||
EditorState? editorState;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// The appflowy editor use Intl as localization, set the default language as fallback.
|
||||
Intl.defaultLocale = 'en_US';
|
||||
|
||||
EditorNotification.addListener(_onEditorNotification);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
EditorNotification.removeListener(_onEditorNotification);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -75,6 +70,7 @@ class _DocumentPageState extends State<DocumentPage> {
|
|||
}
|
||||
|
||||
final editorState = state.editorState;
|
||||
this.editorState = editorState;
|
||||
final error = state.error;
|
||||
if (error != null || editorState == null) {
|
||||
Log.error(error);
|
||||
|
@ -149,20 +145,19 @@ class _DocumentPageState extends State<DocumentPage> {
|
|||
);
|
||||
}
|
||||
|
||||
// Future<void> _exportPage(DocumentDataPB data) async {
|
||||
// final picker = getIt<FilePickerService>();
|
||||
// final dir = await picker.getDirectoryPath();
|
||||
// if (dir == null) {
|
||||
// return;
|
||||
// }
|
||||
// final path = p.join(dir, '${documentBloc.view.name}.json');
|
||||
// const encoder = JsonEncoder.withIndent(' ');
|
||||
// final json = encoder.convert(data.toProto3Json());
|
||||
// await File(path).writeAsString(json.base64.base64);
|
||||
// if (mounted) {
|
||||
// showSnackBarMessage(context, 'Export success to $path');
|
||||
// }
|
||||
// }
|
||||
void _onEditorNotification(EditorNotificationType type) {
|
||||
final editorState = this.editorState;
|
||||
if (editorState == null) {
|
||||
return;
|
||||
}
|
||||
if (type == EditorNotificationType.undo) {
|
||||
undoCommand.execute(editorState);
|
||||
} else if (type == EditorNotificationType.redo) {
|
||||
redoCommand.execute(editorState);
|
||||
} else if (type == EditorNotificationType.exitEditing) {
|
||||
editorState.selection = null;
|
||||
}
|
||||
}
|
||||
|
||||
void _onNotificationAction(
|
||||
BuildContext context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue