Skip to content

limafresh/messagebubble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

messagebubble

Modern message bubble widget for Go Fyne GUI toolkit.

Why messagebubble?

  • Automatically update colors when switching between light/dark themes
  • Set colors for the bubble, message, and time for light and dark themes
  • Support for text selection, which is probably important for any chat
  • Changing the corner radius

Install

go get github.com/limafresh/messagebubble/v2@latest

demo

Usage

An example can be seen here.

bubble := messagebubble.NewMessageBubble(
	"Alex", // sender's name
	"Hi, how are you?", // message text
	"13:36", // sending time
	false, // mine: true, other: false
)

Customization

Colors

bubble.Colors.Bubble.Mine = []color.NRGBA{
	{255, 51, 0, 255}, // for light theme
	{153, 0, 255, 255}, // for dark theme
}

Available: Bubble.Mine, Bubble.Other, Text.Mine, Text.Other, Time.Mine, Time.Other.

Fields

Field Value Description
Colors *messagebubble.Colors Bubble colors
CornerRadius float32 The radius of the bubble's corners
TimeSize float32 The size of the time label
HideSender bool Whether to hide the sender label (in messages not mine)
HideTime bool Whether to hide the time label

Example:

bubble.CornerRadius = 16
bubble.TimeSize = 10

Constants

  • DefaultCornerRadius
  • DefaultTimeSize
  • DefaultMaxWidth

Customization of bubbles in a container

For example, let's change CornerRadius of all bubbles in vbox:

for _, obj := range vbox.Objects {
	if bubble, ok := obj.(*messagebubble.MessageBubble); ok {
		bubble.CornerRadius = 16
	}
}

Contributors

Languages