mirror of
https://github.com/foss42/apidash.git
synced 2025-05-31 14:23:45 +08:00
Revamped text editor
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
@ -19,7 +18,6 @@ class TextFieldEditor extends StatefulWidget {
|
||||
class _TextFieldEditorState extends State<TextFieldEditor> {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
late final FocusNode editorFocusNode;
|
||||
late final FocusNode keyboardListnerFocusNode;
|
||||
|
||||
void insertTab() {
|
||||
String sp = " ";
|
||||
@ -41,75 +39,14 @@ class _TextFieldEditorState extends State<TextFieldEditor> {
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.initialValue != null) {
|
||||
controller.text = widget.initialValue!;
|
||||
}
|
||||
return RawKeyboardListener(
|
||||
focusNode: keyboardListnerFocusNode,
|
||||
onKey: (RawKeyEvent event) {
|
||||
if (event.runtimeType == RawKeyDownEvent &&
|
||||
(event.logicalKey == LogicalKeyboardKey.tab)) {
|
||||
if (kIsWeb) {
|
||||
FocusScope.of(context).previousFocus();
|
||||
} else {
|
||||
print(FocusScope.of(context).debugLabel);
|
||||
print("here");
|
||||
//FocusScope.of(context).requestFocus(editorFocusNode);
|
||||
//FocusScope.of(context).previousFocus();
|
||||
//FocusScope.of(context).unfocus();
|
||||
editorFocusNode.requestFocus();
|
||||
}
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}*/
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.initialValue != null) {
|
||||
|
Reference in New Issue
Block a user