Documentation
¶
Overview ¶
Package textfield contains Material 3 Text Field components.
Reference: [Text Fields](https://m3.material.io/components/text-fields/overview) Specs: [Text Fields Specs](https://m3.material.io/components/text-fields/specs)
Index ¶
- Constants
- Variables
- type Composable
- func Filled(value string, onValueChange func(string), options ...TextFieldOption) Composable
- func Outlined(value string, onValueChange func(string), options ...TextFieldOption) Composable
- func OutlinedSecureTextField(value string, onValueChange func(string), options ...TextFieldOption) Composable
- func SecureTextField(value string, onValueChange func(string), options ...TextFieldOption) Composable
- func TextField(value string, onValueChange func(string), label string, ...) Composable
- type Composer
- type FilledTextFieldWidget
- type HandlerWrapper
- type Modifier
- type OnSubmitWrapper
- type OutlinedTextFieldWidget
- func (in *OutlinedTextFieldWidget) Clear()
- func (in *OutlinedTextFieldWidget) ClearError()
- func (in *OutlinedTextFieldWidget) IsActive() bool
- func (in *OutlinedTextFieldWidget) IsErrored() bool
- func (in *OutlinedTextFieldWidget) Layout(gtx layout.Context, th *gioMaterial.Theme, hint string) layout.Dimensions
- func (in *OutlinedTextFieldWidget) SetError(isError bool, err string)
- func (in *OutlinedTextFieldWidget) TextTooLong() bool
- type Progress
- func (p Progress) Absolute() float32
- func (p Progress) Direction() ProgressDirection
- func (p Progress) Finished() bool
- func (p Progress) Progress() float32
- func (p *Progress) Start(began time.Time, direction ProgressDirection, duration time.Duration)
- func (p Progress) Started() bool
- func (p *Progress) Stop()
- func (p *Progress) Update(now time.Time)
- type ProgressDirection
- type TextFieldColors
- type TextFieldOption
- func WithColors(colors TextFieldColors) TextFieldOption
- func WithEnabled(enabled bool) TextFieldOption
- func WithError(isError bool) TextFieldOption
- func WithLabel(label string) TextFieldOption
- func WithLeadingIcon(icon Composable) TextFieldOption
- func WithMask(mask rune) TextFieldOption
- func WithMaxLines(maxLines int) TextFieldOption
- func WithMinLines(minLines int) TextFieldOption
- func WithModifier(m Modifier) TextFieldOption
- func WithOnSubmit(onSubmit func()) TextFieldOption
- func WithPlaceholder(placeholder string) TextFieldOption
- func WithPrefix(prefix Composable) TextFieldOption
- func WithReadOnly(readOnly bool) TextFieldOption
- func WithShape(shape interface{}) TextFieldOption
- func WithSingleLine(singleLine bool) TextFieldOption
- func WithSuffix(suffix Composable) TextFieldOption
- func WithSupportingText(text string) TextFieldOption
- func WithTextStyle(textStyle *text.TextStyle) TextFieldOption
- func WithTrailingIcon(icon Composable) TextFieldOption
- type TextFieldOptions
- type TextFieldStateTracker
- type TextFieldWidget
- type VisibilityAnimation
- func (v VisibilityAnimation) Animating() bool
- func (v *VisibilityAnimation) Appear(now time.Time)
- func (v *VisibilityAnimation) Disappear(now time.Time)
- func (v *VisibilityAnimation) Revealed(gtx layout.Context) float32
- func (v *VisibilityAnimation) String(gtx layout.Context) string
- func (v *VisibilityAnimation) ToggleVisibility(now time.Time)
- func (v VisibilityAnimation) Visible() bool
- type VisibilityAnimationState
Constants ¶
const ( DefaultObfuscationCharacter = '•' SecureTextFieldNodeID = "Material3SecureTextField" )
const Material3FilledTextFieldNodeID = "Material3FilledTextField"
const Material3OutlinedTextFieldNodeID = "Material3OutlinedTextField"
const Material3TextFieldNodeID = "Material3TextField"
Variables ¶
var EmptyModifier = modifier.EmptyModifier
Functions ¶
This section is empty.
Types ¶
type Composable ¶
type Composable = api.Composable
func Filled ¶
func Filled( value string, onValueChange func(string), options ...TextFieldOption, ) Composable
Filled implements the Filled Material Design 3 text field. It uses a custom widget implementation.
func Outlined ¶
func Outlined( value string, onValueChange func(string), options ...TextFieldOption, ) Composable
Outlined implements the Outlined Material Design 3 text field. It uses a custom widget implementation adapted from gio-x.
func OutlinedSecureTextField ¶
func OutlinedSecureTextField( value string, onValueChange func(string), options ...TextFieldOption, ) Composable
OutlinedSecureTextField implements the Outlined Secure Text Field.
func SecureTextField ¶
func SecureTextField( value string, onValueChange func(string), options ...TextFieldOption, ) Composable
SecureTextField implements the Filled Secure Text Field. It is designed for password entry.
func TextField ¶
func TextField( value string, onValueChange func(string), label string, options ...TextFieldOption, ) Composable
TextField implements a Material Design 3 text field. It defaults to the Filled variant for backward compatibility, but users should prefer explicit Filled or Outlined calls.
type FilledTextFieldWidget ¶
type FilledTextFieldWidget struct {
widget.Editor
Helper string
Colors TextFieldColors
Prefix layout.Widget
Suffix layout.Widget
// contains filtered or unexported fields
}
FilledTextFieldWidget is the local implementation of the Filled text field.
func (*FilledTextFieldWidget) IsErrored ¶
func (in *FilledTextFieldWidget) IsErrored() bool
func (*FilledTextFieldWidget) Layout ¶
func (in *FilledTextFieldWidget) Layout(gtx layout.Context, th *gioMaterial.Theme, hint string) layout.Dimensions
func (*FilledTextFieldWidget) SetError ¶
func (in *FilledTextFieldWidget) SetError(isError bool, err string)
type HandlerWrapper ¶
type HandlerWrapper struct {
Func func(string)
}
type OnSubmitWrapper ¶
type OnSubmitWrapper struct {
Func func()
}
type OutlinedTextFieldWidget ¶
type OutlinedTextFieldWidget struct {
widget.Editor
// Config
Helper string
CharLimit uint
Prefix layout.Widget
Suffix layout.Widget
Colors TextFieldColors
// contains filtered or unexported fields
}
func (*OutlinedTextFieldWidget) Clear ¶
func (in *OutlinedTextFieldWidget) Clear()
Clear the input text and reset any error status.
func (*OutlinedTextFieldWidget) ClearError ¶
func (in *OutlinedTextFieldWidget) ClearError()
ClearError clears any errored status.
func (*OutlinedTextFieldWidget) IsActive ¶
func (in *OutlinedTextFieldWidget) IsActive() bool
IsActive if input is in an active state (Active, Focused or Errored).
func (*OutlinedTextFieldWidget) IsErrored ¶
func (in *OutlinedTextFieldWidget) IsErrored() bool
IsErrored if input is in an errored state. Typically this is when the validator has returned an error message.
func (*OutlinedTextFieldWidget) Layout ¶
func (in *OutlinedTextFieldWidget) Layout(gtx layout.Context, th *gioMaterial.Theme, hint string) layout.Dimensions
func (*OutlinedTextFieldWidget) SetError ¶
func (in *OutlinedTextFieldWidget) SetError(isError bool, err string)
SetError puts the input into an errored state with the specified error text.
func (*OutlinedTextFieldWidget) TextTooLong ¶
func (in *OutlinedTextFieldWidget) TextTooLong() bool
TextTooLong returns whether the current editor text exceeds the set character limit.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress is an animation primitive that tracks progress of time over a fixed duration as a float between [0, 1].
Progress is reversable.
Widgets map async UI events to state changes: stop, forward, reverse. Widgets then interpolate visual data based on progress value.
Update method must be called every tick to update the progress value.
func (Progress) Direction ¶
func (p Progress) Direction() ProgressDirection
Direction reports the current direction.
type ProgressDirection ¶
type ProgressDirection int
ProgressDirection specifies how to update progress every tick.
const ( // Forward progresses from 0 to 1. Forward ProgressDirection = iota // Reverse progresses from 1 to 0. Reverse )
func (ProgressDirection) String ¶
func (d ProgressDirection) String() string
type TextFieldColors ¶
type TextFieldColors struct {
TextColor graphics.Color
DisabledTextColor graphics.Color
CursorColor graphics.Color
ErrorCursorColor graphics.Color
SelectionColor graphics.Color
FocusedIndicatorColor graphics.Color
UnfocusedIndicatorColor graphics.Color
DisabledIndicatorColor graphics.Color
ErrorIndicatorColor graphics.Color
HoveredIndicatorColor graphics.Color
LeadingIconColor graphics.Color
TrailingIconColor graphics.Color
DisabledLeadingIconColor graphics.Color
DisabledTrailingIconColor graphics.Color
LabelColor graphics.Color
UnfocusedLabelColor graphics.Color
FocusedLabelColor graphics.Color // Added
DisabledLabelColor graphics.Color
ErrorLabelColor graphics.Color
PlaceholderColor graphics.Color
DisabledPlaceholderColor graphics.Color
SupportingTextColor graphics.Color
DisabledSupportingTextColor graphics.Color
ErrorSupportingTextColor graphics.Color
ContainerColor graphics.Color // Added
DisabledContainerColor graphics.Color // Added
}
func DefaultTextFieldColors ¶
func DefaultTextFieldColors() TextFieldColors
func ResolveTextFieldColors ¶
func ResolveTextFieldColors(c Composer, colors TextFieldColors) TextFieldColors
type TextFieldOption ¶
type TextFieldOption func(*TextFieldOptions)
func WithColors ¶
func WithColors(colors TextFieldColors) TextFieldOption
func WithEnabled ¶
func WithEnabled(enabled bool) TextFieldOption
func WithError ¶
func WithError(isError bool) TextFieldOption
func WithLabel ¶
func WithLabel(label string) TextFieldOption
func WithLeadingIcon ¶
func WithLeadingIcon(icon Composable) TextFieldOption
func WithMask ¶
func WithMask(mask rune) TextFieldOption
func WithMaxLines ¶
func WithMaxLines(maxLines int) TextFieldOption
func WithMinLines ¶
func WithMinLines(minLines int) TextFieldOption
func WithModifier ¶
func WithModifier(m Modifier) TextFieldOption
func WithOnSubmit ¶
func WithOnSubmit(onSubmit func()) TextFieldOption
func WithPlaceholder ¶
func WithPlaceholder(placeholder string) TextFieldOption
func WithPrefix ¶
func WithPrefix(prefix Composable) TextFieldOption
func WithReadOnly ¶
func WithReadOnly(readOnly bool) TextFieldOption
func WithShape ¶
func WithShape(shape interface{}) TextFieldOption
func WithSingleLine ¶
func WithSingleLine(singleLine bool) TextFieldOption
func WithSuffix ¶
func WithSuffix(suffix Composable) TextFieldOption
func WithSupportingText ¶
func WithSupportingText(text string) TextFieldOption
func WithTextStyle ¶
func WithTextStyle(textStyle *text.TextStyle) TextFieldOption
func WithTrailingIcon ¶
func WithTrailingIcon(icon Composable) TextFieldOption
type TextFieldOptions ¶
type TextFieldOptions struct {
Modifier Modifier
Enabled bool
ReadOnly bool
TextStyle *text.TextStyle
Label string //maybe.Maybe[api.Composable]
Placeholder string //maybe.Maybe[api.Composable]
LeadingIcon api.Composable
TrailingIcon api.Composable
Prefix api.Composable
Suffix api.Composable
SupportingText string //maybe.Maybe[api.Composable]
IsError bool
SingleLine bool
MaxLines int
MinLines int
Mask rune
Shape interface{}
Colors TextFieldColors
OnSubmit func() // Called when Enter is pressed (SingleLine mode)
}
func DefaultTextFieldOptions ¶
func DefaultTextFieldOptions() TextFieldOptions
type TextFieldStateTracker ¶
type TextFieldStateTracker struct {
LastValue string
}
type TextFieldWidget ¶
type TextFieldWidget struct {
// Editor contains the edit buffer.
widget.Editor
// Helper text to give additional context to a field.
Helper string
// CharLimit specifies the maximum number of characters the text input
// will allow. Zero means "no limit".
CharLimit uint
// Prefix appears before the content of the text input.
Prefix layout.Widget
// Suffix appears after the content of the text input.
Suffix layout.Widget
// contains filtered or unexported fields
}
TextField implements the Material Design Text Field described here: https://material.io/components/text-fields
type VisibilityAnimation ¶
type VisibilityAnimation struct {
// How long does the animation last
time.Duration
State VisibilityAnimationState
Started time.Time
}
VisibilityAnimation holds the animation state for animations that transition between a "visible" and "invisible" state for a fixed duration of time.
func (VisibilityAnimation) Animating ¶
func (v VisibilityAnimation) Animating() bool
Animating() returns whether the animation is either in the process of appearsing or disappearing.
func (*VisibilityAnimation) Appear ¶
func (v *VisibilityAnimation) Appear(now time.Time)
Appear triggers the animation to begin becoming visible at the provided time. It is a no-op if the animation is already visible.
func (*VisibilityAnimation) Disappear ¶
func (v *VisibilityAnimation) Disappear(now time.Time)
Disappear triggers the animation to begin becoming invisible at the provided time. It is a no-op if the animation is already invisible.
func (*VisibilityAnimation) Revealed ¶
func (v *VisibilityAnimation) Revealed(gtx layout.Context) float32
Revealed returns the fraction of the animated entity that should be revealed at the current time in the animation. This fraction is computed with linear interpolation.
Revealed should be invoked during every frame that v.Animating() returns true.
If the animation reaches its end this frame, Revealed will transition it to a non-animating state automatically.
If the animation is in the process of animating, calling Revealed will automatically add an InvalidateOp to the provided layout.Context to ensure that the next frame will be generated promptly.
func (*VisibilityAnimation) String ¶
func (v *VisibilityAnimation) String(gtx layout.Context) string
func (*VisibilityAnimation) ToggleVisibility ¶
func (v *VisibilityAnimation) ToggleVisibility(now time.Time)
ToggleVisibility will make an invisible animation begin the process of becoming visible and a visible animation begin the process of disappearing.
func (VisibilityAnimation) Visible ¶
func (v VisibilityAnimation) Visible() bool
Visible() returns whether any part of the animated entity should be visible during the current animation frame.
type VisibilityAnimationState ¶
type VisibilityAnimationState int
VisibilityAnimationState represents possible states that a VisibilityAnimation can be in.
const ( Visible VisibilityAnimationState = iota Disappearing Appearing Invisible )
func (VisibilityAnimationState) String ¶
func (v VisibilityAnimationState) String() string