|
|
|
@ -9,7 +9,7 @@ import 'package:flutter/foundation.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
|
import 'package:flutter_quill/extensions.dart'; |
|
|
|
|
import 'package:flutter_quill/flutter_quill.dart' hide QuillText; |
|
|
|
|
import 'package:flutter_quill/flutter_quill.dart' hide Text; |
|
|
|
|
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart'; |
|
|
|
|
import 'package:path/path.dart' as path; |
|
|
|
|
import 'package:path_provider/path_provider.dart'; |
|
|
|
@ -31,6 +31,7 @@ class HomePage extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
class _HomePageState extends State<HomePage> { |
|
|
|
|
late final QuillController _controller; |
|
|
|
|
late final Future<void> _loadDocumentFromAssetsFuture; |
|
|
|
|
final FocusNode _focusNode = FocusNode(); |
|
|
|
|
Timer? _selectAllTimer; |
|
|
|
|
_SelectionType _selectionType = _SelectionType.none; |
|
|
|
@ -46,7 +47,7 @@ class _HomePageState extends State<HomePage> { |
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
_loadFromAssets(); |
|
|
|
|
_loadDocumentFromAssetsFuture = _loadFromAssets(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Future<void> _loadFromAssets() async { |
|
|
|
@ -55,29 +56,29 @@ class _HomePageState extends State<HomePage> { |
|
|
|
|
? 'assets/sample_data_nomedia.json' |
|
|
|
|
: 'assets/sample_data.json'); |
|
|
|
|
final doc = Document.fromJson(jsonDecode(result)); |
|
|
|
|
setState(() { |
|
|
|
|
_controller = QuillController( |
|
|
|
|
document: doc, |
|
|
|
|
selection: const TextSelection.collapsed(offset: 0), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} catch (error) { |
|
|
|
|
final doc = Document()..insert(0, 'Empty asset'); |
|
|
|
|
setState(() { |
|
|
|
|
_controller = QuillController( |
|
|
|
|
document: doc, |
|
|
|
|
selection: const TextSelection.collapsed(offset: 0), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
if (_controller == null) { |
|
|
|
|
return const Scaffold(body: Center(child: Text('Loading...'))); |
|
|
|
|
return FutureBuilder( |
|
|
|
|
future: _loadDocumentFromAssetsFuture, |
|
|
|
|
builder: (context, snapshot) { |
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
|
|
return const Scaffold( |
|
|
|
|
body: Center(child: CircularProgressIndicator.adaptive()), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
|
appBar: AppBar( |
|
|
|
|
backgroundColor: Colors.grey.shade800, |
|
|
|
@ -109,13 +110,15 @@ class _HomePageState extends State<HomePage> { |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
drawer: Container( |
|
|
|
|
constraints: |
|
|
|
|
BoxConstraints(maxWidth: MediaQuery.sizeOf(context).width * 0.7), |
|
|
|
|
constraints: BoxConstraints( |
|
|
|
|
maxWidth: MediaQuery.sizeOf(context).width * 0.7), |
|
|
|
|
color: Colors.grey.shade800, |
|
|
|
|
child: _buildMenuBar(context), |
|
|
|
|
), |
|
|
|
|
body: _buildWelcomeEditor(context), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool _onTripleClickSelection() { |
|
|
|
|