improve code editor

This commit is contained in:
2025-01-22 22:02:16 +08:00
parent 87f0f5bb55
commit 8e2520f8e8
2 changed files with 7 additions and 4 deletions

View File

@@ -55,7 +55,7 @@ class _CodeEditorState extends State<CodeEditor> {
Widget buildLineNumbers() { Widget buildLineNumbers() {
return SizedBox( return SizedBox(
width: 32, width: 36,
child: Column( child: Column(
children: [ children: [
for (var i = 1; i <= lineCount; i++) for (var i = 1; i <= lineCount; i++)

View File

@@ -298,10 +298,10 @@ class _BodyState extends State<_Body> {
// //
} }
} }
context.to(() => _EditFilePage(source.filePath)).then((value) async { context.to(() => _EditFilePage(source.filePath, () async {
await ComicSource.reload(); await ComicSource.reload();
setState(() {}); setState(() {});
}); }));
} }
static Future<void> update(ComicSource source) async { static Future<void> update(ComicSource source) async {
@@ -617,10 +617,12 @@ void _addAllPagesWithComicSource(ComicSource source) {
} }
class _EditFilePage extends StatefulWidget { class _EditFilePage extends StatefulWidget {
const _EditFilePage(this.path); const _EditFilePage(this.path, this.onExit);
final String path; final String path;
final void Function() onExit;
@override @override
State<_EditFilePage> createState() => __EditFilePageState(); State<_EditFilePage> createState() => __EditFilePageState();
} }
@@ -637,6 +639,7 @@ class __EditFilePageState extends State<_EditFilePage> {
@override @override
void dispose() { void dispose() {
File(widget.path).writeAsStringSync(current); File(widget.path).writeAsStringSync(current);
widget.onExit();
super.dispose(); super.dispose();
} }