mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-08 09:00:54 +08:00
Remove duplication of NoteTitleEditor
This commit is contained in:
@ -6,6 +6,7 @@ import 'package:gitjournal/core/checklist.dart';
|
||||
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/editors/common.dart';
|
||||
import 'package:gitjournal/editors/note_title_editor.dart';
|
||||
|
||||
class ChecklistEditor extends StatefulWidget implements Editor {
|
||||
final Note note;
|
||||
@ -116,7 +117,7 @@ class ChecklistEditorState extends State<ChecklistEditor>
|
||||
|
||||
var titleEditor = Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0.0),
|
||||
child: _NoteTitleEditor(_titleTextController),
|
||||
child: NoteTitleEditor(_titleTextController),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
@ -197,30 +198,6 @@ class ChecklistEditorState extends State<ChecklistEditor>
|
||||
}
|
||||
}
|
||||
|
||||
class _NoteTitleEditor extends StatelessWidget {
|
||||
final TextEditingController textController;
|
||||
|
||||
_NoteTitleEditor(this.textController);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var style = Theme.of(context).textTheme.title;
|
||||
|
||||
return TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
maxLines: 1,
|
||||
style: style,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Title',
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
controller: textController,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
typedef TextChangedFunction = void Function(String);
|
||||
typedef StatusChangedFunction = void Function(bool);
|
||||
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/editors/common.dart';
|
||||
import 'package:gitjournal/editors/note_title_editor.dart';
|
||||
import 'package:gitjournal/widgets/note_viewer.dart';
|
||||
|
||||
class MarkdownEditor extends StatefulWidget implements Editor {
|
||||
@ -66,7 +67,7 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
if (note.canHaveMetadata) _NoteTitleEditor(_titleTextController),
|
||||
if (note.canHaveMetadata) NoteTitleEditor(_titleTextController),
|
||||
_NoteBodyEditor(
|
||||
_textController,
|
||||
autofocus: widget.autofocusOnEditor,
|
||||
@ -137,27 +138,3 @@ class _NoteBodyEditor extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _NoteTitleEditor extends StatelessWidget {
|
||||
final TextEditingController textController;
|
||||
|
||||
_NoteTitleEditor(this.textController);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var style = Theme.of(context).textTheme.title;
|
||||
|
||||
return TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
maxLines: 1,
|
||||
style: style,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Title',
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
controller: textController,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
25
lib/editors/note_title_editor.dart
Normal file
25
lib/editors/note_title_editor.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NoteTitleEditor extends StatelessWidget {
|
||||
final TextEditingController textController;
|
||||
|
||||
NoteTitleEditor(this.textController);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var style = Theme.of(context).textTheme.title;
|
||||
|
||||
return TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
maxLines: 1,
|
||||
style: style,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Title',
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
controller: textController,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user