Documentation ¶
Overview ¶
Package plato implements themed styles for Plato Team Inc. https://www.platoapp.com/
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DefaultMaxImageHeight = unit.Dp(400) DefaultMaxMessageWidth = unit.Dp(600) DefaultMinMessageWidth = unit.Dp(80) DefaultAvatarSize = unit.Dp(28) LocalMessageColor = color.NRGBA{R: 63, G: 133, B: 232, A: 255} NonLocalMessageColor = color.NRGBA{R: 50, G: 50, B: 50, A: 255} )
var TickIcon = func() *widget.Icon { icon, _ := widget.NewIcon(icons.NavigationCheck) return icon }()
TickIcon used for read receipts.
Functions ¶
Types ¶
type D ¶
type D = layout.Dimensions
type MessageConfig ¶
type MessageConfig struct { // Content specifies the raw textual content of the message. Content string // Seen indicates whether this message has been "seen" by other users. Seen bool // Time indicates when this message was sent. Time time.Time // Color of the message bubble. // Defaults to LocalMessageColor. Color color.NRGBA // Compact mode avoids laying out timestamp and read-receipt. Compact bool }
MessageConfig describes aspects of a chat message.
type MessageStyle ¶
type MessageStyle struct { // Interaction holds the stateful parts of this message. Interaction *chatwidget.Message // MaxMessageWidth constrains the display width of the message's background. MaxMessageWidth unit.Dp // MinMessageWidth constrains the display width of the message's background. MinMessageWidth unit.Dp // MaxImageHeight constrains the maximum height of an image message. The image // will be scaled to fit within this height. MaxImageHeight unit.Dp // ContentPadding separates the Content field from the edges of the background. // If using a NinePatch background, this field will be ignored in favor of the // content padding encoded within the ninepatch image. ContentPadding layout.Inset // BubbleStyle configures a chat bubble beneath the message. If NinePatch is // non-nil, this field is ignored. chatmaterial.BubbleStyle // Ninepatch provides a ninepatch stretchable image background. Only used if // non-nil. *ninepatch.NinePatch // Content is the actual styled text of the message. Content richtext.TextStyle // Seen if this message has been seen, show a read receipt. Seen bool // Time is the timestamp associated with the message. Time material.LabelStyle // Receipt lays out the read receipt. Receipt *widget.Icon // Clickable indicates whether the message content should be able to receive // click events. Clickable bool // Compact mode avoids laying out timestamp and read-receipt. Compact bool // TickIconColor is the color of the "read and received" checkmark icon if it // is displayed. TickIconColor color.NRGBA }
MessageStyle configures the presentation of a chat message.
func Message ¶
func Message(th *material.Theme, interact *chatwidget.Message, msg MessageConfig) MessageStyle
Message constructs a MessageStyle with sensible defaults.
func (MessageStyle) Layout ¶
func (m MessageStyle) Layout(gtx C) (d D)
Layout the message atop its background.
func (*MessageStyle) TextColor ¶
func (c *MessageStyle) TextColor(cl color.NRGBA)
func (MessageStyle) WithBubbleColor ¶
func (c MessageStyle) WithBubbleColor(th *material.Theme, col color.NRGBA, luminance float64) MessageStyle
WithBubbleColor sets the message bubble color and selects a contrasted text color.
func (MessageStyle) WithNinePatch ¶
func (c MessageStyle) WithNinePatch(th *material.Theme, np ninepatch.NinePatch) MessageStyle
WithNinePatch sets the message surface to a ninepatch image.
type RowConfig ¶
type RowConfig struct { Sender string Avatar image.Image Content string SentAt time.Time Image image.Image Local bool }
RowConfig describes the aspects of a chat row relevant for displaying it within a widget.
type RowStyle ¶
type RowStyle struct { chatlayout.Row // Local indicates that the message was sent by the local user, // and should be right-aligned. Local bool // Time is the timestamp associated with the message. Time material.LabelStyle // StatusMessage defines a warning message to be displayed beneath the // chat message. StatusMessage material.LabelStyle // UserInfoStyle configures how the sender's information is displayed. UserInfoStyle // Avatar image for the user. Avatar chatmaterial.Image // MessageStyle configures how the text and its background are presented. MessageStyle // Interaction holds the interactive state of this message. Interaction *chatwidget.Row // Menu configures the right-click context menu for this message. Menu component.MenuStyle }
RowStyle configures the presentation of a chat message within a vertical list of chat messages.
In particular, RowStyle is repsonsible for gutters and anchoring of messages.
type UserInfoStyle ¶
type UserInfoStyle struct { // Username configures the presentation of the user name text. Username material.LabelStyle // Spacer is inserted between the username and avatar fields. layout.Spacer // Local controls the Left-to-Right ordering of layout. If false, // the Left-to-Right order will be: // - Avatar // - Spacer // - Username // If true, the order is reversed. Local bool }
UserInfoStyle defines the presentation of information about a user.