Files
8bitMyGoUI/chat/stickerpicker.go
T
ZacharyZhang-NY 455f5f2a05 Add chat components 321-345; named List rows, inert scroll views
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.
2026-10-12 05:02:36 -04:00

38 lines
912 B
Go

package chat
import (
"log/slog"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/display"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type StickerPickerOptions struct {
Disabled bool
}
type StickerPickerResult struct {
Element *ui.Element
// Picked is the sticker chosen this frame, else empty.
Picked string
}
type stickerKey struct{}
// StickerPicker picks a big face sticker from a grid.
func StickerPicker(c *ui.Context, text string, o StickerPickerOptions) StickerPickerResult {
k := pixel.K(c)
box := ui.Box(c)
cur := ui.Local(box, stickerKey{}, func() int { return 0 })
var res StickerPickerResult
res.Element = box.Children(func() {
if picked := grid(c, k, text, display.EmojiNames, 4, 3, cur, o.Disabled); picked != "" {
res.Picked = picked
slog.Debug("8bit: sticker picked", "label", text, "sticker", picked)
}
})
return res
}