Skip to content

Commit

Permalink
fixes theme colors
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerojas26 committed Jul 13, 2024
1 parent d68a380 commit 702f080
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 100 deletions.
13 changes: 6 additions & 7 deletions app/App.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ import (
var App = tview.NewApplication()

func init() {
Styles := tview.Theme{
theme := tview.Theme{
PrimitiveBackgroundColor: tcell.ColorDefault,
ContrastBackgroundColor: tcell.ColorBlue,
MoreContrastBackgroundColor: tcell.ColorGreen,
BorderColor: tcell.ColorWhite,
TitleColor: tcell.ColorWhite,
GraphicsColor: tcell.ColorWhite,
PrimaryTextColor: tcell.ColorWhite.TrueColor(),
SecondaryTextColor: tcell.ColorCadetBlue,
PrimaryTextColor: tcell.ColorDefault.TrueColor(),
SecondaryTextColor: tcell.ColorYellow,
TertiaryTextColor: tcell.ColorGreen,
InverseTextColor: tcell.ColorDarkGray,
ContrastSecondaryTextColor: tcell.ColorNavy,
InverseTextColor: tcell.ColorWhite,
ContrastSecondaryTextColor: tcell.ColorBlack,
}

tview.Styles = Styles
tview.Styles = theme
}
3 changes: 1 addition & 2 deletions components/ConfirmationModal.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package components

import (
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)

Expand All @@ -17,7 +16,7 @@ func NewConfirmationModal(confirmationText string) *ConfirmationModal {
modal.SetText("Are you sure?")
}
modal.AddButtons([]string{"Yes", "No"})
modal.SetBackgroundColor(tcell.ColorBlack)
modal.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
modal.SetTextColor(tview.Styles.PrimaryTextColor)

return &ConfirmationModal{
Expand Down
14 changes: 7 additions & 7 deletions components/ConnectionForm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ func NewConnectionForm(connectionPages *models.ConnectionPages) *ConnectionForm

wrapper.SetDirection(tview.FlexColumnCSS)

addForm := tview.NewForm().SetFieldBackgroundColor(tcell.ColorWhite).SetButtonBackgroundColor(tcell.ColorWhite).SetLabelColor(tcell.ColorWhite.TrueColor()).SetFieldTextColor(tcell.ColorBlack)
addForm := tview.NewForm().SetFieldBackgroundColor(tview.Styles.InverseTextColor).SetButtonBackgroundColor(tview.Styles.InverseTextColor).SetLabelColor(tview.Styles.PrimaryTextColor).SetFieldTextColor(tview.Styles.ContrastSecondaryTextColor)
addForm.AddInputField("Name", "", 0, nil, nil)
addForm.AddInputField("URL", "", 0, nil, nil)

buttonsWrapper := tview.NewFlex().SetDirection(tview.FlexColumn)

saveButton := tview.NewButton("[darkred]F1 [black]Save")
saveButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
saveButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(saveButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

testButton := tview.NewButton("[darkred]F2 [black]Test")
testButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
testButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(testButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

connectButton := tview.NewButton("[darkred]F3 [black]Connect")
connectButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
connectButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(connectButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

cancelButton := tview.NewButton("[darkred]Esc [black]Cancel")
cancelButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
cancelButton.SetStyle(tcell.StyleDefault.Background(tcell.Color(tview.Styles.PrimaryTextColor)))
buttonsWrapper.AddItem(cancelButton, 0, 1, false)

statusText := tview.NewTextView()
Expand Down Expand Up @@ -161,7 +161,7 @@ func (form *ConnectionForm) testConnection(connectionString string) {
return
}

form.StatusText.SetText("Connecting...").SetTextColor(tcell.ColorGreen)
form.StatusText.SetText("Connecting...").SetTextColor(tview.Styles.TertiaryTextColor)

var db drivers.Driver

Expand All @@ -179,7 +179,7 @@ func (form *ConnectionForm) testConnection(connectionString string) {
if err != nil {
form.StatusText.SetText(err.Error()).SetTextStyle(tcell.StyleDefault.Foreground(tcell.ColorRed))
} else {
form.StatusText.SetText("Connection success").SetTextColor(tcell.ColorGreen)
form.StatusText.SetText("Connection success").SetTextColor(tview.Styles.TertiaryTextColor)
}
App.ForceDraw()
}
Expand Down
12 changes: 6 additions & 6 deletions components/ConnectionSelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ func NewConnectionSelection(connectionForm *ConnectionForm, connectionPages *mod
buttonsWrapper := tview.NewFlex().SetDirection(tview.FlexRowCSS)

newButton := tview.NewButton("[darkred]N[black]ew")
newButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
newButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(newButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

connectButton := tview.NewButton("[darkred]C[black]onnect")
connectButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
connectButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(connectButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

editButton := tview.NewButton("[darkred]E[black]dit")
editButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
editButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(editButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

deleteButton := tview.NewButton("[darkred]D[black]elete")
deleteButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
deleteButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(deleteButton, 0, 1, false)
buttonsWrapper.AddItem(nil, 1, 0, false)

quitButton := tview.NewButton("[darkred]Q[black]uit")
quitButton.SetStyle(tcell.StyleDefault.Background(tcell.ColorGhostWhite))
quitButton.SetStyle(tcell.StyleDefault.Background(tview.Styles.PrimaryTextColor))
buttonsWrapper.AddItem(quitButton, 0, 1, false)

statusText := tview.NewTextView()
Expand Down Expand Up @@ -130,7 +130,7 @@ func (cs *ConnectionSelection) Connect(connection models.Connection) {
MainPages.SwitchToPage(connection.URL)
App.Draw()
} else {
cs.StatusText.SetText("Connecting...").SetTextColor(tcell.ColorGreen)
cs.StatusText.SetText("Connecting...").SetTextColor(tview.Styles.TertiaryTextColor)
App.Draw()

var newDbDriver drivers.Driver
Expand Down
3 changes: 2 additions & 1 deletion components/ConnectionsTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func NewConnectionsTable() *ConnectionsTable {
errorTextView: errorTextView,
}

table.SetSelectedStyle(tcell.StyleDefault.Foreground(tview.Styles.PrimaryTextColor).Background(tview.Styles.SecondaryTextColor))
table.SetOffset(5, 0)
table.SetSelectedStyle(tcell.StyleDefault.Foreground(tview.Styles.SecondaryTextColor).Background(tview.Styles.PrimitiveBackgroundColor))

wrapper.AddItem(table, 0, 1, true)

Expand Down
1 change: 1 addition & 0 deletions components/Pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import (
var MainPages = tview.NewPages()

func init() {
MainPages.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
MainPages.AddPage("Connections", NewConnectionPages().Flex, true, true)
}
16 changes: 8 additions & 8 deletions components/ResultTableFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func NewResultsFilter() *ResultsTableFilter {
recordsFilter.SetTitleAlign(tview.AlignCenter)
recordsFilter.SetBorderPadding(0, 0, 1, 1)

recordsFilter.Label.SetTextColor(tcell.ColorOrange)
recordsFilter.Label.SetTextColor(tview.Styles.TertiaryTextColor)
recordsFilter.Label.SetText("WHERE")
recordsFilter.Label.SetBorderPadding(0, 0, 0, 1)

recordsFilter.Input.SetPlaceholder("Enter a WHERE clause to filter the results")
recordsFilter.Input.SetPlaceholderStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorDefault))
recordsFilter.Input.SetFieldBackgroundColor(tcell.ColorDefault)
recordsFilter.Input.SetFieldTextColor(tcell.ColorWhite.TrueColor())
recordsFilter.Input.SetPlaceholderStyle(tcell.StyleDefault.Foreground(tview.Styles.PrimaryTextColor).Background(tview.Styles.PrimitiveBackgroundColor))
recordsFilter.Input.SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
recordsFilter.Input.SetFieldTextColor(tview.Styles.PrimaryTextColor)
recordsFilter.Input.SetDoneFunc(func(key tcell.Key) {
switch key {
case tcell.KeyEnter:
Expand All @@ -50,7 +50,7 @@ func NewResultsFilter() *ResultsTableFilter {

}
})
recordsFilter.Input.SetAutocompleteStyles(tcell.ColorBlack, tcell.StyleDefault.Foreground(tview.Styles.PrimaryTextColor).Background(tcell.ColorBlack), tcell.StyleDefault.Foreground(tview.Styles.PrimaryTextColor).Background(tcell.ColorBlack))
recordsFilter.Input.SetAutocompleteStyles(tview.Styles.PrimitiveBackgroundColor, tcell.StyleDefault.Foreground(tview.Styles.PrimaryTextColor).Background(tview.Styles.PrimitiveBackgroundColor), tcell.StyleDefault.Foreground(tview.Styles.SecondaryTextColor).Background(tview.Styles.PrimitiveBackgroundColor))

recordsFilter.AddItem(recordsFilter.Label, 6, 0, false)
recordsFilter.AddItem(recordsFilter.Input, 0, 1, false)
Expand Down Expand Up @@ -95,21 +95,21 @@ func (filter *ResultsTableFilter) RemoveHighlight() {

func (filter *ResultsTableFilter) RemoveLocalHighlight() {
filter.SetBorderColor(tcell.ColorWhite)
filter.Label.SetTextColor(tcell.ColorOrange)
filter.Label.SetTextColor(tview.Styles.TertiaryTextColor)
filter.Input.SetPlaceholderTextColor(tview.Styles.InverseTextColor)
filter.Input.SetFieldTextColor(tview.Styles.InverseTextColor)
}

func (filter *ResultsTableFilter) Highlight() {
filter.SetBorderColor(tcell.ColorWhite)
filter.Label.SetTextColor(tcell.ColorOrange)
filter.Label.SetTextColor(tview.Styles.TertiaryTextColor)
filter.Input.SetPlaceholderTextColor(tcell.ColorWhite)
filter.Input.SetFieldTextColor(tview.Styles.PrimaryTextColor)
}

func (filter *ResultsTableFilter) HighlightLocal() {
filter.SetBorderColor(tview.Styles.PrimaryTextColor)
filter.Label.SetTextColor(tcell.ColorOrange)
filter.Label.SetTextColor(tview.Styles.TertiaryTextColor)
filter.Input.SetPlaceholderTextColor(tcell.ColorWhite)
filter.Input.SetFieldTextColor(tview.Styles.PrimaryTextColor)
}
88 changes: 44 additions & 44 deletions components/ResultsTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type ResultsTable struct {

var (
ErrorModal = tview.NewModal()
ChangeColor = tcell.ColorDarkOrange.TrueColor()
InsertColor = tcell.ColorDarkGreen.TrueColor()
ChangeColor = tcell.ColorDarkOrange
InsertColor = tcell.ColorDarkGreen
DeleteColor = tcell.ColorRed
)

Expand All @@ -76,14 +76,14 @@ func NewResultsTable(listOfDbChanges *[]models.DbDmlChange, listOfDbInserts *[]m
errorModal.AddButtons([]string{"Ok"})
errorModal.SetText("An error occurred")
errorModal.SetBackgroundColor(tcell.ColorRed)
errorModal.SetTextColor(tcell.ColorBlack)
errorModal.SetButtonStyle(tcell.StyleDefault.Foreground(tcell.ColorBlack))
errorModal.SetTextColor(tview.Styles.PrimaryTextColor)
errorModal.SetButtonStyle(tcell.StyleDefault.Foreground(tview.Styles.PrimaryTextColor))
errorModal.SetFocus(0)

loadingModal := tview.NewModal()
loadingModal.SetText("Loading...")
loadingModal.SetBackgroundColor(tview.Styles.SecondaryTextColor)
loadingModal.SetTextColor(tview.Styles.PrimaryTextColor)
loadingModal.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
loadingModal.SetTextColor(tview.Styles.SecondaryTextColor)

pages := tview.NewPages()
pages.AddPage("table", wrapper, true, true)
Expand All @@ -109,7 +109,7 @@ func NewResultsTable(listOfDbChanges *[]models.DbDmlChange, listOfDbInserts *[]m
table.SetBorders(true)
table.SetFixed(1, 0)
table.SetInputCapture(table.tableInputCapture)
table.SetSelectedStyle(tcell.StyleDefault.Background(tview.Styles.SecondaryTextColor).Foreground(tcell.ColorBlack.TrueColor()))
table.SetSelectedStyle(tcell.StyleDefault.Background(tview.Styles.SecondaryTextColor).Foreground(tview.Styles.ContrastSecondaryTextColor))

return table
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func (table *ResultsTable) AddInsertedRows() {
tableCell.SetExpansion(1)
tableCell.SetReference(inserts[i].PrimaryKeyValue)

tableCell.SetTextColor(tview.Styles.PrimaryTextColor)
tableCell.SetTextColor(tcell.ColorWhite.TrueColor())
tableCell.SetBackgroundColor(InsertColor)

table.SetCell(rowIndex, j, tableCell)
Expand Down Expand Up @@ -421,13 +421,13 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
}
}

if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) == 0 {
table.Tree.ForceRemoveHighlight()
} else if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) > 0 {
table.Tree.GetCurrentNode().SetColor(InsertColor)
} else if len(*table.state.listOfDbChanges) > 0 && len(*table.state.listOfDbInserts) == 0 {
table.Tree.GetCurrentNode().SetColor(ChangeColor)
}
// if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) == 0 {
// table.Tree.ForceRemoveHighlight()
// } else if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) > 0 {
// table.Tree.GetCurrentNode().SetColor(InsertColor)
// } else if len(*table.state.listOfDbChanges) > 0 && len(*table.state.listOfDbInserts) == 0 {
// table.Tree.GetCurrentNode().SetColor(ChangeColor)
// }
} else {
table.AppendNewChange("DELETE", table.GetDBReference(), selectedRowIndex, -1, "")
}
Expand All @@ -447,7 +447,7 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
table.InsertRow(newRow, newRowIndex, newRowUuid)

for i := 0; i < table.GetColumnCount(); i++ {
table.GetCell(newRowIndex, i).SetBackgroundColor(tcell.ColorDarkGreen)
table.GetCell(newRowIndex, i).SetBackgroundColor(InsertColor).SetTextColor(tcell.ColorWhite.TrueColor())
}

newInsert := models.DbInsert{
Expand All @@ -460,11 +460,11 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event

*table.state.listOfDbInserts = append(*table.state.listOfDbInserts, newInsert)

if table.Tree.GetCurrentNode().GetColor() == tview.Styles.InverseTextColor || table.Tree.GetCurrentNode().GetColor() == tview.Styles.PrimaryTextColor {
table.Tree.GetCurrentNode().SetColor(InsertColor)
} else if table.Tree.GetCurrentNode().GetColor() == DeleteColor {
table.Tree.GetCurrentNode().SetColor(ChangeColor)
}
// if table.Tree.GetCurrentNode().GetColor() == tview.Styles.InverseTextColor || table.Tree.GetCurrentNode().GetColor() == tview.Styles.PrimaryTextColor {
// table.Tree.GetCurrentNode().SetColor(InsertColor)
// } else if table.Tree.GetCurrentNode().GetColor() == DeleteColor {
// table.Tree.GetCurrentNode().SetColor(ChangeColor)
// }

table.Select(newRowIndex, 1)

Expand Down Expand Up @@ -918,7 +918,7 @@ func (table *ResultsTable) StartEditingCell(row int, col int, callback func(newV
inputField := tview.NewInputField()
inputField.SetText(cell.Text)
inputField.SetFieldBackgroundColor(tview.Styles.PrimaryTextColor)
inputField.SetFieldTextColor(tcell.ColorBlack)
inputField.SetFieldTextColor(tview.Styles.PrimitiveBackgroundColor)

inputField.SetDoneFunc(func(key tcell.Key) {
table.SetIsEditing(false)
Expand Down Expand Up @@ -1030,18 +1030,18 @@ func (table *ResultsTable) AppendNewChange(changeType string, tableName string,
cell.SetBackgroundColor(tcell.ColorDefault)
cell.SetTextColor(tview.Styles.PrimaryTextColor)

if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) == 0 {
table.Tree.GetCurrentNode().SetColor(tview.Styles.InverseTextColor)
} else if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) > 0 {
table.Tree.GetCurrentNode().SetColor(InsertColor)
} else if len(*table.state.listOfDbChanges) > 0 && len(*table.state.listOfDbInserts) == 0 {
table.Tree.GetCurrentNode().SetColor(ChangeColor)
}
// if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) == 0 {
// table.Tree.GetCurrentNode().SetColor(tview.Styles.InverseTextColor)
// } else if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) > 0 {
// table.Tree.GetCurrentNode().SetColor(InsertColor)
// } else if len(*table.state.listOfDbChanges) > 0 && len(*table.state.listOfDbInserts) == 0 {
// table.Tree.GetCurrentNode().SetColor(ChangeColor)
// }

} else {
cell.SetBackgroundColor(tcell.ColorOrange.TrueColor())
cell.SetTextColor(tcell.ColorBlack.TrueColor())
table.Tree.GetCurrentNode().SetColor(ChangeColor)
// table.Tree.GetCurrentNode().SetColor(ChangeColor)

(*table.state.listOfDbChanges)[indexOfChange].Value = value
}
Expand All @@ -1060,32 +1060,32 @@ func (table *ResultsTable) AppendNewChange(changeType string, tableName string,

cell.SetBackgroundColor(tcell.ColorOrange.TrueColor())
cell.SetTextColor(tcell.ColorBlack.TrueColor())
table.Tree.GetCurrentNode().SetColor(ChangeColor)
// table.Tree.GetCurrentNode().SetColor(ChangeColor)
}
case "DELETE":
if alreadyExists {

*table.state.listOfDbChanges = append((*table.state.listOfDbChanges)[:indexOfChange], (*table.state.listOfDbChanges)[indexOfChange+1:]...)

if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) == 0 {
table.Tree.GetCurrentNode().SetColor(tview.Styles.InverseTextColor)
} else if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) > 0 {
table.Tree.GetCurrentNode().SetColor(InsertColor)
} else if len(*table.state.listOfDbChanges) > 0 && len(*table.state.listOfDbInserts) == 0 {
table.Tree.GetCurrentNode().SetColor(ChangeColor)
}
// if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) == 0 {
// table.Tree.GetCurrentNode().SetColor(tview.Styles.InverseTextColor)
// } else if len(*table.state.listOfDbChanges) == 0 && len(*table.state.listOfDbInserts) > 0 {
// table.Tree.GetCurrentNode().SetColor(InsertColor)
// } else if len(*table.state.listOfDbChanges) > 0 && len(*table.state.listOfDbInserts) == 0 {
// table.Tree.GetCurrentNode().SetColor(ChangeColor)
// }

for i := 0; i < table.GetColumnCount(); i++ {
table.GetCell(rowIndex, i).SetBackgroundColor(tcell.ColorDefault)
table.GetCell(rowIndex, i).SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
}

} else {

if table.Tree.GetCurrentNode().GetColor() == tview.Styles.InverseTextColor || table.Tree.GetCurrentNode().GetColor() == tview.Styles.PrimaryTextColor {
table.Tree.GetCurrentNode().SetColor(DeleteColor)
} else if table.Tree.GetCurrentNode().GetColor() == InsertColor {
table.Tree.GetCurrentNode().SetColor(ChangeColor)
}
// if table.Tree.GetCurrentNode().GetColor() == tview.Styles.InverseTextColor || table.Tree.GetCurrentNode().GetColor() == tview.Styles.PrimaryTextColor {
// table.Tree.GetCurrentNode().SetColor(DeleteColor)
// } else if table.Tree.GetCurrentNode().GetColor() == InsertColor {
// table.Tree.GetCurrentNode().SetColor(ChangeColor)
// }

newChange := models.DbDmlChange{
Type: changeType,
Expand Down
Loading

0 comments on commit 702f080

Please sign in to comment.