2016-09-11 17:55:19 +02:00
|
|
|
package views
|
|
|
|
|
|
|
|
import (
|
2016-10-01 14:07:42 +02:00
|
|
|
"github.com/gizak/termui"
|
|
|
|
|
2016-10-19 09:08:31 +02:00
|
|
|
"github.com/erroneousboat/slack-term/components"
|
|
|
|
"github.com/erroneousboat/slack-term/service"
|
2016-09-11 17:55:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type View struct {
|
|
|
|
Input *components.Input
|
2016-09-24 20:18:09 +02:00
|
|
|
Chat *components.Chat
|
2016-09-25 22:34:02 +02:00
|
|
|
Channels *components.Channels
|
|
|
|
Mode *components.Mode
|
2016-09-11 17:55:19 +02:00
|
|
|
}
|
|
|
|
|
2016-09-25 22:34:02 +02:00
|
|
|
func CreateChatView(svc *service.SlackService) *View {
|
2016-09-11 17:55:19 +02:00
|
|
|
input := components.CreateInput()
|
2016-09-28 22:10:04 +02:00
|
|
|
|
2016-09-25 22:34:02 +02:00
|
|
|
channels := components.CreateChannels(svc, input.Par.Height)
|
2016-09-28 22:10:04 +02:00
|
|
|
|
|
|
|
chat := components.CreateChat(
|
2016-09-30 23:52:26 +02:00
|
|
|
svc,
|
|
|
|
input.Par.Height,
|
|
|
|
svc.SlackChannels[channels.SelectedChannel],
|
2016-10-02 13:32:36 +02:00
|
|
|
svc.Channels[channels.SelectedChannel].Name,
|
2016-09-28 22:10:04 +02:00
|
|
|
)
|
|
|
|
|
2016-09-25 22:34:02 +02:00
|
|
|
mode := components.CreateMode()
|
2016-09-11 17:55:19 +02:00
|
|
|
|
|
|
|
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,
|
|
|
|
)
|
|
|
|
}
|