refactor(ui): explicitly return values
This commit is contained in:
parent
04e24917de
commit
e4fbeb1c11
9 changed files with 25 additions and 29 deletions
|
|
@ -51,9 +51,10 @@ func main() {
|
|||
tview.Borders.BottomRight = ' '
|
||||
|
||||
config = util.NewConfig()
|
||||
|
||||
loginModal = ui.NewLoginModal(onLoginModalDone)
|
||||
guildsDropDown = ui.NewGuildsDropDown(onGuildsDropDownSelected, config.Theme)
|
||||
channelsTreeNode = ui.NewChannelsTreeNode()
|
||||
channelsTreeNode = tview.NewTreeNode("")
|
||||
channelsTreeView = ui.NewChannelsTreeView(channelsTreeNode, onChannelsTreeViewSelected, config.Theme)
|
||||
messagesTextView = ui.NewMessagesTextView(onMessagesTextViewChanged, config.Theme)
|
||||
mainFlex = ui.NewMainFlex(guildsDropDown, channelsTreeView, messagesTextView)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewApp() (app *tview.Application) {
|
||||
app = tview.NewApplication().
|
||||
func NewApp() *tview.Application {
|
||||
app := tview.NewApplication().
|
||||
EnableMouse(true)
|
||||
|
||||
return
|
||||
return app
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewGuildsDropDown(onGuildsDropDownSelected func(text string, index int), theme *util.Theme) (guildsDropDown *tview.DropDown) {
|
||||
guildsDropDown = tview.NewDropDown()
|
||||
func NewGuildsDropDown(onGuildsDropDownSelected func(text string, index int), theme *util.Theme) *tview.DropDown {
|
||||
guildsDropDown := tview.NewDropDown()
|
||||
|
||||
guildsDropDown.
|
||||
SetLabel("Guild: ").
|
||||
|
|
@ -19,5 +19,5 @@ func NewGuildsDropDown(onGuildsDropDownSelected func(text string, index int), th
|
|||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return
|
||||
return guildsDropDown
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewMainFlex(guildsDropDown *tview.DropDown, channelsTreeView *tview.TreeView, messagesTextView *tview.TextView) (mainFlex *tview.Flex) {
|
||||
func NewMainFlex(guildsDropDown *tview.DropDown, channelsTreeView *tview.TreeView, messagesTextView *tview.TextView) *tview.Flex {
|
||||
midFlex := tview.NewFlex().
|
||||
AddItem(channelsTreeView, 20, 1, false).
|
||||
AddItem(messagesTextView, 0, 3, false)
|
||||
mainFlex = tview.NewFlex().
|
||||
mainFlex := tview.NewFlex().
|
||||
SetDirection(tview.FlexRow).
|
||||
AddItem(guildsDropDown, 3, 1, false).
|
||||
AddItem(midFlex, 0, 1, false)
|
||||
|
||||
return
|
||||
return mainFlex
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewLoginForm(via string, onLoginFormLoginButtonSelected func()) (loginForm *tview.Form) {
|
||||
loginForm = tview.NewForm()
|
||||
func NewLoginForm(via string, onLoginFormLoginButtonSelected func()) *tview.Form {
|
||||
loginForm := tview.NewForm()
|
||||
|
||||
loginForm.
|
||||
AddButton("Login", onLoginFormLoginButtonSelected).
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewMessageInputField(onMessageInputFieldDone func(key tcell.Key), theme *util.Theme) (messageInputField *tview.InputField) {
|
||||
messageInputField = tview.NewInputField()
|
||||
func NewMessageInputField(onMessageInputFieldDone func(key tcell.Key), theme *util.Theme) *tview.InputField {
|
||||
messageInputField := tview.NewInputField()
|
||||
|
||||
messageInputField.
|
||||
SetPlaceholder("Message...").
|
||||
|
|
@ -19,5 +19,5 @@ func NewMessageInputField(onMessageInputFieldDone func(key tcell.Key), theme *ut
|
|||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return
|
||||
return messageInputField
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ const (
|
|||
LoginViaEmailPasswordLoginModalButton = "Login via email and password"
|
||||
)
|
||||
|
||||
func NewLoginModal(onLoginModalDone func(buttonIndex int, buttonLabel string)) (loginModal *tview.Modal) {
|
||||
loginModal = tview.NewModal()
|
||||
func NewLoginModal(onLoginModalDone func(buttonIndex int, buttonLabel string)) *tview.Modal {
|
||||
loginModal := tview.NewModal()
|
||||
|
||||
loginModal.
|
||||
SetText("Choose a login method:").
|
||||
|
|
@ -19,5 +19,5 @@ func NewLoginModal(onLoginModalDone func(buttonIndex int, buttonLabel string)) (
|
|||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return
|
||||
return loginModal
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewMessagesTextView(onMessagesTextViewChanged func(), theme *util.Theme) (messagesTextView *tview.TextView) {
|
||||
messagesTextView = tview.NewTextView()
|
||||
func NewMessagesTextView(onMessagesTextViewChanged func(), theme *util.Theme) *tview.TextView {
|
||||
messagesTextView := tview.NewTextView()
|
||||
|
||||
messagesTextView.
|
||||
SetDynamicColors(true).
|
||||
|
|
@ -19,5 +19,5 @@ func NewMessagesTextView(onMessagesTextViewChanged func(), theme *util.Theme) (m
|
|||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return
|
||||
return messagesTextView
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewChannelsTreeView(channelsTreeNode *tview.TreeNode, onChannelsTreeViewSelected func(node *tview.TreeNode), theme *util.Theme) (channelsTreeView *tview.TreeView) {
|
||||
channelsTreeView = tview.NewTreeView()
|
||||
func NewChannelsTreeView(channelsTreeNode *tview.TreeNode, onChannelsTreeViewSelected func(node *tview.TreeNode), theme *util.Theme) *tview.TreeView {
|
||||
channelsTreeView := tview.NewTreeView()
|
||||
|
||||
channelsTreeView.
|
||||
SetTopLevel(1).
|
||||
|
|
@ -18,10 +18,5 @@ func NewChannelsTreeView(channelsTreeNode *tview.TreeNode, onChannelsTreeViewSel
|
|||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func NewChannelsTreeNode() (channelsTreeNode *tview.TreeNode) {
|
||||
channelsTreeNode = tview.NewTreeNode("")
|
||||
return
|
||||
return channelsTreeView
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue