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.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+73
@@ -0,0 +1,73 @@
|
||||
package ui_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
// A popup of SelectBase's, a panel with a scroll container that shrinks
|
||||
// inside it, is no taller than the room the window has, as ui.Select's:
|
||||
// its options scroll inside the window, and End shows the last (#1956).
|
||||
// One that fits keeps its height.
|
||||
func TestAttachToFitsRoom(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
count int
|
||||
want float32 // the panel's height
|
||||
}{
|
||||
// 140 DIP above the trigger, 148 below it: the panel takes the
|
||||
// room below, less its top margin and the window's edge.
|
||||
{"long", 30, 320 - (140 + 32) - 4 - 4},
|
||||
// Three options and the panel's padding fit below the trigger.
|
||||
{"short", 3, 3*32 + 2*4},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
options := make([]string, tc.count)
|
||||
for i := range options {
|
||||
options[i] = fmt.Sprintf("Option %02d", i)
|
||||
}
|
||||
last := options[len(options)-1]
|
||||
selected := options[0]
|
||||
var panel ui.Rect
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
ui.Column(c).Padding(140, 20).Children(func() {
|
||||
sel := ui.SelectBase(c, &selected)
|
||||
sel.Trigger.Height(32).Padding(0, 10).Label("Choice").Children(func() {
|
||||
ui.Text(c, selected)
|
||||
})
|
||||
p := sel.Popup(func(panel ui.Element) {
|
||||
panel.Margin(4, 0, 0, 0).Padding(4).MaxHeight(256)
|
||||
ui.Scroll(c).Shrink(1).Children(func() {
|
||||
for _, opt := range options {
|
||||
sel.Item(opt).Height(32).Padding(0, 10).Children(func() {
|
||||
ui.Text(c, opt)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
panel = ui.Rect{}
|
||||
if p.Valid() {
|
||||
panel = p.Bounds()
|
||||
}
|
||||
})
|
||||
}, 400, 320)
|
||||
if err := tt.Click("Choice"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tt.Key(0, ui.KeyEnd)
|
||||
tt.Frame()
|
||||
if panel.Y != 140+32+4 || panel.H != tc.want {
|
||||
t.Errorf("the list box is %+v, want at y %v, %v high", panel, 140+32+4, tc.want)
|
||||
}
|
||||
if bottom := panel.Y + panel.H; bottom > 320-4 {
|
||||
t.Errorf("the list box ends at %v, past the window's edge", bottom)
|
||||
}
|
||||
r, ok := tt.Find(last)
|
||||
if !ok || r.Y < panel.Y || r.Y+r.H > panel.Y+panel.H || r.Y+r.H > 320-4 {
|
||||
t.Errorf("%s after End is at %+v (found %v), outside the list box %+v or the window", last, r, ok, panel)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user