fix: no dead title bar on the server list
While disconnected the screen is the bare list with its own heading; the navigation stack (and its new-session and refresh actions) exists only once connected. That removes the duplicate title and the buttons that could do nothing without a session. Bump version to 0.1.6 (build 7).
This commit is contained in:
1 parent
e240a33e31
commit
56cf889ee9
4 files changed
+36
-24
No files matched your search
+31
-20
@@ -28,24 +28,7 @@ func rootWithStore(st storage.Store) ui.Node {
|
||||
func newApp(st storage.Store) (*controller, ui.Node) {
|
||||
c := newController(st)
|
||||
signal.OnCleanup(c.shutdown)
|
||||
node := ui.Stack(c.screen, ui.ScreenOptions{
|
||||
Title: ui.Val("OpenChamber"),
|
||||
Actions: []ui.Action{
|
||||
{
|
||||
Title: ui.Val("新建"),
|
||||
Icon: ui.IconPlus,
|
||||
Disabled: signal.Func(func() bool { return !c.connected.Get() }),
|
||||
OnPress: c.openNewSession,
|
||||
},
|
||||
{
|
||||
Title: ui.Val("刷新"),
|
||||
Icon: ui.IconRefresh,
|
||||
Disabled: signal.Func(func() bool { return !c.connected.Get() || c.busy.Get() }),
|
||||
OnPress: c.refresh,
|
||||
},
|
||||
},
|
||||
})
|
||||
return c, node
|
||||
return c, c.screen()
|
||||
}
|
||||
|
||||
type controller struct {
|
||||
@@ -132,9 +115,21 @@ func newController(st storage.Store) *controller {
|
||||
return c
|
||||
}
|
||||
|
||||
// screen is the app's tree: a navigation stack while connected (its bar
|
||||
// holds the session actions), and the bare server list while not, so the
|
||||
// list is not framed by a bar whose buttons would do nothing.
|
||||
func (c *controller) screen() ui.Node {
|
||||
return ui.SafeArea(ui.Style{Grow: 1},
|
||||
ui.Show(c.connected, c.sessionsScreen, c.connectionsScreen),
|
||||
return ui.Column(ui.Style{Grow: 1},
|
||||
ui.Show(c.connected,
|
||||
func() ui.Node {
|
||||
return ui.Stack(c.sessionsScreen, ui.ScreenOptions{
|
||||
Title: ui.Val("OpenChamber"),
|
||||
Actions: c.barActions(),
|
||||
}, ui.Style{Grow: 1})
|
||||
},
|
||||
func() ui.Node {
|
||||
return ui.SafeArea(ui.Style{Grow: 1}, c.connectionsScreen())
|
||||
}),
|
||||
c.formSheet(),
|
||||
c.passwordSheet(),
|
||||
c.instancesSheet(),
|
||||
@@ -142,6 +137,22 @@ func (c *controller) screen() ui.Node {
|
||||
)
|
||||
}
|
||||
|
||||
func (c *controller) barActions() []ui.Action {
|
||||
return []ui.Action{
|
||||
{
|
||||
Title: ui.Val("新建"),
|
||||
Icon: ui.IconPlus,
|
||||
OnPress: c.openNewSession,
|
||||
},
|
||||
{
|
||||
Title: ui.Val("刷新"),
|
||||
Icon: ui.IconRefresh,
|
||||
Disabled: signal.Func(func() bool { return c.busy.Get() }),
|
||||
OnPress: c.refresh,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *controller) shutdown() {
|
||||
if c.cancelSSE != nil {
|
||||
c.cancelSSE()
|
||||
|
||||
Reference in new issue
Block a user