Skip to content

Commit

Permalink
Add some properties (cursorColor, onTextChange, focusNode, `onT…
Browse files Browse the repository at this point in the history
…extSubmitted`, ...) for TextField
  • Loading branch information
dab246 committed Jul 24, 2024
1 parent 9b114d8 commit b1b7af2
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions lib/src/presentation/language_tool_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ class LanguageToolTextField extends StatefulWidget {
/// Determine text Direction
final TextDirection? textDirection;

final ValueChanged<String>? onTextChange;
final ValueChanged<String>? onTextSubmitted;
final VoidCallback? onTap;
final TapRegionCallback? onTapOutside;
final TextInputAction? textInputAction;
final bool obscureText;
final TextInputType? keyboardType;
final Color? cursorColor;
final bool autoFocus;
final FocusNode? focusNode;
final Brightness? keyboardAppearance;
final bool autocorrect;
final bool readOnly;
final MouseCursor? mouseCursor;

/// Creates a widget that checks grammar errors.
const LanguageToolTextField({
required this.controller,
Expand All @@ -51,6 +66,20 @@ class LanguageToolTextField extends StatefulWidget {
this.expands = false,
this.textAlign = TextAlign.start,
this.textDirection,
this.cursorColor,
this.autocorrect = true,
this.obscureText = false,
this.autoFocus = false,
this.readOnly = false,
this.textInputAction,
this.keyboardType,
this.focusNode,
this.keyboardAppearance,
this.mouseCursor,
this.onTap,
this.onTapOutside,
this.onTextChange,
this.onTextSubmitted,
super.key,
});

Expand All @@ -61,14 +90,15 @@ class LanguageToolTextField extends StatefulWidget {
class _LanguageToolTextFieldState extends State<LanguageToolTextField> {
static const _padding = 24.0;

final _focusNode = FocusNode();
FocusNode? _focusNode;
final _scrollController = ScrollController();

@override
void initState() {
super.initState();
final controller = widget.controller;

_focusNode = widget.focusNode ?? FocusNode();
controller.focusNode = _focusNode;
controller.language = widget.language;
final defaultPopup = MistakePopup(popupRenderer: PopupOverlayRenderer());
Expand Down Expand Up @@ -111,6 +141,19 @@ class _LanguageToolTextFieldState extends State<LanguageToolTextField> {
maxLines: widget.maxLines,
expands: widget.expands,
style: widget.style,
cursorColor: widget.cursorColor,
autocorrect: widget.autocorrect,
textInputAction: widget.textInputAction,
keyboardAppearance: widget.keyboardAppearance,
obscureText: widget.obscureText,
keyboardType: widget.keyboardType,
autofocus: widget.autoFocus,
readOnly: widget.readOnly,
mouseCursor: widget.mouseCursor,
onChanged: widget.onTextChange,
onSubmitted: widget.onTextSubmitted,
onTap: widget.onTap,
onTapOutside: widget.onTapOutside,
),
),
);
Expand All @@ -123,7 +166,9 @@ class _LanguageToolTextFieldState extends State<LanguageToolTextField> {

@override
void dispose() {
_focusNode.dispose();
if (widget.focusNode == null) {
_focusNode?.dispose();
}
_scrollController.dispose();
super.dispose();
}
Expand Down

0 comments on commit b1b7af2

Please sign in to comment.