2016-10-30 16:02:11 +01:00

49 lines
833 B
Go

package views
import (
"github.com/gizak/termui"
"github.com/erroneousboat/slack-term/components"
"github.com/erroneousboat/slack-term/service"
)
type View struct {
Input *components.Input
Chat *components.Chat
Channels *components.Channels
Mode *components.Mode
}
func CreateChatView(svc *service.SlackService) *View {
input := components.CreateInput()
channels := components.CreateChannels(svc, input.Par.Height)
chat := components.CreateChat(
svc,
input.Par.Height,
svc.SlackChannels[channels.SelectedChannel],
svc.Channels[channels.SelectedChannel],
)
mode := components.CreateMode()
view := &View{
Input: input,
Channels: channels,
Chat: chat,
Mode: mode,
}
return view
}
func (v *View) Refresh() {
termui.Render(
v.Input,
v.Chat,
v.Channels,
v.Mode,
)
}