mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-11-10 10:18:57 +03:00
feat: add empty document entry in example
This commit is contained in:
parent
58d656d9f4
commit
eb7c65aa8b
@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:collection';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:example/expandable_floating_action_button.dart';
|
import 'package:example/expandable_floating_action_button.dart';
|
||||||
@ -80,12 +81,21 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
icon: const Icon(Icons.note_add),
|
icon: const Icon(Icons.note_add),
|
||||||
),
|
),
|
||||||
ActionButton(
|
ActionButton(
|
||||||
|
icon: const Icon(Icons.document_scanner),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (page == 1) return;
|
if (page == 1) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
page = 1;
|
page = 1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
ActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (page == 2) return;
|
||||||
|
setState(() {
|
||||||
|
page = 2;
|
||||||
|
});
|
||||||
|
},
|
||||||
icon: const Icon(Icons.text_fields),
|
icon: const Icon(Icons.text_fields),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -97,11 +107,41 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
return _buildFlowyEditor();
|
return _buildFlowyEditor();
|
||||||
} else if (page == 1) {
|
} else if (page == 1) {
|
||||||
|
return _buildFlowyEditorWithEmptyDocument();
|
||||||
|
} else if (page == 2) {
|
||||||
return _buildTextField();
|
return _buildTextField();
|
||||||
}
|
}
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildFlowyEditorWithEmptyDocument() {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.only(left: 20, right: 20),
|
||||||
|
child: FlowyEditor(
|
||||||
|
key: editorKey,
|
||||||
|
editorState: EditorState(
|
||||||
|
document: StateTree(
|
||||||
|
root: Node(
|
||||||
|
type: 'editor',
|
||||||
|
children: LinkedList()
|
||||||
|
..add(
|
||||||
|
TextNode.empty()
|
||||||
|
..delta = Delta(
|
||||||
|
[TextInsert('')],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
attributes: {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
keyEventHandlers: const [],
|
||||||
|
customBuilders: {
|
||||||
|
'image': ImageNodeBuilder(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFlowyEditor() {
|
Widget _buildFlowyEditor() {
|
||||||
return FutureBuilder<String>(
|
return FutureBuilder<String>(
|
||||||
future: rootBundle.loadString('assets/example.json'),
|
future: rootBundle.loadString('assets/example.json'),
|
||||||
|
Loading…
Reference in New Issue
Block a user