theme

package
v0.0.18-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultIconButtonWidthDp = 20

Variables

This section is empty.

Functions

func ApplyAsContrast added in v0.0.14

func ApplyAsContrast(p material.Palette, pair ContrastPair) material.Palette

func ApplyAsNormal added in v0.0.14

func ApplyAsNormal(p material.Palette, pair ContrastPair) material.Palette

func BackgroundColor added in v0.0.16

func BackgroundColor(r sprigWidget.ReplyStatus, th *Theme) color.NRGBA

func BorderColor added in v0.0.16

func BorderColor(r sprigWidget.ReplyStatus, th *Theme) color.NRGBA

func HighlightColor added in v0.0.16

func HighlightColor(r sprigWidget.ReplyStatus, th *Theme) color.NRGBA

func ReplyTextColor added in v0.0.16

func ReplyTextColor(r sprigWidget.ReplyStatus, th *Theme) color.NRGBA

Types

type AuthorNameStyle added in v0.0.6

type AuthorNameStyle struct {
	Active bool
	ForestRefStyle
	ActivityIndicatorStyle material.LabelStyle
}

AuthorNameStyle configures the presentation of an Author name that can be presented with an activity indicator.

func AuthorName added in v0.0.6

func AuthorName(theme *Theme, authorName string, authorID *fields.QualifiedHash, active bool) AuthorNameStyle

AuthorName constructs an AuthorNameStyle for the user with the provided info.

func (AuthorNameStyle) Layout added in v0.0.6

Layout renders the AuthorNameStyle.

type C added in v0.0.6

type C = layout.Context

type ComposerStyle added in v0.0.15

type ComposerStyle struct {
	*sprigWidget.Composer
	*Theme
	Communities []*forest.Community
}

func Composer added in v0.0.15

func Composer(th *Theme, state *sprigWidget.Composer, communities []*forest.Community) ComposerStyle

func (ComposerStyle) Layout added in v0.0.15

type ContrastPair added in v0.0.14

type ContrastPair struct {
	Fg, Bg color.NRGBA
}

func PairFor added in v0.0.14

func PairFor(bg color.NRGBA) ContrastPair

PairFor wraps the provided theme color in a Color type with an automatically populated Text color. The Text field value is chosen based on the luminance of the provided color.

type D added in v0.0.6

type D = layout.Dimensions

type ForestRefStyle added in v0.0.16

type ForestRefStyle struct {
	NameStyle, SuffixStyle, ActivityIndicatorStyle material.LabelStyle
}

ForestRefStyle configures the presentation of a reference to a forest node that has both a name and an ID.

func CommunityName added in v0.0.6

func CommunityName(theme *material.Theme, communityName string, communityID *fields.QualifiedHash) ForestRefStyle

CommunityName constructs a ForestRefStyle for the provided community.

func ForestRef added in v0.0.16

func ForestRef(theme *material.Theme, name string, id *fields.QualifiedHash) ForestRefStyle

ForestRef constructs a ForestRefStyle for the node with the provided info.

func (ForestRefStyle) Layout added in v0.0.16

func (f ForestRefStyle) Layout(gtx C) D

Layout renders the ForestRefStyle.

type IconButton added in v0.0.10

type IconButton struct {
	Button *widget.Clickable
	Icon   *widget.Icon
	Size   unit.Value
	Inset  layout.Inset
}

IconButton applies defaults before rendering a `material.IconButtonStyle` to reduce noise. The main paramaters for each button are the state and icon. Color, size and inset are often the same. This wrapper reduces noise by defaulting those things.

func (IconButton) Layout added in v0.0.10

func (btn IconButton) Layout(gtx C, th *Theme) D

type MessageListStyle added in v0.0.16

type MessageListStyle struct {
	*Theme
	State             *sprigWidget.MessageList
	Replies           []ds.ReplyData
	Prefixes          []layout.Widget
	CreateReplyButton *widget.Clickable
}

func MessageList added in v0.0.16

func MessageList(th *Theme, state *sprigWidget.MessageList, replyBtn *widget.Clickable, replies []ds.ReplyData) MessageListStyle

func (MessageListStyle) Layout added in v0.0.16

func (m MessageListStyle) Layout(gtx C) D

type Rect added in v0.0.10

type Rect struct {
	Color color.NRGBA
	Size  f32.Point
	Radii float32
}

Rect creates a rectangle of the provided background color with Dimensions specified by size and a corner radius (on all corners) specified by radii.

