mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Update editor.dart
This commit is contained in:
@ -18,13 +18,8 @@ class TextFieldEditor extends StatefulWidget {
|
|||||||
|
|
||||||
class _TextFieldEditorState extends State<TextFieldEditor> {
|
class _TextFieldEditorState extends State<TextFieldEditor> {
|
||||||
final TextEditingController controller = TextEditingController();
|
final TextEditingController controller = TextEditingController();
|
||||||
final editorFocusNode = FocusNode();
|
late final FocusNode editorFocusNode;
|
||||||
final keyboardListnerFocusNode = FocusNode();
|
late final FocusNode keyboardListnerFocusNode;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void insertTab() {
|
void insertTab() {
|
||||||
String sp = " ";
|
String sp = " ";
|
||||||
@ -42,6 +37,22 @@ class _TextFieldEditorState extends State<TextFieldEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
editorFocusNode = FocusNode(debugLabel: "Editor Focus Node");
|
||||||
|
keyboardListnerFocusNode =
|
||||||
|
FocusNode(debugLabel: "Keyboard Listner Focus Node");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
keyboardListnerFocusNode.dispose();
|
||||||
|
editorFocusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.initialValue != null) {
|
if (widget.initialValue != null) {
|
||||||
@ -55,6 +66,11 @@ class _TextFieldEditorState extends State<TextFieldEditor> {
|
|||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
FocusScope.of(context).previousFocus();
|
FocusScope.of(context).previousFocus();
|
||||||
} else {
|
} else {
|
||||||
|
print(FocusScope.of(context).debugLabel);
|
||||||
|
print("here");
|
||||||
|
//FocusScope.of(context).requestFocus(editorFocusNode);
|
||||||
|
//FocusScope.of(context).previousFocus();
|
||||||
|
//FocusScope.of(context).unfocus();
|
||||||
editorFocusNode.requestFocus();
|
editorFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
insertTab();
|
insertTab();
|
||||||
@ -92,12 +108,50 @@ class _TextFieldEditorState extends State<TextFieldEditor> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
Widget build(BuildContext context) {
|
||||||
keyboardListnerFocusNode.dispose();
|
if (widget.initialValue != null) {
|
||||||
editorFocusNode.dispose();
|
controller.text = widget.initialValue!;
|
||||||
super.dispose();
|
}
|
||||||
|
return CallbackShortcuts(
|
||||||
|
bindings: <ShortcutActivator, VoidCallback>{
|
||||||
|
const SingleActivator(LogicalKeyboardKey.tab): () {
|
||||||
|
insertTab();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
child: TextFormField(
|
||||||
|
key: Key(widget.fieldKey),
|
||||||
|
controller: controller,
|
||||||
|
focusNode: editorFocusNode,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
expands: true,
|
||||||
|
maxLines: null,
|
||||||
|
style: kCodeStyle,
|
||||||
|
textAlignVertical: TextAlignVertical.top,
|
||||||
|
onChanged: widget.onChanged,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter content (body)",
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline.withOpacity(
|
||||||
|
kHintOpacity,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.primary.withOpacity(
|
||||||
|
kHintOpacity,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user