Revert
This commit is contained in:
parent
cf8cc8f72b
commit
3410b0a29d
3 changed files with 33 additions and 33 deletions
|
|
@ -69,6 +69,21 @@ func (lf *LoginForm) onLoginButtonSelected() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mainFlex = newMainFlex()
|
||||
discordState = newState(token)
|
||||
err = discordState.Open(context.Background())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
right := tview.NewFlex()
|
||||
right.SetDirection(tview.FlexRow)
|
||||
right.AddItem(messagesText, 0, 1, false)
|
||||
right.AddItem(messageInput, 3, 1, false)
|
||||
|
||||
// The guilds tree is always focused first at start-up.
|
||||
mainFlex.AddItem(guildsTree, 0, 1, true)
|
||||
mainFlex.AddItem(right, 0, 4, false)
|
||||
|
||||
mainFlex.SetInputCapture(onInputCapture)
|
||||
app.SetRoot(mainFlex, true)
|
||||
}
|
||||
|
|
|
|||
18
main.go
18
main.go
|
|
@ -19,7 +19,7 @@ var (
|
|||
discordState *State
|
||||
|
||||
app = tview.NewApplication()
|
||||
mainFlex *MainFlex
|
||||
mainFlex = tview.NewFlex()
|
||||
guildsTree *GuildsTree
|
||||
messagesText *MessagesText
|
||||
messageInput *MessageInput
|
||||
|
|
@ -69,6 +69,11 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Initialize UI widgets
|
||||
guildsTree = newGuildsTree()
|
||||
messagesText = newMessagesText()
|
||||
messageInput = newMessageInput()
|
||||
|
||||
// mission failed, we'll get 'em next time
|
||||
if token == "" {
|
||||
app.SetRoot(newLoginForm(), true)
|
||||
|
|
@ -79,7 +84,16 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mainFlex = newMainFlex()
|
||||
right := tview.NewFlex()
|
||||
right.SetDirection(tview.FlexRow)
|
||||
right.AddItem(messagesText, 0, 1, false)
|
||||
right.AddItem(messageInput, 3, 1, false)
|
||||
|
||||
// The guilds tree is always focused first at start-up.
|
||||
mainFlex.AddItem(guildsTree, 0, 1, true)
|
||||
mainFlex.AddItem(right, 0, 4, false)
|
||||
|
||||
mainFlex.SetInputCapture(onInputCapture)
|
||||
app.SetRoot(mainFlex, true)
|
||||
}
|
||||
|
||||
|
|
|
|||
31
main_flex.go
31
main_flex.go
|
|
@ -4,38 +4,9 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type MainFlex struct {
|
||||
*tview.Flex
|
||||
}
|
||||
|
||||
func newMainFlex() *MainFlex {
|
||||
mf := &MainFlex{
|
||||
Flex: tview.NewFlex(),
|
||||
}
|
||||
|
||||
// Initialize UI widgets
|
||||
guildsTree = newGuildsTree()
|
||||
messagesText = newMessagesText()
|
||||
messageInput = newMessageInput()
|
||||
|
||||
right := tview.NewFlex()
|
||||
right.SetDirection(tview.FlexRow)
|
||||
right.AddItem(messagesText, 0, 1, false)
|
||||
right.AddItem(messageInput, 3, 1, false)
|
||||
|
||||
// The guilds tree is always focused first at start-up.
|
||||
mf.AddItem(guildsTree, 0, 1, true)
|
||||
mf.AddItem(right, 0, 4, false)
|
||||
|
||||
mf.SetInputCapture(mainFlex.onInputCapture)
|
||||
|
||||
return mf
|
||||
}
|
||||
|
||||
func (mf *MainFlex) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
func onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
log.Println(event.Name())
|
||||
switch event.Name() {
|
||||
case cfg.Keys.GuildsTree.Focus:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue