Files
openchamber-android-native/third_party/mygo/ui/mobile/list.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
2026-11-18 13:22:59 +08:00

72 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package mobile
import "github.com/egoist/mygo/ui"
// RowOptions are what a ListRow shows.
type RowOptions struct {
Title, Subtitle string
// Leading and Trailing build what goes at its ends.
Leading, Trailing func()
// Disclosure shows that it goes somewhere: a chevron on Cupertino.
Disclosure bool
}
// ListRow shows a row of a list, of a height a finger can tap: UITableViewCell's
// on Cupertino and Material's list item on Material, with its look of being
// pressed. Clicked reports a tap.
func ListRow(c *ui.Context, o RowOptions) ui.Element {
t := c.Theme()
minH := float32(44)
if Current() == Material {
minH = 56
}
label := o.Title
if o.Subtitle != "" {
label += ", " + o.Subtitle // screen readers read the row as one
}
row := ui.Row(c).FillWidth().MinHeight(minH).AlignItems(ui.Center).Padding(10, 16).Gap(12).Role(ui.RoleButton).Label(label)
press(row, t)
row.Children(func() {
if o.Leading != nil {
o.Leading()
}
ui.Column(c).Grow(1).Basis(0).Gap(2).Children(func() {
ui.Text(c, o.Title)
if o.Subtitle != "" {
ui.Text(c, o.Subtitle).FontSize(14).TextColor(t.TextMuted)
}
})
if o.Trailing != nil {
o.Trailing()
}
if o.Disclosure && Current() == Cupertino {
ui.Text(c, "›").FontSize(20).TextColor(t.TextMuted)
}
})
return row
}
// Section shows rows together under a header: UITableView's inset grouped style
// on Cupertino, with a line between them; on Material, a heading over the list.
func Section(c *ui.Context, header string, rows func()) ui.Element {
t := c.Theme()
col := ui.Column(c).FillWidth().Gap(6)
if Current() == Cupertino {
col.PaddingX(16)
}
col.Children(func() {
if header != "" {
h := ui.Text(c, header).FontSize(13).TextColor(t.TextMuted)
if Current() == Material {
h.PaddingX(16)
}
}
body := ui.Column(c).FillWidth().Dividers(0.5, t.Border)
if Current() == Cupertino {
body.Background(t.Surface).Radius(10).Clip()
}
body.Children(rows)
})
return col
}