tangled
alpha
login
or
join now
treethought.xyz
/
attie
5
fork
atom
AT Protocol Terminal Interface Explorer
5
fork
atom
overview
issues
pulls
pipelines
add global footer
Cam Sweeney
3 weeks ago
26f2cfba
b35a01e2
+32
-25
2 changed files
expand all
collapse all
unified
split
ui
app.go
repo.go
+30
-12
ui/app.go
···
9
9
"github.com/bluesky-social/indigo/atproto/syntax"
10
10
"github.com/charmbracelet/bubbles/spinner"
11
11
tea "github.com/charmbracelet/bubbletea"
12
12
+
"github.com/charmbracelet/lipgloss"
12
13
"github.com/treethought/attie/at"
13
14
)
14
15
···
92
93
return a.active.Init()
93
94
}
94
95
96
96
+
const footerHeight = 1
97
97
+
95
98
func (a *App) resizeChildren() tea.Cmd {
96
99
cmds := []tea.Cmd{}
97
97
-
a.search.SetSize(a.w, a.h)
98
98
-
a.repoView.SetSize(a.w, a.h)
99
99
-
a.rlist.SetSize(a.w, a.h)
100
100
-
a.recordView.SetSize(a.w, a.h)
101
101
-
a.jetstream.SetSize(a.w, a.h)
102
102
-
a.jetEventView.SetSize(a.w, a.h)
100
100
+
h := a.h - footerHeight
101
101
+
a.search.SetSize(a.w, h)
102
102
+
a.repoView.SetSize(a.w, h)
103
103
+
a.rlist.SetSize(a.w, h)
104
104
+
a.recordView.SetSize(a.w, h)
105
105
+
a.jetstream.SetSize(a.w, h)
106
106
+
a.jetEventView.SetSize(a.w, h)
103
107
return tea.Batch(cmds...)
104
108
}
105
109
···
225
229
a.actx.collection = ""
226
230
a.actx.record = nil
227
231
cmd := a.repoView.SetRepo(msg.repo)
228
228
-
a.repoView.SetSize(a.w, a.h) // Set size before switching view
232
232
+
a.repoView.SetSize(a.w, a.h-footerHeight) // Set size before switching view
229
233
a.active = a.repoView
230
234
a.search.loading = false
231
235
return a, cmd
···
241
245
a.actx.collection = msg.records.Collection()
242
246
a.actx.record = nil
243
247
cmd := a.rlist.SetRecords(msg.records.Records)
244
244
-
a.rlist.SetSize(a.w, a.h) // Set size before switching view
248
248
+
a.rlist.SetSize(a.w, a.h-footerHeight) // Set size before switching view
245
249
a.active = a.rlist
246
250
a.search.loading = false
247
251
return a, cmd
···
252
256
a.actx.collection = msg.record.Record.Collection()
253
257
a.actx.record = msg.record.Record
254
258
a.recordView.SetRecord(msg.record.Record)
255
255
-
a.recordView.SetSize(a.w, a.h) // Set size before switching view
259
259
+
a.recordView.SetSize(a.w, a.h-footerHeight) // Set size before switching view
256
260
a.active = a.recordView
257
261
return a, nil
258
262
259
263
case jetEventSelectedMsg:
260
264
a.jetEventView.SetEvent(msg.evt)
261
261
-
a.jetEventView.SetSize(a.w, a.h)
265
265
+
a.jetEventView.SetSize(a.w, a.h-footerHeight)
262
266
a.active = a.jetEventView
263
267
a.jetSreamActive = false
264
268
return a, nil
···
326
330
}
327
331
}
328
332
333
333
+
func (a *App) footer() string {
334
334
+
key := func(k string) string {
335
335
+
return lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205")).Render(k)
336
336
+
}
337
337
+
sep := dimStyle.Render(" · ")
338
338
+
content := key("esc") + dimStyle.Render(" back") +
339
339
+
sep + key("ctrl+k") + dimStyle.Render(" search") +
340
340
+
sep + key("ctrl+j") + dimStyle.Render(" jetstream")
341
341
+
return lipgloss.NewStyle().Width(a.w).Align(lipgloss.Right).Render(content)
342
342
+
}
343
343
+
329
344
func (a *App) View() string {
330
345
if a.loading {
331
346
return "Loading... " + a.spinner.View()
332
347
}
348
348
+
var body string
333
349
if a.jetSreamActive {
334
334
-
return a.jetstream.View()
350
350
+
body = a.jetstream.View()
351
351
+
} else {
352
352
+
body = a.active.View()
335
353
}
336
336
-
return a.active.View()
354
354
+
return lipgloss.JoinVertical(lipgloss.Left, body, a.footer())
337
355
}
338
356
339
357
// Message types
+2
-13
ui/repo.go
···
173
173
return
174
174
}
175
175
headerHeight := lipgloss.Height(r.header)
176
176
-
footerHeight := 2 // "\n" + help text line
177
176
178
177
// List gets all remaining space
179
179
-
listHeight := r.height - headerHeight - footerHeight
178
178
+
listHeight := r.height - headerHeight
180
179
if listHeight < 5 {
181
180
listHeight = 5
182
181
}
···
188
187
if r.repo == nil {
189
188
return "No repository loaded"
190
189
}
191
191
-
192
192
-
// Footer help text
193
193
-
footer := dimStyle.Render("Press Esc to go back • ↑/↓ or j/k to navigate • Ctrl+C to quit")
194
194
-
195
195
-
// Join header (fixed), list (scrollable), and footer
196
196
-
return lipgloss.JoinVertical(
197
197
-
lipgloss.Left,
198
198
-
r.header,
199
199
-
r.clist.View(),
200
200
-
"\n"+footer,
201
201
-
)
190
190
+
return lipgloss.JoinVertical(lipgloss.Left, r.header, r.clist.View())
202
191
}