Improve default colors
This commit is contained in:
parent
813e652784
commit
3be7497ea5
11 changed files with 43 additions and 66 deletions
14
discordo.go
14
discordo.go
|
|
@ -27,12 +27,14 @@ var currentGuild gateway.GuildCreateEvent
|
|||
var currentChannel discord.Channel
|
||||
|
||||
func main() {
|
||||
tview.Styles.PrimitiveBackgroundColor = tcell.GetColor("#1C1E26")
|
||||
|
||||
loginModal = ui.NewLoginModal(onLoginModalDone)
|
||||
guildsDropDown = ui.NewGuildsDropDown(onGuildsDropDownSelected)
|
||||
channelsList = ui.NewChannelsList(onChannelsListSelected)
|
||||
messagesTextView = ui.NewMessagesTextView(onMessagesTextViewChanged)
|
||||
mainFlex = ui.NewMainFlex(guildsDropDown, channelsList, messagesTextView)
|
||||
app = ui.NewApplication(onApplicationInputCapture)
|
||||
app = ui.NewApplication()
|
||||
|
||||
token := util.GetPassword("token")
|
||||
if token != "" {
|
||||
|
|
@ -45,7 +47,7 @@ func main() {
|
|||
app.SetRoot(loginModal, true)
|
||||
}
|
||||
|
||||
if err := app.Run(); err != nil {
|
||||
if err := app.EnableMouse(true).Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -54,14 +56,6 @@ func onLoginFormQuitButtonSelected() {
|
|||
app.Stop()
|
||||
}
|
||||
|
||||
func onApplicationInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
if event.Key() == tcell.KeyCtrlR {
|
||||
app.Sync()
|
||||
}
|
||||
|
||||
return event
|
||||
}
|
||||
|
||||
func onMessagesTextViewChanged() {
|
||||
app.Draw()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewApplication(onApplicationInputCapture func(event *tcell.EventKey) *tcell.EventKey) *tview.Application {
|
||||
app := tview.NewApplication().
|
||||
EnableMouse(true).
|
||||
SetInputCapture(onApplicationInputCapture)
|
||||
func NewApplication() (app *tview.Application) {
|
||||
app = tview.NewApplication()
|
||||
|
||||
return app
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var guildsDropDownBackgroundColor = tcell.GetColor("#1C1E26")
|
||||
|
||||
func NewGuildsDropDown(onGuildsDropDownSelected func(text string, index int)) *tview.DropDown {
|
||||
guildsDropDown := tview.NewDropDown().
|
||||
func NewGuildsDropDown(onGuildsDropDownSelected func(text string, index int)) (guildsDropDown *tview.DropDown) {
|
||||
guildsDropDown = tview.NewDropDown().
|
||||
SetLabel("Guild: ").
|
||||
SetSelectedFunc(onGuildsDropDownSelected)
|
||||
guildsDropDown.
|
||||
SetFieldBackgroundColor(guildsDropDownBackgroundColor).
|
||||
SetBackgroundColor(guildsDropDownBackgroundColor).
|
||||
SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor).
|
||||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return guildsDropDown
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewMainFlex(guildsDropDown *tview.DropDown, channelsList *tview.List, messagesTextView *tview.TextView) *tview.Flex {
|
||||
mainFlex := tview.NewFlex().
|
||||
func NewMainFlex(guildsDropDown *tview.DropDown, channelsList *tview.List, messagesTextView *tview.TextView) (mainFlex *tview.Flex) {
|
||||
mainFlex = tview.NewFlex().
|
||||
SetDirection(tview.FlexRow).
|
||||
AddItem(guildsDropDown, 3, 1, false).
|
||||
AddItem(
|
||||
|
|
@ -17,5 +17,5 @@ func NewMainFlex(guildsDropDown *tview.DropDown, channelsList *tview.List, messa
|
|||
false,
|
||||
)
|
||||
|
||||
return mainFlex
|
||||
return
|
||||
}
|
||||
|
|
|
|||
10
ui/forms.go
10
ui/forms.go
|
|
@ -5,16 +5,12 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var loginFormBackgroundColor = tcell.GetColor("#1C1E26")
|
||||
var loginFormButtonBackgroundColor = tcell.GetColor("#5865F2")
|
||||
|
||||
func NewLoginForm(via string, onLoginFormLoginButtonSelected func(), onLoginFormQuitButtonSelected func()) *tview.Form {
|
||||
loginForm := tview.NewForm().
|
||||
func NewLoginForm(via string, onLoginFormLoginButtonSelected func(), onLoginFormQuitButtonSelected func()) (loginForm *tview.Form) {
|
||||
loginForm = tview.NewForm().
|
||||
AddButton("Login", onLoginFormLoginButtonSelected).
|
||||
AddButton("Quit", onLoginFormQuitButtonSelected)
|
||||
loginForm.
|
||||
SetButtonBackgroundColor(loginFormButtonBackgroundColor).
|
||||
SetBackgroundColor(loginFormBackgroundColor).
|
||||
SetButtonBackgroundColor(tcell.GetColor("#5865F2")).
|
||||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,20 +5,16 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var messageInputFieldBackgroundColor = tcell.GetColor("#1C1E26")
|
||||
var messageInputFieldPlaceholderTextColor = tcell.ColorWhite
|
||||
|
||||
func NewMessageInputField(onMessageInputFieldDone func(key tcell.Key)) *tview.InputField {
|
||||
messageInputField := tview.NewInputField().
|
||||
func NewMessageInputField(onMessageInputFieldDone func(key tcell.Key)) (messageInputField *tview.InputField) {
|
||||
messageInputField = tview.NewInputField().
|
||||
SetPlaceholder("Message...").
|
||||
SetFieldWidth(0).
|
||||
SetDoneFunc(onMessageInputFieldDone)
|
||||
messageInputField.
|
||||
SetFieldBackgroundColor(messageInputFieldBackgroundColor).
|
||||
SetPlaceholderTextColor(messageInputFieldPlaceholderTextColor).
|
||||
SetBackgroundColor(messageInputFieldBackgroundColor).
|
||||
SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor).
|
||||
SetPlaceholderTextColor(tcell.ColorDarkGray).
|
||||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return messageInputField
|
||||
return
|
||||
}
|
||||
|
|
|
|||
14
ui/lists.go
14
ui/lists.go
|
|
@ -5,17 +5,17 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var channelsListBackgroundColor = tcell.GetColor("#1C1E26")
|
||||
|
||||
func NewChannelsList(onChannelsListSelected func(i int, mainText string, secondaryText string, _ rune)) *tview.List {
|
||||
channelsList := tview.NewList().
|
||||
func NewChannelsList(onChannelsListSelected func(i int, mainText string, secondaryText string, _ rune)) (channelsList *tview.List) {
|
||||
channelsList = tview.NewList().
|
||||
ShowSecondaryText(false).
|
||||
SetMainTextColor(tcell.ColorDarkGray).
|
||||
SetSelectedTextColor(tcell.ColorWhite).
|
||||
SetSelectedBackgroundColor(tview.Styles.PrimitiveBackgroundColor).
|
||||
SetSelectedFunc(onChannelsListSelected)
|
||||
channelsList.
|
||||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1).
|
||||
SetTitle("Channels").
|
||||
SetBackgroundColor(channelsListBackgroundColor)
|
||||
SetTitle("Channels")
|
||||
|
||||
return channelsList
|
||||
return
|
||||
}
|
||||
|
|
|
|||
10
ui/modals.go
10
ui/modals.go
|
|
@ -1,12 +1,14 @@
|
|||
package ui
|
||||
|
||||
import "github.com/rivo/tview"
|
||||
import (
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var LoginViaTokenLoginModalButton = "Login via token"
|
||||
var LoginViaEmailPasswordLoginModalButton = "Login via email and password"
|
||||
|
||||
func NewLoginModal(onLoginModalDone func(buttonIndex int, buttonLabel string)) *tview.Modal {
|
||||
loginModal := tview.NewModal().
|
||||
func NewLoginModal(onLoginModalDone func(buttonIndex int, buttonLabel string)) (loginModal *tview.Modal) {
|
||||
loginModal = tview.NewModal().
|
||||
SetText("Choose a login method:").
|
||||
AddButtons([]string{LoginViaTokenLoginModalButton, LoginViaEmailPasswordLoginModalButton}).
|
||||
SetDoneFunc(onLoginModalDone)
|
||||
|
|
@ -14,5 +16,5 @@ func NewLoginModal(onLoginModalDone func(buttonIndex int, buttonLabel string)) *
|
|||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return loginModal
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var messagesTextViewBackgroundColor = tcell.GetColor("#1C1E26")
|
||||
|
||||
func NewMessagesTextView(onMessagesTextViewChanged func()) *tview.TextView {
|
||||
messagesTextView := tview.NewTextView().
|
||||
func NewMessagesTextView(onMessagesTextViewChanged func()) (messagesTextView *tview.TextView) {
|
||||
messagesTextView = tview.NewTextView().
|
||||
SetDynamicColors(true).
|
||||
SetWrap(true).
|
||||
SetWordWrap(true).
|
||||
|
|
@ -17,8 +14,7 @@ func NewMessagesTextView(onMessagesTextViewChanged func()) *tview.TextView {
|
|||
SetChangedFunc(onMessagesTextViewChanged)
|
||||
messagesTextView.
|
||||
SetBorder(true).
|
||||
SetBorderPadding(0, 0, 1, 1).
|
||||
SetBackgroundColor(messagesTextViewBackgroundColor)
|
||||
SetBorderPadding(0, 0, 1, 1)
|
||||
|
||||
return messagesTextView
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ func SendMessage(session *session.Session, channelID discord.ChannelID, content
|
|||
}
|
||||
}
|
||||
|
||||
func GetMessages(session *session.Session, channelID discord.ChannelID, limit uint) []discord.Message {
|
||||
func GetMessages(session *session.Session, channelID discord.ChannelID, limit uint) (messages []discord.Message) {
|
||||
messages, err := session.Messages(channelID, limit)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return messages
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ import (
|
|||
|
||||
const Service string = "discordo"
|
||||
|
||||
func GetPassword(user string) string {
|
||||
func GetPassword(user string) (password string) {
|
||||
password, err := keyring.Get(Service, user)
|
||||
if err == keyring.ErrNotFound {
|
||||
return ""
|
||||
}
|
||||
|
||||
return password
|
||||
return
|
||||
}
|
||||
|
||||
func SetPassword(user string, password string) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue