mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 04:07:53 +08:00
move NoteEditorSelector to its own file
This commit is contained in:
@ -10,6 +10,7 @@ import 'package:gitjournal/editors/checklist_editor.dart';
|
|||||||
import 'package:gitjournal/settings.dart';
|
import 'package:gitjournal/settings.dart';
|
||||||
import 'package:gitjournal/state_container.dart';
|
import 'package:gitjournal/state_container.dart';
|
||||||
import 'package:gitjournal/widgets/folder_selection_dialog.dart';
|
import 'package:gitjournal/widgets/folder_selection_dialog.dart';
|
||||||
|
import 'package:gitjournal/widgets/note_editor_selector.dart';
|
||||||
import 'package:gitjournal/widgets/rename_dialog.dart';
|
import 'package:gitjournal/widgets/rename_dialog.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@ -145,45 +146,10 @@ class NoteEditorState extends State<NoteEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _noteEditorChooserSelected(Note _note) async {
|
void _noteEditorChooserSelected(Note _note) async {
|
||||||
var onEditorChange = (EditorType et) => Navigator.of(context).pop(et);
|
|
||||||
|
|
||||||
var newEditorType = await showDialog<EditorType>(
|
var newEditorType = await showDialog<EditorType>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
var children = <Widget>[
|
return NoteEditorSelector(editorType);
|
||||||
RadioListTile<EditorType>(
|
|
||||||
title: const Text("Markdown Editor"),
|
|
||||||
value: EditorType.Markdown,
|
|
||||||
groupValue: editorType,
|
|
||||||
onChanged: onEditorChange,
|
|
||||||
),
|
|
||||||
RadioListTile<EditorType>(
|
|
||||||
title: const Text("Raw Editor"),
|
|
||||||
value: EditorType.Raw,
|
|
||||||
groupValue: editorType,
|
|
||||||
onChanged: onEditorChange,
|
|
||||||
),
|
|
||||||
RadioListTile<EditorType>(
|
|
||||||
title: const Text("Checklist Editor"),
|
|
||||||
value: EditorType.Checklist,
|
|
||||||
groupValue: editorType,
|
|
||||||
onChanged: onEditorChange,
|
|
||||||
),
|
|
||||||
RadioListTile<EditorType>(
|
|
||||||
title: const Text("Journal Editor"),
|
|
||||||
value: EditorType.Journal,
|
|
||||||
groupValue: editorType,
|
|
||||||
onChanged: onEditorChange,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text("Choose Editor"),
|
|
||||||
content: Column(
|
|
||||||
children: children,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
49
lib/widgets/note_editor_selector.dart
Normal file
49
lib/widgets/note_editor_selector.dart
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gitjournal/screens/note_editor.dart';
|
||||||
|
|
||||||
|
class NoteEditorSelector extends StatelessWidget {
|
||||||
|
final EditorType currentEditor;
|
||||||
|
|
||||||
|
NoteEditorSelector(this.currentEditor);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var onEditorChange = (EditorType et) => Navigator.of(context).pop(et);
|
||||||
|
|
||||||
|
var children = <Widget>[
|
||||||
|
// FIXME: Change this to ListTiles with nice icons
|
||||||
|
RadioListTile<EditorType>(
|
||||||
|
title: const Text("Markdown Editor"),
|
||||||
|
value: EditorType.Markdown,
|
||||||
|
groupValue: currentEditor,
|
||||||
|
onChanged: onEditorChange,
|
||||||
|
),
|
||||||
|
RadioListTile<EditorType>(
|
||||||
|
title: const Text("Raw Editor"),
|
||||||
|
value: EditorType.Raw,
|
||||||
|
groupValue: currentEditor,
|
||||||
|
onChanged: onEditorChange,
|
||||||
|
),
|
||||||
|
RadioListTile<EditorType>(
|
||||||
|
title: const Text("Checklist Editor"),
|
||||||
|
value: EditorType.Checklist,
|
||||||
|
groupValue: currentEditor,
|
||||||
|
onChanged: onEditorChange,
|
||||||
|
),
|
||||||
|
RadioListTile<EditorType>(
|
||||||
|
title: const Text("Journal Editor"),
|
||||||
|
value: EditorType.Journal,
|
||||||
|
groupValue: currentEditor,
|
||||||
|
onChanged: onEditorChange,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text("Choose Editor"),
|
||||||
|
content: Column(
|
||||||
|
children: children,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user