feat: add more showcases on desktop/mobile platform (#481)

This commit is contained in:
Lucas.Xu 2023-09-20 11:17:39 +08:00 • committed by GitHub
commit 78dd254d1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,7 +51,9 @@ class _HomePageState extends State<HomePage> {
void initState() {
super.initState();
_jsonString = rootBundle.loadString('assets/example.json');
_jsonString = PlatformExtension.isDesktopOrWeb
? rootBundle.loadString('assets/example.json')
: rootBundle.loadString('assets/mobile_example.json');
_widgetBuilder = (context) => Editor(
jsonString: _jsonString,
@ -109,7 +111,9 @@ class _HomePageState extends State<HomePage> {
// AppFlowy Editor Demo
_buildSeparator(context, 'AppFlowy Editor Demo'),
_buildListTile(context, 'With Example.json', () {
final jsonString = rootBundle.loadString('assets/example.json');
final jsonString = PlatformExtension.isDesktopOrWeb
? rootBundle.loadString('assets/example.json')
: rootBundle.loadString('assets/mobile_example.json');
_loadEditor(context, jsonString);
}),
_buildListTile(context, 'With Large Document (10000+ lines)', () {
@ -159,6 +163,16 @@ class _HomePageState extends State<HomePage> {
),
);
}),
_buildListTile(context, 'RTL', () {
final jsonString = rootBundle.loadString(
'assets/arabic_example.json',
);
_loadEditor(
context,
jsonString,
textDirection: TextDirection.rtl,
);
}),
// Encoder Demo
_buildSeparator(context, 'Export To X Demo'),
@ -227,8 +241,9 @@ class _HomePageState extends State<HomePage> {
Future<void> _loadEditor(
BuildContext context,
Future<String> jsonString,
) async {
Future<String> jsonString, {
TextDirection textDirection = TextDirection.ltr,
}) async {
final completer = Completer<void>();
_jsonString = jsonString;
setState(
@ -238,6 +253,7 @@ class _HomePageState extends State<HomePage> {
onEditorStateChange: (editorState) {
_editorState = editorState;
},
textDirection: textDirection,
);
},
);