plato

package
v0.0.0-...-69d9917 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT, Unlicense Imports: 15 Imported by: 0

Documentation

Overview

Package plato implements themed styles for Plato Team Inc. https://www.platoapp.com/

Index

Constants

This section is empty.

Variables

View Source
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}
)
View Source
var TickIcon = func() *widget.Icon {
	icon, _ := widget.NewIcon(icons.NavigationCheck)
	return icon
}()

TickIcon used for read receipts.

Functions

func Luminance

func Luminance(c color.NRGBA) float64

Luminance computes the relative brightness of a color, normalized between [0,1]. Ignores alpha.

Types

type C

type C = layout.Context

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.

func NewRow

func NewRow(
	th *material.Theme,
	interact *chatwidget.Row,
	menu *component.MenuState,
	msg RowConfig,
) RowStyle

NewRow creates a style type that can lay out the data for a message.

func (RowStyle) Layout

func (c RowStyle) Layout(gtx C) D

Layout the message.

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.

func UserInfo

func UserInfo(th *material.Theme, username string) UserInfoStyle

UserInfo constructs a UserInfoStyle with sensible defaults.

func (UserInfoStyle) Layout

func (ui UserInfoStyle) Layout(gtx C) D

Layout the user information.

Jump to

Keyboard shortcuts

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