mirror of
https://github.com/foss42/apidash.git
synced 2025-07-15 00:52:22 +08:00
Revamped text editor
This commit is contained in:
@ -41,7 +41,8 @@ class _EditRequestBodyState extends ConsumerState<EditRequestBody> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextFieldEditor(
|
child: TextFieldEditor(
|
||||||
fieldKey: "$activeId-body",
|
key: Key("$activeId-body"),
|
||||||
|
fieldKey: "$activeId-body-editor",
|
||||||
initialValue: reqestModel.requestBody,
|
initialValue: reqestModel.requestBody,
|
||||||
onChanged: (String value) {
|
onChanged: (String value) {
|
||||||
ref
|
ref
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
@ -19,7 +18,6 @@ class TextFieldEditor extends StatefulWidget {
|
|||||||
class _TextFieldEditorState extends State<TextFieldEditor> {
|
class _TextFieldEditorState extends State<TextFieldEditor> {
|
||||||
final TextEditingController controller = TextEditingController();
|
final TextEditingController controller = TextEditingController();
|
||||||
late final FocusNode editorFocusNode;
|
late final FocusNode editorFocusNode;
|
||||||
late final FocusNode keyboardListnerFocusNode;
|
|
||||||
|
|
||||||
void insertTab() {
|
void insertTab() {
|
||||||
String sp = " ";
|
String sp = " ";
|
||||||
@ -41,75 +39,14 @@ class _TextFieldEditorState extends State<TextFieldEditor> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
editorFocusNode = FocusNode(debugLabel: "Editor Focus Node");
|
editorFocusNode = FocusNode(debugLabel: "Editor Focus Node");
|
||||||
keyboardListnerFocusNode =
|
|
||||||
FocusNode(debugLabel: "Keyboard Listner Focus Node");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
keyboardListnerFocusNode.dispose();
|
|
||||||
editorFocusNode.dispose();
|
editorFocusNode.dispose();
|
||||||
super.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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.initialValue != null) {
|
if (widget.initialValue != null) {
|
||||||
|
Reference in New Issue
Block a user