func (Rect) Layout added in v0.0.10

func (r Rect) Layout(gtx C) D

Layout renders the Rect into the provided context

type ReplyStyle

type ReplyStyle struct {
	// ReplyStyleTransition captures the two states that the ReplyStyle is
	// transitioning between (though it may not currently be transitioning).
	ReplyStyleTransition

	// Background color for the status badge (currently only used if root node)
	BadgeColor color.NRGBA
	// Text config for the status badge
	BadgeText material.LabelStyle

	// MaxLines limits the maximum number of lines of content text that should
	// be displayed. Values less than 1 indicate unlimited.
	MaxLines int

	// CollapseMetadata should be set to true if this reply can be rendered
	// without the author being displayed.
	CollapseMetadata bool

	*sprigWidget.ReplyAnimationState

	ds.ReplyData
	// Whether or not to render the user as active
	ShowActive bool

	// Special text to overlay atop the message contents. Used for displaying
	// messages on anchor nodes with hidden children.
	AnchorText material.LabelStyle

	Content richtext.TextStyle
	Shaper  text.Shaper

	AuthorNameStyle
	CommunityNameStyle ForestRefStyle
	DateStyle          material.LabelStyle

	// Padding configures the padding surrounding the entire interior content of the
	// rendered message.
	Padding layout.Inset

	// MetadataPadding configures the padding surrounding the metadata line of a node.
	MetadataPadding layout.Inset
	// contains filtered or unexported fields
}

ReplyStyle presents a reply as a formatted chat bubble.

func Reply

func Reply(th *Theme, status *sprigWidget.ReplyAnimationState, nodes ds.ReplyData, text richtext.TextStyle, showActive bool) ReplyStyle

Reply configures a ReplyStyle for the provided state.

func (ReplyStyle) Anchoring added in v0.0.16

func (r ReplyStyle) Anchoring(th *material.Theme, numNodes int) ReplyStyle

Anchoring modifies the ReplyStyle to indicate that it is hiding some number of other nodes.

func (ReplyStyle) HideMetadata added in v0.0.12

func (r ReplyStyle) HideMetadata(b bool) ReplyStyle

HideMetadata configures the node metadata line to not be displayed in the reply.

func (ReplyStyle) Layout

func (r ReplyStyle) Layout(gtx layout.Context) layout.Dimensions

Layout renders the ReplyStyle.

type ReplyStyleConfig added in v0.0.18

type ReplyStyleConfig struct {
	Highlight  color.NRGBA
	Background color.NRGBA
	TextColor  color.NRGBA
	Border     color.NRGBA
	// contains filtered or unexported fields
}

ReplyStyleConfig configures aspects of the presentation of a message.

func ReplyStyleConfigFor added in v0.0.18

func ReplyStyleConfigFor(th *Theme, status sprigWidget.ReplyStatus) ReplyStyleConfig

ReplyStyleConfigFor returns a configuration tailored to the given ReplyStatus and theme.

type ReplyStyleTransition added in v0.0.18

type ReplyStyleTransition struct {
	Previous, Current ReplyStyleConfig
}

ReplyStyleTransition represents a transition from one ReplyStyleConfig to another one and provides a method for interpolating the intermediate results between them.

func (ReplyStyleTransition) InterpolateWith added in v0.0.18

func (r ReplyStyleTransition) InterpolateWith(progress float32) ReplyStyleConfig

InterpolateWith returns a ReplyStyleConfig blended between the previous and current configurations, with 0 returning the previous configuration and 1 returning the current.

type Swatch added in v0.0.14

type Swatch struct {
	Light, Dark, Default ContrastPair
}

type TextFormStyle added in v0.0.9

type TextFormStyle struct {
	State *widget.TextForm
	// internal widget separation distance
	layout.Inset
	PasteButton      material.IconButtonStyle
	SubmitButton     material.ButtonStyle
	EditorHint       string
	EditorBackground color.NRGBA
	*Theme
}

func TextForm added in v0.0.9

func TextForm(th *Theme, state *widget.TextForm, submitText, formHint string) TextFormStyle

func (TextFormStyle) Layout added in v0.0.9

type Theme added in v0.0.7

type Theme struct {
	*material.Theme
	Primary    Swatch
	Secondary  Swatch
	Background Swatch

	Ancestors, Descendants, Selected, Siblings, Unselected *color.NRGBA
}

func New added in v0.0.7

func New() *Theme

func (*Theme) ToDark added in v0.0.12

func (t *Theme) ToDark()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL