mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: update main.dart
This commit is contained in:
parent
76cdb689fb
commit
862ba3173a
@ -1,13 +1,13 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:example/plugin/code_block_node_widget.dart';
|
|
||||||
import 'package:example/plugin/horizontal_rule_node_widget.dart';
|
|
||||||
import 'package:example/plugin/tex_block_node_widget.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:example/plugin/code_block_node_widget.dart';
|
||||||
|
import 'package:example/plugin/horizontal_rule_node_widget.dart';
|
||||||
|
import 'package:example/plugin/tex_block_node_widget.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
@ -26,22 +26,16 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return const MaterialApp(
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: [
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
GlobalWidgetsLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
AppFlowyEditorLocalizations.delegate,
|
AppFlowyEditorLocalizations.delegate,
|
||||||
],
|
],
|
||||||
supportedLocales: const [Locale('en', 'US')],
|
supportedLocales: [Locale('en', 'US')],
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
home: MyHomePage(title: 'AppFlowyEditor Example'),
|
||||||
primarySwatch: Colors.blue,
|
|
||||||
// extensions: [HeadingPluginStyle.light],
|
|
||||||
),
|
|
||||||
darkTheme: ThemeData.dark(),
|
|
||||||
themeMode: ThemeMode.dark,
|
|
||||||
home: const MyHomePage(title: 'AppFlowyEditor Example'),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,20 +59,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: _buildEditor(context),
|
body: _buildEditor(context),
|
||||||
// body: Center(
|
|
||||||
// child: ContextMenu(editorState: EditorState.empty(), items: [
|
|
||||||
// [
|
|
||||||
// ContextMenuItem(name: 'ABCDEFGHIJKLM', onPressed: (editorState) {}),
|
|
||||||
// ContextMenuItem(name: 'A', onPressed: (editorState) {}),
|
|
||||||
// ContextMenuItem(name: 'A', onPressed: (editorState) {})
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// ContextMenuItem(name: 'B', onPressed: (editorState) {}),
|
|
||||||
// ContextMenuItem(name: 'B', onPressed: (editorState) {}),
|
|
||||||
// ContextMenuItem(name: 'B', onPressed: (editorState) {})
|
|
||||||
// ]
|
|
||||||
// ]),
|
|
||||||
// ),
|
|
||||||
floatingActionButton: _buildExpandableFab(),
|
floatingActionButton: _buildExpandableFab(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -92,10 +72,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
rootBundle.loadString('assets/example.json'),
|
rootBundle.loadString('assets/example.json'),
|
||||||
);
|
);
|
||||||
} else if (_pageIndex == 1) {
|
} else if (_pageIndex == 1) {
|
||||||
return _buildEditorWithJsonString(
|
|
||||||
rootBundle.loadString('assets/big_document.json'),
|
|
||||||
);
|
|
||||||
} else if (_pageIndex == 2) {
|
|
||||||
return _buildEditorWithJsonString(
|
return _buildEditorWithJsonString(
|
||||||
Future.value(
|
Future.value(
|
||||||
jsonEncode(EditorState.empty().document.toJson()),
|
jsonEncode(EditorState.empty().document.toJson()),
|
||||||
@ -126,32 +102,19 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
_editorState!.transactionStream.listen((event) {
|
_editorState!.transactionStream.listen((event) {
|
||||||
debugPrint('Transaction: ${event.toJson()}');
|
debugPrint('Transaction: ${event.toJson()}');
|
||||||
});
|
});
|
||||||
final themeData = darkMode
|
final themeData = Theme.of(context).copyWith(extensions: [
|
||||||
? ThemeData.dark().copyWith(extensions: [
|
if (darkMode) ...darkEditorStyleExtension,
|
||||||
HeadingPluginStyle.dark,
|
if (darkMode) ...darkPlguinStyleExtension,
|
||||||
CheckboxPluginStyle.dark,
|
if (!darkMode) ...lightEditorStyleExtension,
|
||||||
NumberListPluginStyle.dark,
|
if (!darkMode) ...lightPlguinStyleExtension,
|
||||||
QuotedTextPluginStyle.dark,
|
]);
|
||||||
BulletedListPluginStyle.dark,
|
|
||||||
EditorStyle.dark,
|
|
||||||
])
|
|
||||||
: ThemeData.light().copyWith(
|
|
||||||
extensions: [
|
|
||||||
HeadingPluginStyle.light,
|
|
||||||
CheckboxPluginStyle.light,
|
|
||||||
NumberListPluginStyle.light,
|
|
||||||
QuotedTextPluginStyle.light,
|
|
||||||
BulletedListPluginStyle.light,
|
|
||||||
EditorStyle.light,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
return Container(
|
return Container(
|
||||||
color: darkMode ? Colors.black : Colors.white,
|
color: darkMode ? Colors.black : Colors.white,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: AppFlowyEditor(
|
child: AppFlowyEditor(
|
||||||
editorState: _editorState!,
|
editorState: _editorState!,
|
||||||
themeData: themeData,
|
|
||||||
editable: true,
|
editable: true,
|
||||||
|
themeData: themeData,
|
||||||
customBuilders: {
|
customBuilders: {
|
||||||
'text/code_block': CodeBlockNodeWidgetBuilder(),
|
'text/code_block': CodeBlockNodeWidgetBuilder(),
|
||||||
'tex': TeXBlockNodeWidgetBuidler(),
|
'tex': TeXBlockNodeWidgetBuidler(),
|
||||||
@ -190,10 +153,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
icon: const Icon(Icons.abc),
|
icon: const Icon(Icons.abc),
|
||||||
onPressed: () => _switchToPage(1),
|
onPressed: () => _switchToPage(1),
|
||||||
),
|
),
|
||||||
ActionButton(
|
|
||||||
icon: const Icon(Icons.abc),
|
|
||||||
onPressed: () => _switchToPage(2),
|
|
||||||
),
|
|
||||||
ActionButton(
|
ActionButton(
|
||||||
icon: const Icon(Icons.print),
|
icon: const Icon(Icons.print),
|
||||||
onPressed: () => _exportDocument(_editorState!),
|
onPressed: () => _exportDocument(_editorState!),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user