feat: open the turn actions in a bottom sheet
The footer's "more" button now opens a sheet with the completion time above the actions, matching the first-party client; the platform action sheet dropped the time. Copy answer and fork from here are listed, and a back gesture dismisses it. Bump version to 0.1.9 (build 10).
This commit is contained in:
1 parent
a471c026f1
commit
d3e92f036a
3 files changed
+57
-20
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "OpenChamber",
|
"name": "OpenChamber",
|
||||||
"id": "com.openchamber.native",
|
"id": "com.openchamber.native",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"build": 9,
|
"build": 10,
|
||||||
"orientations": ["portrait", "landscape"]
|
"orientations": ["portrait", "landscape"]
|
||||||
}
|
}
|
||||||
+54
-17
@@ -60,6 +60,9 @@ type chat struct {
|
|||||||
|
|
||||||
modelNames *signal.Signal[map[string]string]
|
modelNames *signal.Signal[map[string]string]
|
||||||
|
|
||||||
|
footerOpen *signal.Signal[bool]
|
||||||
|
footerID *signal.Signal[string]
|
||||||
|
|
||||||
pickerOpen *signal.Signal[bool]
|
pickerOpen *signal.Signal[bool]
|
||||||
pickerKind string
|
pickerKind string
|
||||||
pickerItems *signal.Signal[[]pickerItem]
|
pickerItems *signal.Signal[[]pickerItem]
|
||||||
@@ -100,6 +103,8 @@ func (c *controller) openChat(s *ocapi.Session, nav *ui.Navigator) *chat {
|
|||||||
permList: signal.NewFunc([]ocapi.PermissionRequest{}, nil),
|
permList: signal.NewFunc([]ocapi.PermissionRequest{}, nil),
|
||||||
hasPerms: signal.New(false),
|
hasPerms: signal.New(false),
|
||||||
modelNames: signal.NewFunc(map[string]string{}, nil),
|
modelNames: signal.NewFunc(map[string]string{}, nil),
|
||||||
|
footerOpen: signal.New(false),
|
||||||
|
footerID: signal.New(""),
|
||||||
pickerOpen: signal.New(false),
|
pickerOpen: signal.New(false),
|
||||||
pickerItems: signal.NewFunc([]pickerItem{}, nil),
|
pickerItems: signal.NewFunc([]pickerItem{}, nil),
|
||||||
pickerFilter: signal.New(""),
|
pickerFilter: signal.New(""),
|
||||||
@@ -226,27 +231,58 @@ func (ch *chat) copyAnswer(id string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ch *chat) footerMenu(id string) {
|
func (ch *chat) footerMenu(id string) {
|
||||||
m := ch.byID.Peek()[id]
|
ch.footerID.Set(id)
|
||||||
label := ch.modelName(m.Model)
|
ch.footerOpen.Set(true)
|
||||||
if label == "" {
|
}
|
||||||
label = "回答"
|
|
||||||
}
|
// footerSheet is the "more" panel: the completion time, then the actions,
|
||||||
stamp := ""
|
// as the first-party client shows on touch screens.
|
||||||
if m.Time.Completed > 0 {
|
func (ch *chat) footerSheet() ui.Node {
|
||||||
stamp = time.UnixMilli(m.Time.Completed).Format("2006-01-02 15:04")
|
return ui.Sheet(ui.SheetProps{
|
||||||
}
|
Open: ch.footerOpen,
|
||||||
ui.Alert(ui.AlertProps{
|
Detents: ui.DetentMedium,
|
||||||
Title: label,
|
Grabber: true,
|
||||||
Message: stamp,
|
OnDismiss: func() { ch.footerOpen.Set(false) },
|
||||||
ActionSheet: true,
|
Content: func() ui.Node {
|
||||||
Actions: []ui.Action{
|
id := ch.footerID.Peek()
|
||||||
{Title: ui.Val("复制回答"), Icon: "doc.on.doc", OnPress: func() { ch.copyAnswer(id) }},
|
m := ch.byID.Peek()[id]
|
||||||
{Title: ui.Val("从这里分叉"), OnPress: func() { ch.forkFrom(id) }},
|
stamp := ""
|
||||||
{Title: ui.Val("取消"), Role: ui.ActionCancel},
|
if m.Time.Completed > 0 {
|
||||||
|
stamp = time.UnixMilli(m.Time.Completed).Format("2006-01-02 15:04")
|
||||||
|
}
|
||||||
|
act := func(f func()) func() {
|
||||||
|
return func() {
|
||||||
|
ch.footerOpen.Set(false)
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ui.SafeArea(ui.Style{Padding: ui.All(20), Gap: 4},
|
||||||
|
ui.StaticText("更多操作", ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||||
|
ui.Show(signal.Func(func() bool { return stamp != "" }), func() ui.Node {
|
||||||
|
return ui.Row(ui.Style{Padding: ui.Symmetric(8, 0), Gap: 8, Align: ui.AlignCenter},
|
||||||
|
ui.Symbol(ui.Icon("clock"), ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||||
|
ui.StaticText(stamp, ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
sheetAction("复制回答", "doc.on.doc", act(func() { ch.copyAnswer(id) })),
|
||||||
|
sheetAction("从这里分叉", "", act(func() { ch.forkFrom(id) })),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sheetAction(title string, icon ui.Icon, onPress func()) ui.Node {
|
||||||
|
parts := make([]ui.Node, 0, 2)
|
||||||
|
if icon != "" {
|
||||||
|
parts = append(parts, ui.Symbol(icon, ui.Style{Font: fonts.Body, Color: colors.SecondaryLabel}))
|
||||||
|
}
|
||||||
|
parts = append(parts, ui.StaticText(title, ui.Style{Font: fonts.Body}))
|
||||||
|
return ui.View(ui.ViewProps{
|
||||||
|
OnPress: onPress,
|
||||||
|
Style: ui.Style{Padding: ui.Symmetric(12, 4), Align: ui.AlignCenter},
|
||||||
|
}, ui.Row(ui.Style{Gap: 12, Align: ui.AlignCenter}, parts...))
|
||||||
|
}
|
||||||
|
|
||||||
func (ch *chat) forkFrom(id string) {
|
func (ch *chat) forkFrom(id string) {
|
||||||
client := ch.client()
|
client := ch.client()
|
||||||
if client == nil {
|
if client == nil {
|
||||||
@@ -622,6 +658,7 @@ func (ch *chat) screen() ui.Node {
|
|||||||
ch.permissionSection(),
|
ch.permissionSection(),
|
||||||
ch.composer(),
|
ch.composer(),
|
||||||
),
|
),
|
||||||
|
ch.footerSheet(),
|
||||||
ui.Sheet(ui.SheetProps{
|
ui.Sheet(ui.SheetProps{
|
||||||
Open: ch.pickerOpen,
|
Open: ch.pickerOpen,
|
||||||
Detents: ui.DetentLarge,
|
Detents: ui.DetentLarge,
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ func TestTurnFooter(t *testing.T) {
|
|||||||
a.Tap("更多操作")
|
a.Tap("更多操作")
|
||||||
a.WaitFor("复制回答")
|
a.WaitFor("复制回答")
|
||||||
a.Expect("从这里分叉")
|
a.Expect("从这里分叉")
|
||||||
a.Tap("取消")
|
a.Back()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestForkFromTurnFooter(t *testing.T) {
|
func TestForkFromTurnFooter(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user