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
+31
-22
@@ -1,30 +1,39 @@
|
||||
package appui
|
||||
|
||||
import (
|
||||
"github.com/egoist/asuka/colors"
|
||||
"github.com/egoist/asuka/sdk/svg"
|
||||
"github.com/egoist/asuka/ui"
|
||||
"embed"
|
||||
"sync"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
// serverIcon is a rack, drawn as vector paths: Asuka's built-in symbols
|
||||
// have no server glyph on Android, and an SVG keeps it crisp at any size.
|
||||
var serverIcon = svg.MustParse(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/></svg>`)
|
||||
//go:embed icons/*.png
|
||||
var iconFiles embed.FS
|
||||
|
||||
// sparklesIcon marks the turn footer. Drawn here for the same reason as
|
||||
// the server icon: not every platform's symbol set has the name.
|
||||
var sparklesIcon = svg.MustParse(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l1.7 4.3L18 9l-4.3 1.7L12 15l-1.7-4.3L6 9l4.3-1.7L12 3z"/><path d="M19 15l.8 1.9L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-1.1L19 15z"/></svg>`)
|
||||
// iconBitmaps decodes the PNG icons once, on the main thread.
|
||||
var iconBitmaps sync.Map // name -> *ui.Bitmap
|
||||
|
||||
// instancesButton opens the server list: one button, because picking a
|
||||
// server is also how the live one is replaced.
|
||||
func (c *controller) instancesButton() ui.Node {
|
||||
return ui.View(ui.ViewProps{
|
||||
OnPress: func() { c.instancesOpen.Set(true) },
|
||||
Label: ui.Val("实例"),
|
||||
Hint: ui.Val("打开服务器列表"),
|
||||
Style: ui.Style{Padding: ui.All(8)},
|
||||
}, svg.View(svg.Props{
|
||||
Icon: serverIcon,
|
||||
Color: ui.Val(colors.Accent),
|
||||
Style: ui.Style{Width: ui.Pt(22), Height: ui.Pt(22)},
|
||||
}))
|
||||
func iconBitmap(name string) *ui.Bitmap {
|
||||
if v, ok := iconBitmaps.Load(name); ok {
|
||||
return v.(*ui.Bitmap)
|
||||
}
|
||||
data, err := iconFiles.ReadFile("icons/" + name + ".png")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
bmp, err := ui.DecodeBitmap(data)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
iconBitmaps.Store(name, bmp)
|
||||
return bmp
|
||||
}
|
||||
|
||||
// barIcon is the PNG a system navigation bar button takes on Android.
|
||||
func barIcon(name string) []byte {
|
||||
data, err := iconFiles.ReadFile("icons/" + name + ".png")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return data
|
||||
}
|
||||
Reference in new issue
Block a user