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
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NumberInput creates a text input editing *value as a number between lo
|
||||
// and hi, which the arrows Up and Down, and the buttons beside it, step
|
||||
// by step. What is typed applies as soon as it is a number in range, and
|
||||
// shows rounded to the decimals of step once the input loses the focus.
|
||||
// Changed reports a new value.
|
||||
//
|
||||
// ui.NumberInput(c, &app.copies, 1, 99, 1)
|
||||
func coreNumberInput(c *context, value *float64, lo, hi, step float64) *node {
|
||||
t := c.theme
|
||||
row := coreRow(c).Gap(t.Space(1)).Shrink(0).AlignItems(Center)
|
||||
row.widget = "NumberInput"
|
||||
decimals := 0
|
||||
if s := strconv.FormatFloat(step, 'f', -1, 64); strings.Contains(s, ".") {
|
||||
decimals = len(s) - strings.IndexByte(s, '.') - 1
|
||||
}
|
||||
format := func(v float64) string { return strconv.FormatFloat(v, 'f', decimals, 64) }
|
||||
text := coreLocal(row, "text", func() string { return format(*value) })
|
||||
set := func(v float64) {
|
||||
v = math.Max(lo, math.Min(hi, v))
|
||||
if decimals >= 0 {
|
||||
p := math.Pow(10, float64(decimals))
|
||||
v = math.Round(v*p) / p
|
||||
}
|
||||
if v != *value {
|
||||
*value = v
|
||||
row.st.markChanged()
|
||||
c.rt.consumed = true
|
||||
}
|
||||
}
|
||||
row.Children(func() {
|
||||
in := coreTextInput(c, text).Width(t.Space(20)).Shrink(1).MinWidth(0)
|
||||
in.widget = "NumberInput"
|
||||
in.afterInput(func() {
|
||||
if in.Changed() {
|
||||
if v, err := strconv.ParseFloat(strings.TrimSpace(*text), 64); err == nil && v >= lo && v <= hi {
|
||||
set(v)
|
||||
}
|
||||
}
|
||||
if in.Shortcut(0, KeyUp) {
|
||||
set(*value + step)
|
||||
*text = format(*value)
|
||||
}
|
||||
if in.Shortcut(0, KeyDown) {
|
||||
set(*value - step)
|
||||
*text = format(*value)
|
||||
}
|
||||
if !in.Focused() {
|
||||
// What the app set, or what was typed, shown in full.
|
||||
*text = format(*value)
|
||||
}
|
||||
})
|
||||
in.hasRange, in.accRange, in.accStep = true, [3]float64{lo, hi, *value}, step
|
||||
for _, b := range []struct {
|
||||
label string
|
||||
delta float64
|
||||
}{{"−", -step}, {"+", step}} {
|
||||
btn := coreButton(c, b.label).Padding(t.Space(1), t.Space(2)).Label(map[bool]string{true: "Increase", false: "Decrease"}[b.delta > 0])
|
||||
btn.Disabled(b.delta < 0 && *value <= lo || b.delta > 0 && *value >= hi)
|
||||
btn.afterInput(func() {
|
||||
if btn.Clicked() {
|
||||
set(*value + b.delta)
|
||||
*text = format(*value)
|
||||
}
|
||||
})
|
||||
btn.TextColor(t.Text)
|
||||
}
|
||||
})
|
||||
return row
|
||||
}
|
||||
Reference in new issue
Block a user