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.
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package mobile
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
)
|
|
|
|
// inkGrow is how long a ripple takes to cover what was pressed, and inkFade
|
|
// how long it takes to go after the press.
|
|
const (
|
|
inkGrow = 225 * time.Millisecond
|
|
inkFade = 150 * time.Millisecond
|
|
)
|
|
|
|
type inkState struct {
|
|
x, y float32
|
|
at, gone time.Time
|
|
on bool
|
|
}
|
|
|
|
// Ink draws Material's ripple over the element as it is pressed, spreading
|
|
// from where the finger went down, and returns it. The element clips it to its
|
|
// corners if it clips.
|
|
func Ink(e ui.Element) ui.Element {
|
|
s := ui.Local(e, inkKey{}, func() inkState { return inkState{} })
|
|
pressed := e.Pressed()
|
|
switch {
|
|
case pressed && !s.on:
|
|
s.on = true
|
|
s.x, s.y, _ = e.PointerPosition()
|
|
s.at, s.gone = time.Time{}, time.Time{}
|
|
case !pressed && s.on:
|
|
s.on = false
|
|
s.gone = time.Time{}
|
|
}
|
|
color := ui.RGBA(128, 128, 128, 0.2)
|
|
e.DrawOver(func(p *ui.Painter, r ui.Rect) {
|
|
now := p.Now()
|
|
if s.at.IsZero() {
|
|
if !s.on && s.gone.IsZero() {
|
|
return
|
|
}
|
|
s.at = now
|
|
}
|
|
if !s.on && s.gone.IsZero() {
|
|
s.gone = now
|
|
}
|
|
alpha := float32(1)
|
|
if !s.gone.IsZero() {
|
|
alpha = 1 - float32(now.Sub(s.gone))/float32(inkFade)
|
|
if alpha <= 0 {
|
|
s.at = time.Time{}
|
|
return
|
|
}
|
|
}
|
|
grow := min(1, float32(now.Sub(s.at))/float32(inkGrow))
|
|
grow = 1 - (1-grow)*(1-grow)
|
|
far := float32(math.Hypot(float64(max(s.x, r.W-s.x)), float64(max(s.y, r.H-s.y))))
|
|
radius := far * grow
|
|
c := color
|
|
c.A = uint8(float32(c.A) * alpha)
|
|
// The element's box holds the circle.
|
|
p.Clip(r, 0, func() {
|
|
var path ui.Path
|
|
path.Circle(r.X+s.x, r.Y+s.y, radius)
|
|
p.FillPath(&path, c)
|
|
})
|
|
p.After(16 * time.Millisecond)
|
|
})
|
|
return e
|
|
}
|
|
|
|
type inkKey struct{}
|