1
0
Fork 0
forked from Mirrors/gomuks

Add RoomView previews to roster view

This commit is contained in:
FIGBERT 2023-03-07 14:11:08 -08:00
parent f6b722f523
commit 1eb132a589
No known key found for this signature in database
GPG key ID: 67F1598D607A844B
2 changed files with 13 additions and 0 deletions

View file

@ -22,6 +22,7 @@ roster:
'Up': prev_room 'Up': prev_room
'Escape': clear 'Escape': clear
'q': quit 'q': quit
'Enter': enter
modal: modal:
'Tab': select_next 'Tab': select_next

View file

@ -35,6 +35,7 @@ type RosterView struct {
rooms []*rooms.Room rooms []*rooms.Room
height, width int height, width int
focused bool
parent *MainView parent *MainView
} }
@ -108,6 +109,14 @@ func (rstr *RosterView) getMostRecentMessage(room *rooms.Room) (string, bool) {
} }
func (rstr *RosterView) Draw(screen mauview.Screen) { func (rstr *RosterView) Draw(screen mauview.Screen) {
if rstr.focused {
if roomView, ok := rstr.parent.getRoomView(rstr.selected.ID, true); ok {
roomView.Update()
roomView.Draw(screen)
return
}
}
rstr.width, rstr.height = screen.Size() rstr.width, rstr.height = screen.Size()
titleStyle := tcell.StyleDefault.Foreground(tcell.ColorDefault).Bold(true) titleStyle := tcell.StyleDefault.Foreground(tcell.ColorDefault).Bold(true)
@ -197,9 +206,12 @@ func (rstr *RosterView) OnKeyEvent(event mauview.KeyEvent) bool {
rstr.selected = rstr.rooms[index-1] rstr.selected = rstr.rooms[index-1]
} }
case "clear": case "clear":
rstr.focused = false
rstr.selected = nil rstr.selected = nil
case "quit": case "quit":
rstr.parent.gmx.Stop(true) rstr.parent.gmx.Stop(true)
case "enter":
rstr.focused = rstr.selected != nil
default: default:
return false return false
} }