Documentation ¶
Index ¶
- func Interpolate(a, b color.NRGBA, progress float32) color.NRGBA
- func SimpleIconButton(th *material.Theme, state *widget.Clickable, icon *widget.Icon) material.IconButtonStyle
- func SwapGrounds(p material.Palette) material.Palette
- func SwapPairs(p material.Palette) material.Palette
- func WithAlpha(c color.NRGBA, a uint8) color.NRGBA
- type AlphaPalette
- type AppBar
- func (a *AppBar) CloseOverflowMenu(when time.Time)
- func (a *AppBar) Events(gtx layout.Context) []AppBarEvent
- func (a *AppBar) Layout(gtx layout.Context, theme *material.Theme) layout.Dimensions
- func (a *AppBar) SetActions(actions []AppBarAction, overflows []OverflowAction)
- func (a *AppBar) SetContextualActions(actions []AppBarAction, overflows []OverflowAction)
- func (a *AppBar) StartContextual(when time.Time, title string)
- func (a *AppBar) StopContextual(when time.Time)
- func (a *AppBar) ToggleContextual(when time.Time, title string)
- type AppBarAction
- type AppBarContextMenuDismissed
- type AppBarEvent
- type AppBarNavigationClicked
- type AppBarOverflowActionClicked
- type C
- type D
- type Hoverable
- type ModalLayer
- type ModalNavDrawer
- type ModalSheet
- type NavDrawer
- func (m *NavDrawer) AddNavItem(item NavItem)
- func (m *NavDrawer) CurrentNavDestination() interface{}
- func (m *NavDrawer) Layout(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions
- func (m *NavDrawer) LayoutContents(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions
- func (m *NavDrawer) NavDestinationChanged() bool
- func (m *NavDrawer) SetNavDestination(tag interface{})
- type NavItem
- type OverflowAction
- type Progress
- 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 Rect
- type Scrim
- type Sheet
- type TextField
- func (in *TextField) Clear()
- func (in *TextField) ClearError()
- func (in TextField) IsActive() bool
- func (in *TextField) IsErrored() bool
- func (in *TextField) Layout(gtx C, th *material.Theme, hint string) D
- func (in *TextField) SetError(err string)
- func (in *TextField) TextTooLong() bool
- func (in *TextField) Update(gtx C, th *material.Theme, hint string)
- type TruncatingLabelStyle
- type Validator
- type VerticalAnchorPosition
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimpleIconButton ¶
func SimpleIconButton(th *material.Theme, state *widget.Clickable, icon *widget.Icon) material.IconButtonStyle
SimpleIconButton creates an IconButtonStyle that is pre-configured to be the right size for use as an AppBarAction
func SwapGrounds ¶
SwapGrounds swaps the foreground and background colors of both the contrast and non-constrast colors.
Bg <-> Fg ContrastBg <-> ContrastFg
Types ¶
type AlphaPalette ¶
type AlphaPalette struct {
Hover, Selected uint8
}
AlphaPalette is the set of alpha values to be applied for certain material design states like hover, selected, etc...
type AppBar ¶
type AppBar struct { Title, ContextualTitle string // The modal layer is used to lay out the overflow menu. The nav // bar is not functional if this field is not supplied. *ModalLayer // Anchor indicates whether the app bar is anchored at the // top or bottom edge of the interface. It defaults to Top, and // is used to orient the layout of menus relative to the bar. Anchor VerticalAnchorPosition // contains filtered or unexported fields }
AppBar implements the material design App Bar documented here: https://material.io/components/app-bars-top
TODO(whereswaldon): implement support for RTL layouts
func NewAppBar ¶
func NewAppBar(modal *ModalLayer) *AppBar
NewAppBar creates and initializes an App Bar.
func (*AppBar) CloseOverflowMenu ¶
CloseOverflowMenu requests that the overflow menu be closed if it is open.
func (*AppBar) Events ¶
func (a *AppBar) Events(gtx layout.Context) []AppBarEvent
Events returns a slice of all AppBarActions to occur since the last frame.
func (*AppBar) Layout ¶
Layout renders the app bar. It will span all available horizontal space (gtx.Constraints.Max.X), but has a fixed height.
func (*AppBar) SetActions ¶
func (a *AppBar) SetActions(actions []AppBarAction, overflows []OverflowAction)
SetActions configures the set of actions available in the action item area of the app bar. They will be displayed in the order provided (from left to right) and will collapse into the overflow menu from right to left. The provided OverflowActions will always be in the overflow menu in the order provided.
func (*AppBar) SetContextualActions ¶
func (a *AppBar) SetContextualActions(actions []AppBarAction, overflows []OverflowAction)
SetContextualActions configures the actions that should be available in the next Contextual mode that this action bar enters.
func (*AppBar) StartContextual ¶
StartContextual causes the AppBar to transform into a contextual App Bar with a different set of actions than normal. If the App Bar is already in contextual mode, this has no effect. The title will be used as the contextual app bar title.
func (*AppBar) StopContextual ¶
StopContextual causes the AppBar to stop showing a contextual menu if one is currently being displayed.
type AppBarAction ¶
type AppBarAction struct { OverflowAction Layout func(gtx layout.Context, bg, fg color.NRGBA) layout.Dimensions }
AppBarAction configures an action in the App Bar's action items. The embedded OverflowAction provides the action information for when this item disappears into the overflow menu.
func SimpleIconAction ¶
func SimpleIconAction(th *material.Theme, state *widget.Clickable, icon *widget.Icon, overflow OverflowAction) AppBarAction
SimpleIconAction configures an AppBarAction that functions as a simple IconButton. To receive events from the button, use the standard methods on the provided state parameter.
type AppBarContextMenuDismissed ¶
type AppBarContextMenuDismissed struct{}
AppBarContextMenuDismissed indicates that the app bar context menu was dismissed during the last frame.
func (AppBarContextMenuDismissed) AppBarEvent ¶
func (a AppBarContextMenuDismissed) AppBarEvent()
func (AppBarContextMenuDismissed) String ¶
func (a AppBarContextMenuDismissed) String() string
type AppBarNavigationClicked ¶
type AppBarNavigationClicked struct{}
AppBarNavigationClicked indicates that the navigation icon was clicked during the last frame.
func (AppBarNavigationClicked) AppBarEvent ¶
func (a AppBarNavigationClicked) AppBarEvent()
func (AppBarNavigationClicked) String ¶
func (a AppBarNavigationClicked) String() string
type AppBarOverflowActionClicked ¶
type AppBarOverflowActionClicked struct {
Tag interface{}
}
AppBarOverflowActionClicked indicates that an action in the app bar overflow menu was clicked during the last frame.
func (AppBarOverflowActionClicked) AppBarEvent ¶
func (a AppBarOverflowActionClicked) AppBarEvent()
func (AppBarOverflowActionClicked) String ¶
func (a AppBarOverflowActionClicked) String() string
type D ¶
type D = layout.Dimensions
type Hoverable ¶
Hoverable tracks mouse hovers over some area.
type ModalLayer ¶
type ModalLayer struct { VisibilityAnimation Scrim Widget func(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions }
ModalLayer is a widget drawn on top of the normal UI that can be populated by other material components with dismissble modal dialogs. For instance, the App Bar can render its overflow menu within the modal layer, and the modal navigation drawer is entirely within the modal layer.
func (*ModalLayer) Layout ¶
func (m *ModalLayer) Layout(gtx layout.Context, th *material.Theme) layout.Dimensions
Layout renders the modal layer. Unless a modal widget has been triggered, this will do nothing.
type ModalNavDrawer ¶
type ModalNavDrawer struct { // contains filtered or unexported fields }
ModalNavDrawer implements the Material Design Modal Navigation Drawer described here: https://material.io/components/navigation-drawer
func ModalNavFrom ¶
func ModalNavFrom(nav *NavDrawer, modal *ModalLayer) *ModalNavDrawer
func NewModalNav ¶
func NewModalNav(modal *ModalLayer, title, subtitle string) *ModalNavDrawer
NewModalNav configures a modal navigation drawer that will render itself into the provided ModalLayer
func (*ModalNavDrawer) Appear ¶
func (m *ModalNavDrawer) Appear(when time.Time)
func (*ModalNavDrawer) Disappear ¶
func (m *ModalNavDrawer) Disappear(when time.Time)
func (*ModalNavDrawer) Layout ¶
func (m *ModalNavDrawer) Layout() layout.Dimensions
func (*ModalNavDrawer) ToggleVisibility ¶
func (m *ModalNavDrawer) ToggleVisibility(when time.Time)
type ModalSheet ¶
type ModalSheet struct { // MaxWidth constrains the maximum amount of horizontal screen real-estate // covered by the drawer. If the screen is narrower than this value, the // width will be inferred by reserving space for the scrim and using the // leftover area for the drawer. Values between 200 and 400 Dp are recommended. // // The default value used by NewModalNav is 400 Dp. MaxWidth unit.Value Modal *ModalLayer Sheet // contains filtered or unexported fields }
ModalSheet implements the Modal Side Sheet component specified at https://material.io/components/sheets-side#modal-side-sheet
func NewModalSheet ¶
func NewModalSheet(m *ModalLayer) *ModalSheet
NewModalSheet creates a modal sheet that can render a widget on the modal layer.
func (*ModalSheet) Appear ¶
func (s *ModalSheet) Appear(when time.Time)
Appear triggers the appearance of the ModalSheet.
func (*ModalSheet) Disappear ¶
func (s *ModalSheet) Disappear(when time.Time)
Disappear triggers the appearance of the ModalSheet.
func (*ModalSheet) LayoutModal ¶
func (s *ModalSheet) LayoutModal(contents func(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions)
ConfigureModal requests that the sheet prepare the associated ModalLayer to render itself (rather than another modal widget).
func (*ModalSheet) ToggleVisibility ¶
func (s *ModalSheet) ToggleVisibility(when time.Time)
ToggleVisibility triggers the appearance or disappearance of the ModalSheet.
type NavDrawer ¶
type NavDrawer struct { // the upper or lower edge of the drawer. This value should match the anchor // of an app bar if an app bar is used in conjunction with this nav drawer. Anchor VerticalAnchorPosition // contains filtered or unexported fields }
NavDrawer implements the Material Design Navigation Drawer described here: https://material.io/components/navigation-drawer
func (*NavDrawer) AddNavItem ¶
AddNavItem inserts a navigation target into the drawer. This should be invoked only from the layout thread to avoid nasty race conditions.
func (*NavDrawer) CurrentNavDestination ¶
func (m *NavDrawer) CurrentNavDestination() interface{}
CurrentNavDestination returns the tag of the navigation destination selected in the drawer.
func (*NavDrawer) Layout ¶
func (m *NavDrawer) Layout(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions
func (*NavDrawer) LayoutContents ¶
func (m *NavDrawer) LayoutContents(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions
func (*NavDrawer) NavDestinationChanged ¶
NavDestinationChanged returns whether the selected navigation destination has changed since the last frame.
func (*NavDrawer) SetNavDestination ¶
func (m *NavDrawer) SetNavDestination(tag interface{})
SetNavDestination changes the selected navigation item to the item with the provided tag. If the provided tag does not exist, it has no effect.
type NavItem ¶
type NavItem struct { // Tag is an externally-provided identifier for the view // that this item should navigate to. It's value is // opaque to navigation elements. // item's name. Material specifies that either all navigation // items should have an icon, or none should. As such, if this // field is nil, the Name will be aligned all the way to the // left. A mixture of icon and non-icon items will be misaligned. // Users should either set icons for all elements or none. Icon *widget.Icon }
type OverflowAction ¶
type OverflowAction struct { Name string Tag interface{} }
OverflowAction holds information about an action available in an overflow menu
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 Scrim ¶
type Scrim struct { // FinalAlpha is the final opacity of the scrim on a scale from 0 to 255. FinalAlpha uint8 widget.Clickable }
Scrim implments a clickable translucent overlay. It can animate appearing and disappearing as a fade-in, fade-out transition from zero opacity to a fixed maximum opacity.
func (*Scrim) Layout ¶
func (s *Scrim) Layout(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions
Layout draws the scrim using the provided animation. If the animation indicates that the scrim is not visible, this is a no-op.
type Sheet ¶
type Sheet struct{}
Sheet implements the standard side sheet described here: https://material.io/components/sheets-side#usage
type TextField ¶
type TextField struct { // Editor contains the edit buffer. widget.Editor // Hoverable detects mouse hovers. Hoverable Hoverable // Alignment specifies where to anchor the text. Alignment layout.Alignment // 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
func (*TextField) Clear ¶
func (in *TextField) Clear()
Clear the input text and reset any error status.
func (*TextField) ClearError ¶
func (in *TextField) ClearError()
ClearError clears any errored status.
func (*TextField) IsErrored ¶
IsErrored if input is in an errored state. Typically this is when the validator has returned an error message.
func (*TextField) SetError ¶
SetError puts the input into an errored state with the specified error text.
func (*TextField) TextTooLong ¶
TextTooLong returns whether the current editor text exceeds the set character limit.
type TruncatingLabelStyle ¶
type TruncatingLabelStyle material.LabelStyle
TruncatingLabelStyle is a type that forces a label to fit on one line and adds a truncation indicator symbol to the end of the line if the text has been truncated.
func (TruncatingLabelStyle) Layout ¶
func (t TruncatingLabelStyle) Layout(gtx layout.Context) layout.Dimensions
Layout renders the label into the provided context.
type Validator ¶
Validator validates text and returns a string describing the error. Error is displayed as helper text.
type VerticalAnchorPosition ¶
type VerticalAnchorPosition uint
VerticalAnchorPosition indicates the anchor position for the content of a component. Conventionally, this is use by AppBars and NavDrawers to decide how to allocate internal spacing and in which direction to animate certain actions.
const ( Top VerticalAnchorPosition = iota Bottom )
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