forked from Mirrors/gomuks
Add RoomView previews to roster view
This commit is contained in:
parent
f6b722f523
commit
1eb132a589
2 changed files with 13 additions and 0 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue