소스 검색

Improve default colors

rigormorrtiss 4 년 전
부모
커밋
3be7497ea5
11개의 변경된 파일43개의 추가작업 그리고 66개의 파일을 삭제
  1. 4 10
      discordo.go
  2. 3 6
      ui/app.go
  3. 4 8
      ui/dropdowns.go
  4. 3 3
      ui/flex.go
  5. 3 7
      ui/forms.go
  6. 5 9
      ui/inputfields.go
  7. 7 7
      ui/lists.go
  8. 6 4
      ui/modals.go
  9. 4 8
      ui/textviews.go
  10. 2 2
      util/discord.go
  11. 2 2
      util/keyring.go

+ 4 - 10
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()
 }

+ 3 - 6
ui/app.go

@@ -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
 }

+ 4 - 8
ui/dropdowns.go

@@ -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
 }

+ 3 - 3
ui/flex.go

@@ -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
 }

+ 3 - 7
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 - 9
ui/inputfields.go

@@ -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
 }

+ 7 - 7
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
 }

+ 6 - 4
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
 }

+ 4 - 8
ui/textviews.go

@@ -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
 }

+ 2 - 2
util/discord.go

@@ -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
 }

+ 2 - 2
util/keyring.go

@@ -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) {