Speech bubbles, a chat log that follows its end, a composer that sends on Enter, typing dots, chat and channel lists, read receipts, reactions, emoji and sticker pickers, mentions, date and unread rules, system lines, member lists, user cards, a mailbox, mail reader and letter, a notification bell, call controls, a voice meter, attachment chips, link previews and polls. pixel's editor takes EnterSends; display's Bubble takes a Fill and exports EmojiSprite. data.List names its rows, which also lets typing choose one. layout.ScrollArea and input.TextArea hold still under Inert, and an inert scroll view leaves the Tab order until it wakes.
37 lines
885 B
Go
37 lines
885 B
Go
package chat
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type SystemMessageOptions struct {
|
|
// Slot inks the line; zero means Faint.
|
|
Slot pixel.Slot
|
|
}
|
|
|
|
// diamond flanks a system message.
|
|
var diamond = pixel.MustSprite(`
|
|
.#.
|
|
###
|
|
.#.
|
|
`)
|
|
|
|
// SystemMessage centers a notice, such as PLAYER 2 HAS JOINED.
|
|
func SystemMessage(c *ui.Context, text string, o SystemMessageOptions) *ui.Element {
|
|
k := pixel.K(c)
|
|
ink := o.Slot
|
|
if ink == pixel.Ink {
|
|
ink = pixel.Faint
|
|
}
|
|
w := tagW(text) + 16
|
|
return ui.Box(c).AlignSelf(ui.Center).Role(ui.RoleText).Label(text).Size(k.D(w), k.D(pixel.LineHeight)).Draw(func(p *ui.Painter, r ui.Rect) {
|
|
g := k.Canvas(p, r)
|
|
y := (pixel.LineHeight - diamond.H) / 2
|
|
g.Sprite(0, y, diamond, 0, pixel.Accent, 1)
|
|
tag(g, 8, 0, text, ink)
|
|
g.Sprite(w-diamond.W, y, diamond, 0, pixel.Accent, 1)
|
|
})
|
|
}
|