From f79768e9010eb59f5c60310f9d5f5cb9b8554798 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 27 Jun 2024 14:37:48 +0800 Subject: [PATCH] WIP on textfields --- .../lib/src/widgets/form/text_form_field.dart | 19 ++++++++++++++ .../src/widgets/text_field/text_field.dart | 25 ++++++++++--------- .../widgets/text_field/text_field_style.dart | 6 ++--- 3 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 forui/lib/src/widgets/form/text_form_field.dart diff --git a/forui/lib/src/widgets/form/text_form_field.dart b/forui/lib/src/widgets/form/text_form_field.dart new file mode 100644 index 000000000..ec200d318 --- /dev/null +++ b/forui/lib/src/widgets/form/text_form_field.dart @@ -0,0 +1,19 @@ + +import 'package:flutter/material.dart'; + +class FTextFormField extends FormField { + + FTextFormField({ + super.autovalidateMode, + }): super( + builder: (state) + ); + + @override + FormFieldState createState() => _State(); + +} + +class _State extends FormFieldState { + +} diff --git a/forui/lib/src/widgets/text_field/text_field.dart b/forui/lib/src/widgets/text_field/text_field.dart index a118eefd5..045430098 100644 --- a/forui/lib/src/widgets/text_field/text_field.dart +++ b/forui/lib/src/widgets/text_field/text_field.dart @@ -11,6 +11,14 @@ import 'package:forui/forui.dart'; part 'text_field_style.dart'; +/// The default context menu builder. +@internal +Widget defaultContextMenuBuilder( + BuildContext context, + EditableTextState state, +) => AdaptiveTextSelectionToolbar.editableText(editableTextState: state); + + /// A text field. /// /// It lets the user enter text, either with hardware keyboard or with an onscreen keyboard. @@ -20,12 +28,6 @@ part 'text_field_style.dart'; /// * [FTextFieldStyle] for customizing a text field's appearance. /// * [TextField] for more details about working with a text field. final class FTextField extends StatelessWidget { - static Widget _defaultContextMenuBuilder( - BuildContext context, - EditableTextState editableTextState, - ) => - AdaptiveTextSelectionToolbar.editableText(editableTextState: editableTextState); - /// The text field's style. Defaults to [FThemeData.textFieldStyle]. final FTextFieldStyle? style; @@ -537,7 +539,7 @@ final class FTextField extends StatelessWidget { this.restorationId, this.scribbleEnabled = true, this.enableIMEPersonalizedLearning = true, - this.contextMenuBuilder = _defaultContextMenuBuilder, + this.contextMenuBuilder = defaultContextMenuBuilder, this.canRequestFocus = true, this.undoController, this.spellCheckConfiguration, @@ -598,7 +600,7 @@ final class FTextField extends StatelessWidget { this.restorationId, this.scribbleEnabled = true, this.enableIMEPersonalizedLearning = true, - this.contextMenuBuilder = _defaultContextMenuBuilder, + this.contextMenuBuilder = defaultContextMenuBuilder, this.canRequestFocus = true, this.undoController, this.spellCheckConfiguration, @@ -668,7 +670,7 @@ final class FTextField extends StatelessWidget { this.restorationId, this.scribbleEnabled = true, this.enableIMEPersonalizedLearning = true, - this.contextMenuBuilder = _defaultContextMenuBuilder, + this.contextMenuBuilder = defaultContextMenuBuilder, this.canRequestFocus = true, this.undoController, this.spellCheckConfiguration, @@ -737,7 +739,7 @@ final class FTextField extends StatelessWidget { this.restorationId, this.scribbleEnabled = true, this.enableIMEPersonalizedLearning = true, - this.contextMenuBuilder = _defaultContextMenuBuilder, + this.contextMenuBuilder = defaultContextMenuBuilder, this.canRequestFocus = true, this.undoController, this.spellCheckConfiguration, @@ -983,8 +985,7 @@ final class FTextField extends StatelessWidget { ..add(IterableProperty('autofillHints', autofillHints)) ..add(StringProperty('restorationId', restorationId)) ..add(FlagProperty('scribbleEnabled', value: scribbleEnabled, ifTrue: 'scribbleEnabled')) - ..add( - FlagProperty( + ..add(FlagProperty( 'enableIMEPersonalizedLearning', value: enableIMEPersonalizedLearning, ifTrue: 'enableIMEPersonalizedLearning', diff --git a/forui/lib/src/widgets/text_field/text_field_style.dart b/forui/lib/src/widgets/text_field/text_field_style.dart index b21d71921..8aac87ef3 100644 --- a/forui/lib/src/widgets/text_field/text_field_style.dart +++ b/forui/lib/src/widgets/text_field/text_field_style.dart @@ -14,7 +14,7 @@ final class FTextFieldStyle with Diagnosticable { /// The padding surrounding this text field's content. /// - /// Defaults to `const EdgeInsets.symmetric(horizontal: 15, vertical: 5)`. + /// Defaults to `const EdgeInsets.symmetric(horizontal: 15, vertical: 15)`. final EdgeInsets contentPadding; /// Configures padding to edges surrounding a [Scrollable] when this text field scrolls into view. @@ -43,7 +43,7 @@ final class FTextFieldStyle with Diagnosticable { required this.disabled, required this.error, this.cursorColor = CupertinoColors.activeBlue, - this.contentPadding = const EdgeInsets.symmetric(horizontal: 15, vertical: 5), + this.contentPadding = const EdgeInsets.symmetric(horizontal: 15, vertical: 15), this.scrollPadding = const EdgeInsets.all(20), }); @@ -54,7 +54,7 @@ final class FTextFieldStyle with Diagnosticable { required FStyle style, }) : keyboardAppearance = colorScheme.brightness, cursorColor = CupertinoColors.activeBlue, - contentPadding = const EdgeInsets.symmetric(horizontal: 15, vertical: 5), + contentPadding = const EdgeInsets.symmetric(horizontal: 15, vertical: 15), scrollPadding = const EdgeInsets.all(20.0), enabled = FTextFieldStateStyle.inherit( labelColor: colorScheme.primary,