WIP components (as built)
This commit is contained in:
70 files changed
+2610
-235
No files matched your search
+8
-6
@@ -11,11 +11,11 @@ import (
|
||||
"mujicaui/theme"
|
||||
)
|
||||
|
||||
// Attachment is a file attached to a prompt; the caller uploads it.
|
||||
// Attachment describes a caller-uploaded file.
|
||||
type Attachment struct {
|
||||
// Name is required.
|
||||
Name string
|
||||
// Type is the MIME type; empty picks the icon from the name.
|
||||
// Type supplies MIME metadata; empty uses the filename.
|
||||
Type string
|
||||
Size int64
|
||||
// Uploading shows Progress, 0 to 1.
|
||||
@@ -25,7 +25,7 @@ type Attachment struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
// AttachmentChipResult is a chip's element and the user's request this frame.
|
||||
// AttachmentChipResult carries the chip and requested action.
|
||||
type AttachmentChipResult struct {
|
||||
Element *ui.Element
|
||||
removed, retried bool
|
||||
@@ -37,7 +37,7 @@ func (r AttachmentChipResult) Removed() bool { return r.removed }
|
||||
// Retried reports a press of retry on a failed upload.
|
||||
func (r AttachmentChipResult) Retried() bool { return r.retried }
|
||||
|
||||
// AttachmentChip shows an attachment's type, name, size, upload progress or failure, and remove.
|
||||
// AttachmentChip displays upload status, retry and removal controls.
|
||||
func AttachmentChip(c *ui.Context, a Attachment) AttachmentChipResult {
|
||||
if a.Name == "" || a.Size < 0 {
|
||||
panic("mujica: Attachment needs a Name and a non-negative Size")
|
||||
@@ -52,7 +52,7 @@ func AttachmentChip(c *ui.Context, a Attachment) AttachmentChipResult {
|
||||
if a.Err != nil {
|
||||
border = k.Danger
|
||||
}
|
||||
r.Element = ui.Row(c).Gap(u * 2).AlignItems(ui.Center).Padding(u, u, u, u*2).Width(220).
|
||||
r.Element = ui.Row(c).Gap(u*2).AlignItems(ui.Center).Padding(u, u, u, u*2).Width(220).
|
||||
Radius(theme.ControlRadius).Background(k.Surface).Border(theme.BorderWidth, border).Role(ui.RoleGroup).Label(a.Name)
|
||||
disabled := r.Element.IsDisabled()
|
||||
r.Element.Children(func() {
|
||||
@@ -72,7 +72,9 @@ func AttachmentChip(c *ui.Context, a Attachment) AttachmentChipResult {
|
||||
ui.Text(c, fmt.Sprintf(msg(c, "attachment_chip.uploading"), pct)).SingleLine().FontSize(small).TextColor(k.TextMuted).FontFeatures("tnum")
|
||||
frac := float32(a.Progress)
|
||||
ui.Box(c).Height(3).Radius(1.5).Background(k.Border).Role(ui.RoleProgress).Label(fmt.Sprintf(msg(c, "attachment_chip.uploading"), pct)).
|
||||
Draw(func(p *ui.Painter, b ui.Rect) { p.Fill(ui.Rect{X: b.X, Y: b.Y, W: b.W * frac, H: b.H}, k.AccentText, 1.5) })
|
||||
Draw(func(p *ui.Painter, b ui.Rect) {
|
||||
p.Fill(ui.Rect{X: b.X, Y: b.Y, W: b.W * frac, H: b.H}, k.AccentText, 1.5)
|
||||
})
|
||||
default:
|
||||
ui.Text(c, fileMessageSize(c, a.Size)).SingleLine().FontSize(small).TextColor(k.TextMuted)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user